cosmetic: move some makefile variable definitions
[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
2a5500b1 10$(OBJS) $(SUBDIR)%.ho $(SUBDIR)%-test.o $(TESTOBJS): CPPFLAGS += -DHAVE_AV_CONFIG_H
72c2bdeb 11
e273b038 12ifdef CONFIG_STATIC
71c61f62
MR
13all: $(SUBDIR)$(LIBNAME)
14
15install-libs: install-lib$(NAME)-static
16
17$(SUBDIR)$(LIBNAME): $(OBJS)
50e10cbd 18 $(RM) $@
71c61f62
MR
19 $(AR) rc $@ $^ $(EXTRAOBJS)
20 $(RANLIB) $@
21endif
22
56540673
MR
23install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
24
71c61f62 25define RULES
3fd422ff 26$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
63611f31 27 $$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
3fd422ff
MR
28
29$(SUBDIR)%-test.o: $(SUBDIR)%.c
2f8ba7fc 30 $$(CC) $$(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
3fd422ff
MR
31
32$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
2f8ba7fc 33 $$(CC) $$(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
3fd422ff
MR
34
35$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
63611f31
MR
36 $$(YASMDEP) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:.o=.d)
37 $$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
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)