vorbis_dec: factor out duplicated code for index reading, bounds checking and
[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)
7
e273b038 8ifdef CONFIG_STATIC
71c61f62
MR
9all: $(SUBDIR)$(LIBNAME)
10
11install-libs: install-lib$(NAME)-static
12
13$(SUBDIR)$(LIBNAME): $(OBJS)
14 rm -f $@
15 $(AR) rc $@ $^ $(EXTRAOBJS)
16 $(RANLIB) $@
17endif
18
19INCINSTDIR := $(INCDIR)/lib$(NAME)
20
bea81a52 21THIS_LIB := $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
bbba084b 22
71c61f62 23define RULES
3fd422ff 24$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
684b28e0 25 $(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
3fd422ff
MR
26
27$(SUBDIR)%-test.o: $(SUBDIR)%.c
b0f0c430 28 $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c -o $$@ $$^
3fd422ff
MR
29
30$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
b0f0c430 31 $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c -o $$@ $$^
3fd422ff
MR
32
33$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
b7c10b2a 34 $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:.o=.d)
3fd422ff
MR
35 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
36
3fd422ff 37clean::
9292bd77 38 rm -f $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
3fd422ff
MR
39 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
40
41distclean:: clean
42 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
43 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
44
bea81a52 45ifdef CONFIG_SHARED
71c61f62
MR
46all: $(SUBDIR)$(SLIBNAME)
47
48install-libs: install-lib$(NAME)-shared
49
50$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
51 cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
52
0147b92e 53$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS)
71c61f62 54 $(SLIB_CREATE_DEF_CMD)
684b28e0 55 $(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
71c61f62
MR
56 $(SLIB_EXTRA_CMD)
57
8e255b8b 58ifdef SUBDIR
76ca42a8 59$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
71c61f62
MR
60endif
61endif
62
63install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
64 install -d "$(SHLIBDIR)"
3c3e0680 65 install -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
71c61f62
MR
66 $(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
67 cd "$(SHLIBDIR)" && \
68 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
69 cd "$(SHLIBDIR)" && \
70 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
71 $(SLIB_INSTALL_EXTRA_CMD)
72
73install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
74 install -d "$(LIBDIR)"
3c3e0680 75 install -m 644 $$< "$(LIBDIR)"
71c61f62
MR
76 $(LIB_INSTALL_EXTRA_CMD)
77
78install-headers::
79 install -d "$(INCINSTDIR)"
80 install -d "$(LIBDIR)/pkgconfig"
81 install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(INCINSTDIR)"
25cd5cb3 82 install -m 644 $(BUILD_ROOT)/lib$(NAME)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
71c61f62
MR
83
84uninstall-libs::
85 -rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
86 "$(SHLIBDIR)/$(SLIBNAME)" \
87 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
88 -$(SLIB_UNINSTALL_EXTRA_CMD)
89 -rm -f "$(LIBDIR)/$(LIBNAME)"
90
91uninstall-headers::
92 rm -f $(addprefix "$(INCINSTDIR)/",$(HEADERS))
93 rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
94 -rmdir "$(INCDIR)"
95endef
96
97$(eval $(RULES))
3fd422ff 98
bbba084b
MR
99$(EXAMPLES) $(TESTPROGS): $(THIS_LIB) $(DEP_LIBS)
100
3fd422ff
MR
101examples: $(EXAMPLES)
102testprogs: $(TESTPROGS)