subdir.mak 3.12 KB
Newer Older
Måns Rullgård's avatar
Måns Rullgård committed
1 2 3 4 5 6
SRC_DIR := $(SRC_PATH_BARE)/lib$(NAME)

include $(SUBDIR)../common.mak

LIBVERSION := $(lib$(NAME)_VERSION)
LIBMAJOR   := $(lib$(NAME)_VERSION_MAJOR)
7 8
INCINSTDIR := $(INCDIR)/lib$(NAME)
THIS_LIB   := $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
Måns Rullgård's avatar
Måns Rullgård committed
9

10 11 12
all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME)
all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)

13 14 15 16 17 18 19 20 21 22
$(SUBDIR)%-test.o: $(SUBDIR)%.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $(CC_O) $^

$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $(CC_O) $^

$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
	$(YASMDEP) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
	$(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<

23
$(OBJS) $(SUBDIR)%.ho $(SUBDIR)%-test.o $(TESTOBJS): CPPFLAGS += -DHAVE_AV_CONFIG_H
24

Måns Rullgård's avatar
Måns Rullgård committed
25
$(SUBDIR)$(LIBNAME): $(OBJS)
Måns Rullgård's avatar
Måns Rullgård committed
26
	$(RM) $@
Måns Rullgård's avatar
Måns Rullgård committed
27 28 29
	$(AR) rc $@ $^ $(EXTRAOBJS)
	$(RANLIB) $@

30 31
install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig

32 33 34
install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared

Måns Rullgård's avatar
Måns Rullgård committed
35
define RULES
36
$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
Måns Rullgård's avatar
Måns Rullgård committed
37
	$$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
38

Måns Rullgård's avatar
Måns Rullgård committed
39
$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
Måns Rullgård's avatar
Måns Rullgård committed
40
	$(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
Måns Rullgård's avatar
Måns Rullgård committed
41

42
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
Måns Rullgård's avatar
Måns Rullgård committed
43
	$(SLIB_CREATE_DEF_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
44
	$$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
Måns Rullgård's avatar
Måns Rullgård committed
45 46
	$(SLIB_EXTRA_CMD)

47
ifdef SUBDIR
Måns Rullgård's avatar
Måns Rullgård committed
48
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
Måns Rullgård's avatar
Måns Rullgård committed
49 50
endif

Måns Rullgård's avatar
Måns Rullgård committed
51 52 53 54 55 56 57 58 59
clean::
	$(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
	    $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS)))) \
	    $(HOSTOBJS) $(HOSTPROGS)

distclean:: clean
	$(RM)  $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
            $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))

Måns Rullgård's avatar
Måns Rullgård committed
60
install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
Måns Rullgård's avatar
Måns Rullgård committed
61
	$(Q)mkdir -p "$(SHLIBDIR)"
62
	$$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
Måns Rullgård's avatar
Måns Rullgård committed
63 64
	$$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	$(Q)cd "$(SHLIBDIR)" && \
Måns Rullgård's avatar
Måns Rullgård committed
65
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
Måns Rullgård's avatar
Måns Rullgård committed
66
	$(Q)cd "$(SHLIBDIR)" && \
Måns Rullgård's avatar
Måns Rullgård committed
67
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
68
	$(SLIB_INSTALL_EXTRA_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
69

Måns Rullgård's avatar
Måns Rullgård committed
70
install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
Måns Rullgård's avatar
Måns Rullgård committed
71
	$(Q)mkdir -p "$(LIBDIR)"
72
	$$(INSTALL) -m 644 $$< "$(LIBDIR)"
Måns Rullgård's avatar
Måns Rullgård committed
73
	$(LIB_INSTALL_EXTRA_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
74

75
install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
Måns Rullgård's avatar
Måns Rullgård committed
76
	$(Q)mkdir -p "$(INCINSTDIR)"
77 78 79
	$$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"

install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc
Måns Rullgård's avatar
Måns Rullgård committed
80
	$(Q)mkdir -p "$(LIBDIR)/pkgconfig"
81
	$$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
Ramiro Polla's avatar
Ramiro Polla committed
82 83

uninstall-libs::
Måns Rullgård's avatar
Måns Rullgård committed
84
	-$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
Ramiro Polla's avatar
Ramiro Polla committed
85 86 87
	       "$(SHLIBDIR)/$(SLIBNAME)"            \
	       "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	-$(SLIB_UNINSTALL_EXTRA_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
88
	-$(RM) "$(LIBDIR)/$(LIBNAME)"
Ramiro Polla's avatar
Ramiro Polla committed
89 90

uninstall-headers::
Måns Rullgård's avatar
Måns Rullgård committed
91 92
	$(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS))
	$(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
Ramiro Polla's avatar
Ramiro Polla committed
93
	-rmdir "$(INCDIR)"
Måns Rullgård's avatar
Måns Rullgård committed
94 95 96
endef

$(eval $(RULES))
97

98 99
$(EXAMPLES) $(TESTPROGS): $(THIS_LIB) $(DEP_LIBS)

100 101
examples: $(EXAMPLES)
testprogs: $(TESTPROGS)