Move MinGW special casing for shared lib creation to configure.
[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: $(SRCS)
38         $(CC) -MM $(CFLAGS) $^ 1>.depend
39
40 dep:    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 ifeq ($(CONFIG_MINGW),yes)
63         install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
64 else
65         install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
66                 $(shlibdir)/$(SLIBNAME_WITH_VERSION)
67         ln -sf $(SLIBNAME_WITH_VERSION) \
68                $(shlibdir)/$(SLIBNAME_WITH_MAJOR)
69         ln -sf $(SLIBNAME_WITH_VERSION) \
70                $(shlibdir)/$(SLIBNAME)
71 endif
72
73 install-lib-static: $(LIB)
74         install -d "$(libdir)"
75         install -m 644 $(LIB) "$(libdir)"
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 ifeq ($(CONFIG_MINGW),yes)
87         -rm -f $(prefix)/$(SLIBNAME)
88 else
89         -rm -f $(libdir)/$(SLIBNAME_WITH_MAJOR) \
90                $(libdir)/$(SLIBNAME)            \
91                $(libdir)/$(SLIBNAME_WITH_VERSION)
92 endif
93         -rm -f $(libdir)/$(LIB)
94
95 uninstall-headers:
96         rm -f $(addprefix $(incdir)/,$(HEADERS))
97         rm -f $(libdir)/pkgconfig/lib$(NAME).pc
98
99 #
100 # include dependency files if they exist
101 #
102 ifneq ($(wildcard .depend),)
103 include .depend
104 endif