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

include $(SUBDIR)../common.mak

LIBVERSION := $(lib$(NAME)_VERSION)
LIBMAJOR   := $(lib$(NAME)_VERSION_MAJOR)

8
$(OBJS) $(SUBDIR)%-test.o: CPPFLAGS += -DHAVE_AV_CONFIG_H
9

Måns Rullgård's avatar
Måns Rullgård committed
10
ifdef CONFIG_STATIC
Måns Rullgård's avatar
Måns Rullgård committed
11 12 13 14 15
all: $(SUBDIR)$(LIBNAME)

install-libs: install-lib$(NAME)-static

$(SUBDIR)$(LIBNAME): $(OBJS)
Måns Rullgård's avatar
Måns Rullgård committed
16
	$(RM) $@
Måns Rullgård's avatar
Måns Rullgård committed
17 18 19 20
	$(AR) rc $@ $^ $(EXTRAOBJS)
	$(RANLIB) $@
endif

21 22
install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig

Måns Rullgård's avatar
Måns Rullgård committed
23 24
INCINSTDIR := $(INCDIR)/lib$(NAME)

25
THIS_LIB := $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
26

Måns Rullgård's avatar
Måns Rullgård committed
27
define RULES
28
$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
Måns Rullgård's avatar
Måns Rullgård committed
29
	$$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
30 31

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

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

$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
Måns Rullgård's avatar
Måns Rullgård committed
38 39
	$$(YASMDEP) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:.o=.d)
	$$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
40 41

clean::
Måns Rullgård's avatar
Måns Rullgård committed
42
	$(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
43 44
	    $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS)))) \
	    $(HOSTOBJS) $(HOSTPROGS)
45 46

distclean:: clean
Måns Rullgård's avatar
Måns Rullgård committed
47
	$(RM)  $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
48 49
            $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))

50
ifdef CONFIG_SHARED
Måns Rullgård's avatar
Måns Rullgård committed
51 52 53 54 55
all: $(SUBDIR)$(SLIBNAME)

install-libs: install-lib$(NAME)-shared

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

58
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
Måns Rullgård's avatar
Måns Rullgård committed
59
	$(SLIB_CREATE_DEF_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
60
	$$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
Måns Rullgård's avatar
Måns Rullgård committed
61 62
	$(SLIB_EXTRA_CMD)

63
ifdef SUBDIR
Måns Rullgård's avatar
Måns Rullgård committed
64
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
Måns Rullgård's avatar
Måns Rullgård committed
65 66 67 68
endif
endif

install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
Måns Rullgård's avatar
Måns Rullgård committed
69
	$(Q)mkdir -p "$(SHLIBDIR)"
70
	$$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
Måns Rullgård's avatar
Måns Rullgård committed
71 72
	$$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	$(Q)cd "$(SHLIBDIR)" && \
Måns Rullgård's avatar
Måns Rullgård committed
73
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
Måns Rullgård's avatar
Måns Rullgård committed
74
	$(Q)cd "$(SHLIBDIR)" && \
Måns Rullgård's avatar
Måns Rullgård committed
75
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
76
	$(SLIB_INSTALL_EXTRA_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
77 78 79

install-lib$(NAME)-static: MSG = $(LIBDIR)/$(LIBNAME)
install-lib$(NAME)-shared: MSG = $(LIBDIR)/$(SLIBNAME)
Måns Rullgård's avatar
Måns Rullgård committed
80 81

install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
Måns Rullgård's avatar
Måns Rullgård committed
82
	$(Q)mkdir -p "$(LIBDIR)"
83
	$$(INSTALL) -m 644 $$< "$(LIBDIR)"
Måns Rullgård's avatar
Måns Rullgård committed
84
	$(LIB_INSTALL_EXTRA_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
85

86
install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
Måns Rullgård's avatar
Måns Rullgård committed
87
	$(Q)mkdir -p "$(INCINSTDIR)"
88 89 90
	$$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"

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

uninstall-libs::
Måns Rullgård's avatar
Måns Rullgård committed
95
	-$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
Ramiro Polla's avatar
Ramiro Polla committed
96 97 98
	       "$(SHLIBDIR)/$(SLIBNAME)"            \
	       "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	-$(SLIB_UNINSTALL_EXTRA_CMD)
Måns Rullgård's avatar
Måns Rullgård committed
99
	-$(RM) "$(LIBDIR)/$(LIBNAME)"
Ramiro Polla's avatar
Ramiro Polla committed
100 101

uninstall-headers::
Måns Rullgård's avatar
Måns Rullgård committed
102 103
	$(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS))
	$(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
Ramiro Polla's avatar
Ramiro Polla committed
104
	-rmdir "$(INCDIR)"
Måns Rullgård's avatar
Måns Rullgård committed
105 106 107
endef

$(eval $(RULES))
108

109 110
$(EXAMPLES) $(TESTPROGS): $(THIS_LIB) $(DEP_LIBS)

111 112
examples: $(EXAMPLES)
testprogs: $(TESTPROGS)