subdir.mak 1.89 KB
Newer Older
Måns Rullgård's avatar
Måns Rullgård committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
SRC_DIR := $(SRC_PATH_BARE)/lib$(NAME)

include $(SUBDIR)../common.mak

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

ifeq ($(BUILD_STATIC),yes)
all: $(SUBDIR)$(LIBNAME)

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

$(SUBDIR)$(LIBNAME): $(OBJS)
	rm -f $@
	$(AR) rc $@ $^ $(EXTRAOBJS)
	$(RANLIB) $@
endif

INCINSTDIR := $(INCDIR)/lib$(NAME)

define RULES
22
ifdef BUILD_SHARED
Måns Rullgård's avatar
Måns Rullgård committed
23 24 25 26 27 28 29
all: $(SUBDIR)$(SLIBNAME)

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

$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
	cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)

30
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS)
Måns Rullgård's avatar
Måns Rullgård committed
31
	$(SLIB_CREATE_DEF_CMD)
32
	$(CC) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter-out $(DEP_LIBS),$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
Måns Rullgård's avatar
Måns Rullgård committed
33 34
	$(SLIB_EXTRA_CMD)

35
ifdef SUBDIR
Måns Rullgård's avatar
Måns Rullgård committed
36
$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
Måns Rullgård's avatar
Måns Rullgård committed
37 38 39 40 41
endif
endif

install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
	install -d "$(SHLIBDIR)"
42
	install -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
Måns Rullgård's avatar
Måns Rullgård committed
43 44 45 46 47 48 49 50 51
	$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	cd "$(SHLIBDIR)" && \
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
	cd "$(SHLIBDIR)" && \
		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
	$(SLIB_INSTALL_EXTRA_CMD)

install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
	install -d "$(LIBDIR)"
52
	install -m 644 $$< "$(LIBDIR)"
Måns Rullgård's avatar
Måns Rullgård committed
53 54 55 56 57 58
	$(LIB_INSTALL_EXTRA_CMD)

install-headers::
	install -d "$(INCINSTDIR)"
	install -d "$(LIBDIR)/pkgconfig"
	install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(INCINSTDIR)"
59
	install -m 644 $(BUILD_ROOT)/lib$(NAME)/lib$(NAME).pc "$(LIBDIR)/pkgconfig"
Måns Rullgård's avatar
Måns Rullgård committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

uninstall-libs::
	-rm -f "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
	       "$(SHLIBDIR)/$(SLIBNAME)"            \
	       "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
	-$(SLIB_UNINSTALL_EXTRA_CMD)
	-rm -f "$(LIBDIR)/$(LIBNAME)"

uninstall-headers::
	rm -f $(addprefix "$(INCINSTDIR)/",$(HEADERS))
	rm -f "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
	-rmdir "$(INCDIR)"
endef

$(eval $(RULES))