]> git.sesse.net Git - ffmpeg/blob - common.mak
Quote names individually, since otherwise the whole list was understood
[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 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
9 OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
10 STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
11 SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
12
13 EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
14
15 all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
16
17 $(LIB): $(STATIC_OBJS)
18         rm -f $@
19         $(AR) rc $@ $^ $(EXTRAOBJS)
20         $(RANLIB) $@
21
22 $(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
23         ln -sf $^ $@
24
25 $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
26         $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
27         $(SLIB_EXTRA_CMD)
28
29 %.o: %.c
30         $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
31
32 %.o: %.S
33         $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
34
35 # BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
36 %.o: %.cpp
37         g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
38
39 %: %.o $(LIB)
40         $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
41
42 depend dep: $(SRCS)
43         $(CC) -MM $(CFLAGS) $^ 1>.depend
44
45 clean::
46         rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
47               *.lib *.def *.dll.a *.exp
48
49 distclean: clean
50         rm -f .depend
51
52 ifeq ($(BUILD_SHARED),yes)
53 INSTLIBTARGETS += install-lib-shared
54 endif
55 ifeq ($(BUILD_STATIC),yes)
56 INSTLIBTARGETS += install-lib-static
57 endif
58
59 install: install-libs install-headers
60
61 install-libs: $(INSTLIBTARGETS)
62
63 install-lib-shared: $(SLIBNAME)
64         install -d "$(shlibdir)"
65         install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
66                 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
67         cd "$(shlibdir)" && \
68                 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
69         cd "$(shlibdir)" && \
70                 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
71
72 install-lib-static: $(LIB)
73         install -d "$(libdir)"
74         install -m 644 $(LIB) "$(libdir)"
75         $(LIB_INSTALL_EXTRA_CMD)
76
77 install-headers:
78         install -d "$(incdir)"
79         install -d "$(libdir)/pkgconfig"
80         install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
81         install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
82
83 uninstall: uninstall-libs uninstall-headers
84
85 uninstall-libs:
86         -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
87                "$(shlibdir)/$(SLIBNAME)"            \
88                "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
89         -rm -f "$(libdir)/$(LIB)"
90
91 uninstall-headers:
92         rm -f $(addprefix "$(incdir)/",$(HEADERS))
93         rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
94
95 .PHONY: all depend dep clean distclean install* uninstall*
96
97 #
98 # include dependency files if they exist
99 #
100 ifneq ($(wildcard .depend),)
101 include .depend
102 endif