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