move common parts of makefiles into common.mak
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
5SRC_DIR = $(SRC_PATH)/$(SUBDIR)
6VPATH = $(SRC_DIR)
7
8#FIXME: This should be in configure/config.mak
9ifeq ($(CONFIG_WIN32),yes)
10LDFLAGS = -Wl,--output-def,$(@:.dll=.def),--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
11endif
12
13ifeq ($(TARGET_GPROF),yes)
14CFLAGS+=-p
15LDFLAGS+=-p
16endif
17
18ifeq ($(TARGET_ARCH_SPARC64),yes)
19CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
20endif
21
22SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
23OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
24STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
25SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
26
27all: $(LIB) $(SLIBNAME)
28
29$(LIB): $(STATIC_OBJS)
30 rm -f $@
31 $(AR) rc $@ $^ $(EXTRAOBJS)
32 $(RANLIB) $@
33
34$(SLIBNAME): $(SHARED_OBJS)
35 $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
36ifeq ($(CONFIG_WIN32),yes)
37 -lib /machine:i386 /def:$(@:.dll=.def)
38endif
39
40%.o: %.c
41 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
42
43%.o: %.S
44 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
45
46# BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
47%.o: %.cpp
48 g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
49
50depend: $(SRCS)
51 $(CC) -MM $(CFLAGS) $^ 1>.depend
52
53dep: depend
54
55clean::
56 rm -f *.o *.d *~ *.a *.lib *.so *.dylib *.dll \
57 *.lib *.def *.dll.a *.exp
58
59distclean: clean
60 rm -f .depend
61
62ifeq ($(BUILD_SHARED),yes)
63INSTLIBTARGETS += install-lib-shared
64endif
65ifeq ($(BUILD_STATIC),yes)
66INSTLIBTARGETS += install-lib-static
67endif
68
69install: install-libs install-headers
70
71install-libs: $(INSTLIBTARGETS)
72
73install-lib-shared: $(SLIBNAME)
74ifeq ($(CONFIG_WIN32),yes)
75 install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
76else
77 install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
78 $(libdir)/$(SLIBNAME_WITH_VERSION)
79 ln -sf $(SLIBNAME_WITH_VERSION) \
80 $(libdir)/$(SLIBNAME_WITH_MAJOR)
81 ln -sf $(SLIBNAME_WITH_VERSION) \
82 $(libdir)/$(SLIBNAME)
83endif
84
85install-lib-static: $(LIB)
86 install -m 644 $(LIB) "$(libdir)"
87
88install-headers:
89 install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
90 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
91
92#
93# include dependency files if they exist
94#
95ifneq ($(wildcard .depend),)
96include .depend
97endif