build: Store library version numbers in .version files
[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
451db983
MR
12all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME)
13all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)
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
bb0babd7 33 $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS)
3fd422ff 34
edb43487
DB
35$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR)
36 $$(M) $$(SRC_PATH)/avbuild/libversion.sh $(NAME) $$< > $$@
37
c5fd4b50
DB
38$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS)
39 $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@
40
71c61f62 41$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
63611f31 42 $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
71c61f62 43
729f953f 44$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS)
71c61f62 45 $(SLIB_CREATE_DEF_CMD)
4436f25a 46 $$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
71c61f62
MR
47 $(SLIB_EXTRA_CMD)
48
0c8cc2c4 49clean::
a6a750c7
DB
50 $(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
51 $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%)
0c8cc2c4
MR
52
53distclean:: clean
a6a750c7
DB
54 $(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) \
55 $(DISTCLEANSUFFIXES:%=$(SUBDIR)tests/%)
0c8cc2c4 56
71c61f62 57install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
63611f31 58 $(Q)mkdir -p "$(SHLIBDIR)"
2f138f0b
MR
59 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
60 $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F);)
61 $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)")
62 $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
63 $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
63611f31 64
71c61f62 65install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
63611f31 66 $(Q)mkdir -p "$(LIBDIR)"
fd676deb 67 $$(INSTALL) -m 644 $$< "$(LIBDIR)"
6cfac0e9 68 $(LIB_INSTALL_EXTRA_CMD)
71c61f62 69
34512bca 70install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
63611f31 71 $(Q)mkdir -p "$(INCINSTDIR)"
34512bca
MR
72 $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
73
74install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc
63611f31 75 $(Q)mkdir -p "$(LIBDIR)/pkgconfig"
34512bca 76 $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
d3cb93b3
RP
77
78uninstall-libs::
50e10cbd 79 -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
d3cb93b3
RP
80 "$(SHLIBDIR)/$(SLIBNAME)" \
81 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
2f138f0b
MR
82 -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)"%)
83 -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)"%)
50e10cbd 84 -$(RM) "$(LIBDIR)/$(LIBNAME)"
d3cb93b3
RP
85
86uninstall-headers::
a2b4d1df 87 $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS))
50e10cbd 88 $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
a2b4d1df 89 -rmdir "$(INCINSTDIR)"
71c61f62
MR
90endef
91
92$(eval $(RULES))
3fd422ff 93
b339182e
DB
94$(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
95$(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME)
bbba084b 96
3fd422ff 97testprogs: $(TESTPROGS)