Move MinGW LDFLAGS setting to configure.
[platform/upstream/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 ifeq ($(TARGET_GPROF),yes)
9 CFLAGS+=-p
10 LDFLAGS+=-p
11 endif
12
13 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
14 OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
15 STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
16 SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
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 ifeq ($(CONFIG_WIN32),yes)
31         -lib /machine:i386 /def:$(@:.dll=.def)
32 endif
33
34 %.o: %.c
35         $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
36
37 %.o: %.S
38         $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
39
40 # BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
41 %.o: %.cpp
42         g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
43
44 depend: $(SRCS)
45         $(CC) -MM $(CFLAGS) $^ 1>.depend
46
47 dep:    depend
48
49 clean::
50         rm -f *.o *.d *~ *.a *.lib *.so *.dylib *.dll \
51               *.lib *.def *.dll.a *.exp
52
53 distclean: clean
54         rm -f .depend
55
56 ifeq ($(BUILD_SHARED),yes)
57 INSTLIBTARGETS += install-lib-shared
58 endif
59 ifeq ($(BUILD_STATIC),yes)
60 INSTLIBTARGETS += install-lib-static
61 endif
62
63 install: install-libs install-headers
64
65 install-libs: $(INSTLIBTARGETS)
66
67 install-lib-shared: $(SLIBNAME)
68         install -d "$(libdir)"
69 ifeq ($(CONFIG_WIN32),yes)
70         install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
71 else
72         install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
73                 $(libdir)/$(SLIBNAME_WITH_VERSION)
74         ln -sf $(SLIBNAME_WITH_VERSION) \
75                 $(libdir)/$(SLIBNAME_WITH_MAJOR)
76         ln -sf $(SLIBNAME_WITH_VERSION) \
77                 $(libdir)/$(SLIBNAME)
78 endif
79
80 install-lib-static: $(LIB)
81         install -d "$(libdir)"
82         install -m 644 $(LIB) "$(libdir)"
83
84 install-headers:
85         install -d "$(incdir)"
86         install -d "$(libdir)/pkgconfig"
87         install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
88         install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
89
90 uninstall: uninstall-libs uninstall-headers
91
92 uninstall-libs:
93 ifeq ($(CONFIG_WIN32),yes)
94         -rm -f $(prefix)/$(SLIBNAME)
95 else
96         -rm -f $(libdir)/$(SLIBNAME_WITH_MAJOR) \
97               $(libdir)/$(SLIBNAME)            \
98               $(libdir)/$(SLIBNAME_WITH_VERSION)
99 endif
100         -rm -f $(libdir)/$(LIB)
101
102 uninstall-headers:
103         rm -f $(addprefix $(incdir)/,$(HEADERS))
104         rm -f $(libdir)/pkgconfig/lib$(NAME).pc
105
106 #
107 # include dependency files if they exist
108 #
109 ifneq ($(wildcard .depend),)
110 include .depend
111 endif