Use consistent paths for adding values to LDFLAGS.
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
997baf01
MR
5VPATH = $(SRC_PATH_BARE)/lib$(NAME)
6SRC_DIR = "$(VPATH)"
8b2121e3 7
722dabcc
DB
8CFLAGS += $(CFLAGS-yes)
9OBJS += $(OBJS-yes)
10ASM_OBJS += $(ASM_OBJS-yes)
2d93bcc7 11CPP_OBJS += $(CPP_OBJS-yes)
722dabcc 12
dadb850a
DB
13CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
14 -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
15 -I$(SRC_PATH)/libavutil $(OPTFLAGS)
1963f5e3 16
1540cfdc 17SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
8b2121e3
MR
18OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
19STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
20SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
21
06aa32ff 22all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
8b2121e3
MR
23
24$(LIB): $(STATIC_OBJS)
25 rm -f $@
26 $(AR) rc $@ $^ $(EXTRAOBJS)
27 $(RANLIB) $@
28
baa3a937
MR
29$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
30 ln -sf $^ $@
31
32$(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
8b2121e3 33 $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
5cb854e1 34 $(SLIB_EXTRA_CMD)
8b2121e3
MR
35
36%.o: %.c
37 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
38
39%.o: %.S
40 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
41
c6c46511
DB
42%: %.o $(LIB)
43 $(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
44
9d0199f4 45depend dep: $(SRCS)
8b2121e3
MR
46 $(CC) -MM $(CFLAGS) $^ 1>.depend
47
8b2121e3 48clean::
b8635ec6 49 rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
009618ea 50 *.def *.dll.a *.exp
8b2121e3
MR
51
52distclean: clean
53 rm -f .depend
54
55ifeq ($(BUILD_SHARED),yes)
56INSTLIBTARGETS += install-lib-shared
57endif
58ifeq ($(BUILD_STATIC),yes)
59INSTLIBTARGETS += install-lib-static
60endif
61
62install: install-libs install-headers
63
64install-libs: $(INSTLIBTARGETS)
65
66install-lib-shared: $(SLIBNAME)
b8e10478 67 install -d "$(shlibdir)"
ca3798dc
RP
68 install -m 755 $(SLIBNAME) "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
69 $(STRIP) "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
e35a3b7d
DB
70 cd "$(shlibdir)" && \
71 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
72 cd "$(shlibdir)" && \
73 ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
8fbec4f4 74 $(SLIB_INSTALL_EXTRA_CMD)
8b2121e3
MR
75
76install-lib-static: $(LIB)
c7bb67c4 77 install -d "$(libdir)"
8b2121e3 78 install -m 644 $(LIB) "$(libdir)"
d7e27559 79 $(LIB_INSTALL_EXTRA_CMD)
8b2121e3
MR
80
81install-headers:
c7bb67c4
MR
82 install -d "$(incdir)"
83 install -d "$(libdir)/pkgconfig"
997baf01 84 install -m 644 $(addprefix $(SRC_DIR)/,$(HEADERS)) "$(incdir)"
8b2121e3
MR
85 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
86
f9edb717
DB
87uninstall: uninstall-libs uninstall-headers
88
89uninstall-libs:
afa61532
DB
90 -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
91 "$(shlibdir)/$(SLIBNAME)" \
92 "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
afa61532 93 -rm -f "$(libdir)/$(LIB)"
f9edb717
DB
94
95uninstall-headers:
76808d6e 96 rm -f $(addprefix "$(incdir)/",$(HEADERS))
afa61532 97 rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
f9edb717 98
3263626f
DB
99.PHONY: all depend dep clean distclean install* uninstall*
100
6ca0c110 101-include .depend