]> git.sesse.net Git - ffmpeg/blob - common.mak
Move CFLAGS handling to common.mak.
[ffmpeg] / common.mak
1 #
2 # common bits used by all libraries
3 #
4
5 SRC_DIR = $(SRC_PATH)/lib$(NAME)
6 VPATH = $(SRC_DIR)
7
8 CFLAGS += -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)
11 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
12 OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
13 STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
14 SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
15
16 EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
17
18 all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
19
20 $(LIB): $(STATIC_OBJS)
21         rm -f $@
22         $(AR) rc $@ $^ $(EXTRAOBJS)
23         $(RANLIB) $@
24
25 $(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
26         ln -sf $^ $@
27
28 $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
29         $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
30         $(SLIB_EXTRA_CMD)
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
42 %: %.o $(LIB)
43         $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
44
45 depend dep: $(SRCS)
46         $(CC) -MM $(CFLAGS) $^ 1>.depend
47
48 clean::
49         rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
50               *.lib *.def *.dll.a *.exp
51
52 distclean: clean
53         rm -f .depend
54
55 ifeq ($(BUILD_SHARED),yes)
56 INSTLIBTARGETS += install-lib-shared
57 endif
58 ifeq ($(BUILD_STATIC),yes)
59 INSTLIBTARGETS += install-lib-static
60 endif
61
62 install: install-libs install-headers
63
64 install-libs: $(INSTLIBTARGETS)
65
66 install-lib-shared: $(SLIBNAME)
67         install -d "$(shlibdir)"
68         install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
69                 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
70         cd "$(shlibdir)" && \
71                 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
72         cd "$(shlibdir)" && \
73                 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
74
75 install-lib-static: $(LIB)
76         install -d "$(libdir)"
77         install -m 644 $(LIB) "$(libdir)"
78         $(LIB_INSTALL_EXTRA_CMD)
79
80 install-headers:
81         install -d "$(incdir)"
82         install -d "$(libdir)/pkgconfig"
83         install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
84         install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
85
86 uninstall: uninstall-libs uninstall-headers
87
88 uninstall-libs:
89         -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
90                "$(shlibdir)/$(SLIBNAME)"            \
91                "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
92         -rm -f "$(libdir)/$(LIB)"
93
94 uninstall-headers:
95         rm -f $(addprefix "$(incdir)/",$(HEADERS))
96         rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
97
98 .PHONY: all depend dep clean distclean install* uninstall*
99
100 #
101 # include dependency files if they exist
102 #
103 ifneq ($(wildcard .depend),)
104 include .depend
105 endif