ee44855f2d6833690527611ef215f835f90b14a2
[libav.git] / subdir.mak
1 SRC_DIR := $(SRC_PATH_BARE)/lib$(NAME)
2
3 include $(SUBDIR)../common.mak
4
5 LIBVERSION := $(lib$(NAME)_VERSION)
6 LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
7
8 ifdef CONFIG_STATIC
9 all: $(SUBDIR)$(LIBNAME)
10
11 install-libs: install-lib$(NAME)-static
12 install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
13
14 $(SUBDIR)$(LIBNAME): $(OBJS)
15 $(RM) $@
16 $(AR) rc $@ $^ $(EXTRAOBJS)
17 $(RANLIB) $@
18 endif
19
20 INCINSTDIR := $(INCDIR)/lib$(NAME)
21
22 THIS_LIB := $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
23
24 define RULES
25 $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
26 $$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
27
28 $(SUBDIR)%-test.o: $(SUBDIR)%.c
29 $$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
30
31 $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
32 $$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
33
34 $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
35 $$(YASMDEP) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:.o=.d)
36 $$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
37
38 clean::
39 $(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
40 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS)))) \
41 $(HOSTOBJS) $(HOSTPROGS)
42
43 distclean:: clean
44 $(RM) $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
45 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
46
47 ifdef CONFIG_SHARED
48 all: $(SUBDIR)$(SLIBNAME)
49
50 install-libs: install-lib$(NAME)-shared
51
52 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
53 $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
54
55 $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
56 $(SLIB_CREATE_DEF_CMD)
57 $$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
58 $(SLIB_EXTRA_CMD)
59
60 ifdef SUBDIR
61 $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
62 endif
63 endif
64
65 install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
66 $(Q)mkdir -p "$(SHLIBDIR)"
67 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
68 $$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
69 $(Q)cd "$(SHLIBDIR)" && \
70 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
71 $(Q)cd "$(SHLIBDIR)" && \
72 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
73 $$(SLIB_INSTALL_EXTRA_CMD)
74
75 install-lib$(NAME)-static: MSG = $(LIBDIR)/$(LIBNAME)
76 install-lib$(NAME)-shared: MSG = $(LIBDIR)/$(SLIBNAME)
77
78 install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
79 $(Q)mkdir -p "$(LIBDIR)"
80 $$(INSTALL) -m 644 $$< "$(LIBDIR)"
81 $(LIB_INSTALL_EXTRA_CMD)
82
83 install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
84 $(Q)mkdir -p "$(INCINSTDIR)"
85 $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
86
87 install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc
88 $(Q)mkdir -p "$(LIBDIR)/pkgconfig"
89 $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
90
91 uninstall-libs::
92 -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
93 "$(SHLIBDIR)/$(SLIBNAME)" \
94 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
95 -$(SLIB_UNINSTALL_EXTRA_CMD)
96 -$(RM) "$(LIBDIR)/$(LIBNAME)"
97
98 uninstall-headers::
99 $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS))
100 $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
101 -rmdir "$(INCDIR)"
102 endef
103
104 $(eval $(RULES))
105
106 $(EXAMPLES) $(TESTPROGS): $(THIS_LIB) $(DEP_LIBS)
107
108 examples: $(EXAMPLES)
109 testprogs: $(TESTPROGS)