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