Add INSTALL makefile variable
[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)
50e10cbd 14 $(RM) $@
71c61f62
MR
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
38d7ad19 28 $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
3fd422ff
MR
29
30$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
38d7ad19 31 $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
3fd422ff
MR
32
33$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
a4aea515 34 $(YASMDEP) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:.o=.d)
3fd422ff
MR
35 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
36
3fd422ff 37clean::
50e10cbd 38 $(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
de4070b5
MR
39 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS)))) \
40 $(HOSTOBJS) $(HOSTPROGS)
3fd422ff
MR
41
42distclean:: clean
50e10cbd 43 $(RM) $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
3fd422ff
MR
44 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
45
bea81a52 46ifdef CONFIG_SHARED
71c61f62
MR
47all: $(SUBDIR)$(SLIBNAME)
48
49install-libs: install-lib$(NAME)-shared
50
51$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
52 cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
53
a482e61b 54$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
71c61f62 55 $(SLIB_CREATE_DEF_CMD)
684b28e0 56 $(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
71c61f62
MR
57 $(SLIB_EXTRA_CMD)
58
8e255b8b 59ifdef SUBDIR
76ca42a8 60$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
71c61f62
MR
61endif
62endif
63
64install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
b578357e 65 mkdir -p "$(SHLIBDIR)"
fd676deb 66 $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
71c61f62
MR
67 $(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
68 cd "$(SHLIBDIR)" && \
69 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
70 cd "$(SHLIBDIR)" && \
71 $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
72 $(SLIB_INSTALL_EXTRA_CMD)
73
74install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
b578357e 75 mkdir -p "$(LIBDIR)"
fd676deb 76 $$(INSTALL) -m 644 $$< "$(LIBDIR)"
71c61f62
MR
77 $(LIB_INSTALL_EXTRA_CMD)
78
79install-headers::
b578357e
MR
80 mkdir -p "$(INCINSTDIR)"
81 mkdir -p "$(LIBDIR)/pkgconfig"
fd676deb 82 $$(INSTALL) -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(INCINSTDIR)"
aa310a9f 83ifdef BUILT_HEADERS
fd676deb 84 $$(INSTALL) -m 644 $(addprefix $(SUBDIR),$(BUILT_HEADERS)) "$(INCINSTDIR)"
aa310a9f 85endif
fd676deb 86 $$(INSTALL) -m 644 $(BUILD_ROOT)/lib$(NAME)/lib$(NAME).pc "$(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)