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