Move CFLAGS handling to common.mak.
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
42225a30 5SRC_DIR = $(SRC_PATH)/lib$(NAME)
8b2121e3
MR
6VPATH = $(SRC_DIR)
7
dadb850a
DB
8CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
9 -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
10 -I$(SRC_PATH)/libavutil $(OPTFLAGS)
1540cfdc 11SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
8b2121e3
MR
12OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
13STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
14SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
15
3aba4289 16EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
0533322e 17
06aa32ff 18all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
8b2121e3
MR
19
20$(LIB): $(STATIC_OBJS)
21 rm -f $@
22 $(AR) rc $@ $^ $(EXTRAOBJS)
23 $(RANLIB) $@
24
baa3a937
MR
25$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
26 ln -sf $^ $@
27
28$(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
8b2121e3 29 $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
5cb854e1 30 $(SLIB_EXTRA_CMD)
8b2121e3
MR
31
32%.o: %.c
33 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
34
35%.o: %.S
36 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
37
38# BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
39%.o: %.cpp
40 g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
41
c6c46511
DB
42%: %.o $(LIB)
43 $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
44
9d0199f4 45depend dep: $(SRCS)
8b2121e3
MR
46 $(CC) -MM $(CFLAGS) $^ 1>.depend
47
8b2121e3 48clean::
b8635ec6 49 rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
8b2121e3
MR
50 *.lib *.def *.dll.a *.exp
51
52distclean: clean
53 rm -f .depend
54
55ifeq ($(BUILD_SHARED),yes)
56INSTLIBTARGETS += install-lib-shared
57endif
58ifeq ($(BUILD_STATIC),yes)
59INSTLIBTARGETS += install-lib-static
60endif
61
62install: install-libs install-headers
63
64install-libs: $(INSTLIBTARGETS)
65
66install-lib-shared: $(SLIBNAME)
b8e10478 67 install -d "$(shlibdir)"
8b2121e3 68 install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
afa61532 69 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
e35a3b7d
DB
70 cd "$(shlibdir)" && \
71 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
72 cd "$(shlibdir)" && \
73 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
8b2121e3
MR
74
75install-lib-static: $(LIB)
c7bb67c4 76 install -d "$(libdir)"
8b2121e3 77 install -m 644 $(LIB) "$(libdir)"
d7e27559 78 $(LIB_INSTALL_EXTRA_CMD)
8b2121e3
MR
79
80install-headers:
c7bb67c4
MR
81 install -d "$(incdir)"
82 install -d "$(libdir)/pkgconfig"
8b2121e3
MR
83 install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
84 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
85
f9edb717
DB
86uninstall: uninstall-libs uninstall-headers
87
88uninstall-libs:
afa61532
DB
89 -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
90 "$(shlibdir)/$(SLIBNAME)" \
91 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
afa61532 92 -rm -f "$(libdir)/$(LIB)"
f9edb717
DB
93
94uninstall-headers:
76808d6e 95 rm -f $(addprefix "$(incdir)/",$(HEADERS))
afa61532 96 rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
f9edb717 97
3263626f
DB
98.PHONY: all depend dep clean distclean install* uninstall*
99
8b2121e3
MR
100#
101# include dependency files if they exist
102#
103ifneq ($(wildcard .depend),)
104include .depend
105endif