build: Fine-grained link-time dependency settings
[libav.git] / avbuild / library.mak
CommitLineData
11a9320d 1include $(SRC_PATH)/avbuild/common.mak
71c61f62 2
edb43487
DB
3-include $(SUBDIR)lib$(NAME).version
4
71c61f62
MR
5LIBVERSION := $(lib$(NAME)_VERSION)
6LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
304b806c 7LIBMINOR := $(lib$(NAME)_VERSION_MINOR)
477b3382 8INCINSTDIR := $(INCDIR)/lib$(NAME)
71c61f62 9
b3fab1f2
JG
10INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
11
92db5083
DB
12all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(NAME).pc
13all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(NAME).pc
451db983 14
c2626492
MR
15LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS)
16$(LIBOBJS) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
72c2bdeb 17
71c61f62 18$(SUBDIR)$(LIBNAME): $(OBJS)
50e10cbd 19 $(RM) $@
4436f25a 20 $(AR) $(ARFLAGS) $(AR_O) $^
71c61f62 21 $(RANLIB) $@
71c61f62 22
56540673
MR
23install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
24
451db983
MR
25install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
26install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
27
71c61f62 28define RULES
14bba44f 29$(TOOLS): THISLIB = $(NAME:%=$(LD_LIB))
b339182e 30$(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
4b895cb2 31
3794062a 32$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
7cb1d9e2 33 $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS)
3fd422ff 34
edb43487
DB
35$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR)
36 $$(M) $$(SRC_PATH)/avbuild/libversion.sh $(NAME) $$< > $$@
37
92db5083
DB
38$(SUBDIR)lib$(NAME).pc: $(SUBDIR)version.h | $(SUBDIR)
39 $$(M) $$(SRC_PATH)/avbuild/pkgconfig_generate.sh $(NAME) "$(DESC)"
40
c5fd4b50
DB
41$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS)
42 $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@
43
71c61f62 44$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
63611f31 45 $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
71c61f62 46
729f953f 47$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS)
71c61f62 48 $(SLIB_CREATE_DEF_CMD)
4436f25a 49 $$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
71c61f62
MR
50 $(SLIB_EXTRA_CMD)
51
0c8cc2c4 52clean::
a6a750c7
DB
53 $(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
54 $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%)
0c8cc2c4
MR
55
56distclean:: clean
a6a750c7
DB
57 $(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) \
58 $(DISTCLEANSUFFIXES:%=$(SUBDIR)tests/%)
0c8cc2c4 59
71c61f62 60install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
63611f31 61 $(Q)mkdir -p "$(SHLIBDIR)"
2f138f0b
MR
62 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
63 $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F);)
64 $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)")
65 $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
66 $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
63611f31 67
71c61f62 68install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
63611f31 69 $(Q)mkdir -p "$(LIBDIR)"
fd676deb 70 $$(INSTALL) -m 644 $$< "$(LIBDIR)"
6cfac0e9 71 $(LIB_INSTALL_EXTRA_CMD)
71c61f62 72
34512bca 73install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
63611f31 74 $(Q)mkdir -p "$(INCINSTDIR)"
34512bca
MR
75 $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
76
77install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc
63611f31 78 $(Q)mkdir -p "$(LIBDIR)/pkgconfig"
34512bca 79 $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
d3cb93b3
RP
80
81uninstall-libs::
50e10cbd 82 -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
d3cb93b3
RP
83 "$(SHLIBDIR)/$(SLIBNAME)" \
84 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
2f138f0b
MR
85 -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)"%)
86 -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)"%)
50e10cbd 87 -$(RM) "$(LIBDIR)/$(LIBNAME)"
d3cb93b3
RP
88
89uninstall-headers::
a2b4d1df 90 $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS))
50e10cbd 91 $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
a2b4d1df 92 -rmdir "$(INCINSTDIR)"
71c61f62
MR
93endef
94
95$(eval $(RULES))
3fd422ff 96
b339182e
DB
97$(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
98$(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME)
bbba084b 99
3fd422ff 100testprogs: $(TESTPROGS)