01d44840c885304ed5db0248e27a354f764c1bc4
[libav.git] / 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 depend dep: $(SRCS)
40 $(CC) -MM $(CFLAGS) $^ 1>.depend
41
42 clean::
43 rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
44 *.lib *.def *.dll.a *.exp
45
46 distclean: clean
47 rm -f .depend
48
49 ifeq ($(BUILD_SHARED),yes)
50 INSTLIBTARGETS += install-lib-shared
51 endif
52 ifeq ($(BUILD_STATIC),yes)
53 INSTLIBTARGETS += install-lib-static
54 endif
55
56 install: install-libs install-headers
57
58 install-libs: $(INSTLIBTARGETS)
59
60 install-lib-shared: $(SLIBNAME)
61 install -d "$(shlibdir)"
62 install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
63 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
64 cd "$(shlibdir)" && \
65 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
66 cd "$(shlibdir)" && \
67 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
68
69 install-lib-static: $(LIB)
70 install -d "$(libdir)"
71 install -m 644 $(LIB) "$(libdir)"
72 $(LIB_INSTALL_EXTRA_CMD)
73
74 install-headers:
75 install -d "$(incdir)"
76 install -d "$(libdir)/pkgconfig"
77 install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
78 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
79
80 uninstall: uninstall-libs uninstall-headers
81
82 uninstall-libs:
83 -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
84 "$(shlibdir)/$(SLIBNAME)" \
85 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
86 -rm -f "$(libdir)/$(LIB)"
87
88 uninstall-headers:
89 rm -f "$(addprefix $(incdir)/,$(HEADERS))"
90 rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
91
92 .PHONY: all depend dep clean distclean install* uninstall*
93
94 #
95 # include dependency files if they exist
96 #
97 ifneq ($(wildcard .depend),)
98 include .depend
99 endif