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

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
$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
14 15
	$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $(CC_O) $^

16
$(SUBDIR)%-test.o: $(SUBDIR)%.c
17 18 19 20 21 22
	$(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
clean::
	$(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
53
	    $(foreach dir,$(DIRS),$(CLEANSUFFIXES:%=$(SUBDIR)$(dir)/%)) \
Måns Rullgård's avatar
Måns Rullgård committed
54 55 56
	    $(HOSTOBJS) $(HOSTPROGS)

distclean:: clean
57 58
	$(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) \
	    $(foreach dir,$(DIRS),$(DISTCLEANSUFFIXES:%=$(SUBDIR)$(dir)/%))
Måns Rullgård's avatar
Måns Rullgård committed
59

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
	$(Q)cd "$(SHLIBDIR)" && \
Måns Rullgård's avatar
Måns Rullgård committed
64
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
Måns Rullgård's avatar
Måns Rullgård committed
65
	$(Q)cd "$(SHLIBDIR)" && \
Måns Rullgård's avatar
Måns Rullgård committed
66
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
67
	$(SLIB_INSTALL_EXTRA_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
68

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

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

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

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

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

$(eval $(RULES))
96

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

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