c980c3dbe30481c8cefdd8ea97cf4d35aabc55d7
[libav.git] / library.mak
1 include $(SRC_PATH)/common.mak
2
3 LIBVERSION := $(lib$(NAME)_VERSION)
4 LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
5 LIBMINOR := $(lib$(NAME)_VERSION_MINOR)
6 INCINSTDIR := $(INCDIR)/lib$(NAME)
7
8 INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
9
10 all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME)
11 all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)
12
13 $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
14 $(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
15 $(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<
16 -$(STRIP) $(STRIPFLAGS) $@
17
18 LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS)
19 $(LIBOBJS) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
20
21 $(SUBDIR)$(LIBNAME): $(OBJS)
22 $(RM) $@
23 $(AR) $(ARFLAGS) $(AR_O) $^
24 $(RANLIB) $@
25
26 install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
27
28 install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
29 install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
30
31 define RULES
32 $(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
33 $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
34
35 $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
36 $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS)
37
38 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
39 $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
40
41 $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS)
42 $(SLIB_CREATE_DEF_CMD)
43 $$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
44 $(SLIB_EXTRA_CMD)
45
46 clean::
47 $(RM) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
48 $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
49
50 distclean:: clean
51 $(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
52
53 install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
54 $(Q)mkdir -p "$(SHLIBDIR)"
55 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
56 $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F);)
57 $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)")
58 $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)")
59 $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
60
61 install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
62 $(Q)mkdir -p "$(LIBDIR)"
63 $$(INSTALL) -m 644 $$< "$(LIBDIR)"
64 $(LIB_INSTALL_EXTRA_CMD)
65
66 install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
67 $(Q)mkdir -p "$(INCINSTDIR)"
68 $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
69
70 install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc
71 $(Q)mkdir -p "$(LIBDIR)/pkgconfig"
72 $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
73
74 uninstall-libs::
75 -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
76 "$(SHLIBDIR)/$(SLIBNAME)" \
77 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
78 -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)"%)
79 -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)"%)
80 -$(RM) "$(LIBDIR)/$(LIBNAME)"
81
82 uninstall-headers::
83 $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS))
84 $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
85 -rmdir "$(INCINSTDIR)"
86 endef
87
88 $(eval $(RULES))
89
90 $(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
91 $(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME)
92
93 testprogs: $(TESTPROGS)