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