Split install-headers target and simplify rules
[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
34512bca 12install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
71c61f62
MR
13
14$(SUBDIR)$(LIBNAME): $(OBJS)
50e10cbd 15 $(RM) $@
71c61f62
MR
16 $(AR) rc $@ $^ $(EXTRAOBJS)
17 $(RANLIB) $@
18endif
19
20INCINSTDIR := $(INCDIR)/lib$(NAME)
21
bea81a52 22THIS_LIB := $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
bbba084b 23
71c61f62 24define RULES
3fd422ff 25$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
684b28e0 26 $(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
3fd422ff
MR
27
28$(SUBDIR)%-test.o: $(SUBDIR)%.c
38d7ad19 29 $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
3fd422ff
MR
30
31$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
38d7ad19 32 $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
3fd422ff
MR
33
34$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
a4aea515 35 $(YASMDEP) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:.o=.d)
3fd422ff
MR
36 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
37
3fd422ff 38clean::
50e10cbd 39 $(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
de4070b5
MR
40 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS)))) \
41 $(HOSTOBJS) $(HOSTPROGS)
3fd422ff
MR
42
43distclean:: clean
50e10cbd 44 $(RM) $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
3fd422ff
MR
45 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
46
bea81a52 47ifdef CONFIG_SHARED
71c61f62
MR
48all: $(SUBDIR)$(SLIBNAME)
49
50install-libs: install-lib$(NAME)-shared
51
52$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
53 cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
54
a482e61b 55$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
71c61f62 56 $(SLIB_CREATE_DEF_CMD)
684b28e0 57 $(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
71c61f62
MR
58 $(SLIB_EXTRA_CMD)
59
8e255b8b 60ifdef SUBDIR
76ca42a8 61$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
71c61f62
MR
62endif
63endif
64
65install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
b578357e 66 mkdir -p "$(SHLIBDIR)"
fd676deb 67 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
71c61f62
MR
68 $(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
69 cd "$(SHLIBDIR)" && \
70 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
71 cd "$(SHLIBDIR)" && \
72 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
73 $(SLIB_INSTALL_EXTRA_CMD)
74
75install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
b578357e 76 mkdir -p "$(LIBDIR)"
fd676deb 77 $$(INSTALL) -m 644 $$< "$(LIBDIR)"
71c61f62
MR
78 $(LIB_INSTALL_EXTRA_CMD)
79
34512bca 80install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
b578357e 81 mkdir -p "$(INCINSTDIR)"
34512bca
MR
82 $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
83
84install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc
b578357e 85 mkdir -p "$(LIBDIR)/pkgconfig"
34512bca 86 $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
d3cb93b3
RP
87
88uninstall-libs::
50e10cbd 89 -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
d3cb93b3
RP
90 "$(SHLIBDIR)/$(SLIBNAME)" \
91 "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
92 -$(SLIB_UNINSTALL_EXTRA_CMD)
50e10cbd 93 -$(RM) "$(LIBDIR)/$(LIBNAME)"
d3cb93b3
RP
94
95uninstall-headers::
50e10cbd
MR
96 $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS))
97 $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
d3cb93b3 98 -rmdir "$(INCDIR)"
71c61f62
MR
99endef
100
101$(eval $(RULES))
3fd422ff 102
bbba084b
MR
103$(EXAMPLES) $(TESTPROGS): $(THIS_LIB) $(DEP_LIBS)
104
3fd422ff
MR
105examples: $(EXAMPLES)
106testprogs: $(TESTPROGS)