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