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