Switch to the LGPL as agreed to by the author according to the
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
42225a30 5SRC_DIR = $(SRC_PATH)/lib$(NAME)
8b2121e3
MR
6VPATH = $(SRC_DIR)
7
1540cfdc 8SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
8b2121e3
MR
9OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
10STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
11SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
12
3aba4289 13EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
0533322e 14
06aa32ff 15all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
8b2121e3
MR
16
17$(LIB): $(STATIC_OBJS)
18 rm -f $@
19 $(AR) rc $@ $^ $(EXTRAOBJS)
20 $(RANLIB) $@
21
baa3a937
MR
22$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
23 ln -sf $^ $@
24
25$(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
8b2121e3 26 $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
5cb854e1 27 $(SLIB_EXTRA_CMD)
8b2121e3
MR
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
c6c46511
DB
39%: %.o $(LIB)
40 $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
41
9d0199f4 42depend dep: $(SRCS)
8b2121e3
MR
43 $(CC) -MM $(CFLAGS) $^ 1>.depend
44
8b2121e3 45clean::
b8635ec6 46 rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
8b2121e3
MR
47 *.lib *.def *.dll.a *.exp
48
49distclean: clean
50 rm -f .depend
51
52ifeq ($(BUILD_SHARED),yes)
53INSTLIBTARGETS += install-lib-shared
54endif
55ifeq ($(BUILD_STATIC),yes)
56INSTLIBTARGETS += install-lib-static
57endif
58
59install: install-libs install-headers
60
61install-libs: $(INSTLIBTARGETS)
62
63install-lib-shared: $(SLIBNAME)
b8e10478 64 install -d "$(shlibdir)"
8b2121e3 65 install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
afa61532 66 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
e35a3b7d
DB
67 cd "$(shlibdir)" && \
68 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
69 cd "$(shlibdir)" && \
70 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
8b2121e3
MR
71
72install-lib-static: $(LIB)
c7bb67c4 73 install -d "$(libdir)"
8b2121e3 74 install -m 644 $(LIB) "$(libdir)"
d7e27559 75 $(LIB_INSTALL_EXTRA_CMD)
8b2121e3
MR
76
77install-headers:
c7bb67c4
MR
78 install -d "$(incdir)"
79 install -d "$(libdir)/pkgconfig"
8b2121e3
MR
80 install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
81 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
82
f9edb717
DB
83uninstall: uninstall-libs uninstall-headers
84
85uninstall-libs:
afa61532
DB
86 -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
87 "$(shlibdir)/$(SLIBNAME)" \
88 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
afa61532 89 -rm -f "$(libdir)/$(LIB)"
f9edb717
DB
90
91uninstall-headers:
76808d6e 92 rm -f $(addprefix "$(incdir)/",$(HEADERS))
afa61532 93 rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
f9edb717 94
3263626f
DB
95.PHONY: all depend dep clean distclean install* uninstall*
96
8b2121e3
MR
97#
98# include dependency files if they exist
99#
100ifneq ($(wildcard .depend),)
101include .depend
102endif