summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 28 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 7ff52e7..6eba87f 100644
--- a/Makefile
+++ b/Makefile
@@ -18,9 +18,23 @@ STATIC_LIBS :=
SHARED_LIBS :=
INTERNAL_LIBS :=
EXTRA_TARGETS :=
+LIB_DEFS :=
+
+define library_definition =
+LIB$(firstword $(subst =, ,$(1))) := lib$(lastword $(subst =, ,$(1))).$(if $(DO_ALLSTATIC),a,so).xyzzy
+ifdef DO_SHARED
+SHARED_LIBS += lib$(lastword $(subst =, ,$(1))).so.xyzzy
+endif
+ifdef DO_STATIC
+STATIC_LIBS += lib$(lastword $(subst =, ,$(1))).a.xyzzy
+endif
+endef
-include config.mak
include package/targets.mak
+
+$(foreach var,$(LIB_DEFS),$(eval $(call library_definition,$(var))))
+
include package/deps.mak
version_m := $(basename $(version))
@@ -30,8 +44,6 @@ CPPFLAGS_ALL := -iquote src/include-local -Isrc/include $(CPPFLAGS)
CFLAGS_ALL := $(CFLAGS) -pipe -Wall
CFLAGS_SHARED := -fPIC
LDFLAGS_ALL := $(LDFLAGS)
-LDFLAGS_SHARED := -shared
-LDLIBS_ALL := $(LDLIBS)
REALCC = $(CROSS_COMPILE)$(CC)
AR := $(CROSS_COMPILE)ar
RANLIB := $(CROSS_COMPILE)ranlib
@@ -67,11 +79,11 @@ ifneq ($(strip $(ALL_BINS)),)
endif
install: install-dynlib install-libexec install-bin install-sbin install-lib install-include
-install-dynlib: $(SHARED_LIBS:lib%.so=$(DESTDIR)$(dynlibdir)/lib%.so)
+install-dynlib: $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(dynlibdir)/lib%.so)
install-libexec: $(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%)
install-bin: $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%)
install-sbin: $(SBIN_TARGETS:%=$(DESTDIR)$(sbindir)/%)
-install-lib: $(STATIC_LIBS:lib%.a=$(DESTDIR)$(libdir)/lib%.a)
+install-lib: $(STATIC_LIBS:lib%.a.xyzzy=$(DESTDIR)$(libdir)/lib%.a)
install-include: $(ALL_INCLUDES:src/include/$(package)/%.h=$(DESTDIR)$(includedir)/$(package)/%.h)
install-data: $(ALL_DATA:src/etc/%=$(DESTDIR)$(datadir)/%)
@@ -80,12 +92,12 @@ ifneq ($(exthome),)
update:
exec $(INSTALL) -l $(notdir $(home)) $(DESTDIR)$(exthome)
-global-links: $(DESTDIR)$(exthome) $(SHARED_LIBS:lib%.so=$(DESTDIR)$(sproot)/library.so/lib%.so) $(BIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%) $(SBIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%)
+global-links: $(DESTDIR)$(exthome) $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(sproot)/library.so/lib%.so.$(version_M)) $(BIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%) $(SBIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%)
$(DESTDIR)$(sproot)/command/%: $(DESTDIR)$(home)/command/%
exec $(INSTALL) -D -l ..$(subst $(sproot),,$(exthome))/command/$(<F) $@
-$(DESTDIR)$(sproot)/library.so/lib%.so: $(DESTDIR)$(dynlibdir)/lib%.so
+$(DESTDIR)$(sproot)/library.so/lib%.so.$(version_M): $(DESTDIR)$(dynlibdir)/lib%.so.$(version_M)
exec $(INSTALL) -D -l ..$(subst $(sproot),,$(exthome))/library.so/$(<F) $@
.PHONY: update global-links
@@ -95,13 +107,12 @@ endif
$(DESTDIR)$(datadir)/%: src/etc/%
exec $(INSTALL) -D -m 644 $< $@
-
-$(DESTDIR)$(dynlibdir)/lib%.so: lib%.so
+$(DESTDIR)$(dynlibdir)/lib%.so: lib%.so.xyzzy
$(INSTALL) -D -m 755 $< $@.$(version) && \
- $(INSTALL) -l $<.$(version) $@.$(version_m) && \
- $(INSTALL) -l $<.$(version_m) $@.$(version_M) && \
- $(INSTALL) -l $<.$(version_M) $@.$(version_l) && \
- exec $(INSTALL) -l $<.$(version_l) $@
+ $(INSTALL) -l $(@F).$(version) $@.$(version_m) && \
+ $(INSTALL) -l $(@F).$(version_m) $@.$(version_M) && \
+ $(INSTALL) -l $(@F).$(version_M) $@.$(version_l) && \
+ exec $(INSTALL) -l $(@F).$(version_l) $@
$(DESTDIR)$(libexecdir)/% $(DESTDIR)$(bindir)/% $(DESTDIR)$(sbindir)/%: % package/modes
exec $(INSTALL) -D -m 600 $< $@
@@ -109,7 +120,7 @@ $(DESTDIR)$(libexecdir)/% $(DESTDIR)$(bindir)/% $(DESTDIR)$(sbindir)/%: % packag
if [ x$$owner != x ] ; then chown -- $$owner $@ ; fi && \
chmod $$mode $@ ; }
-$(DESTDIR)$(libdir)/lib%.a: lib%.a
+$(DESTDIR)$(libdir)/lib%.a: lib%.a.xyzzy
exec $(INSTALL) -D -m 644 $< $@
$(DESTDIR)$(includedir)/$(package)/%.h: src/include/$(package)/%.h
@@ -122,14 +133,14 @@ $(DESTDIR)$(includedir)/$(package)/%.h: src/include/$(package)/%.h
exec $(REALCC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) $(CFLAGS_SHARED) -c -o $@ $<
$(ALL_BINS):
- exec $(REALCC) -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL) $(LDFLAGS_NOSHARED) $^ $(EXTRA_LIBS) $(LDLIBS_ALL)
+ exec $(REALCC) -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL) $(LDFLAGS_NOSHARED) $^ $(EXTRA_LIBS) $(LDLIBS)
-lib%.a:
+lib%.a.xyzzy:
exec $(AR) rc $@ $^
exec $(RANLIB) $@
-lib%.so:
- exec $(REALCC) -o $@ $(CFLAGS_ALL) $(CFLAGS_SHARED) $(LDFLAGS_ALL) $(LDFLAGS_SHARED) -Wl,-soname,$@.$(version_l) $^
+lib%.so.xyzzy:
+ exec $(REALCC) -o $@ $(CFLAGS_ALL) $(CFLAGS_SHARED) $(LDFLAGS_ALL) $(LDFLAGS_SHARED) -Wl,-soname,$(patsubst lib%.so.xyzzy,lib%.so.$(version_M),$@) $^ $(EXTRA_LIBS) $(LDLIBS)
.PHONY: it all clean distclean tgz strip install install-dynlib install-bin install-sbin install-lib install-include install-data