chibi-scheme/Makefile.libs
Alexei Lozovsky 04ce3700d7 Shared library installation prefixes
Both SOLIBDIR and BINMODDIR install into $(PREFIX)/lib which is the same
value as LIBDIR -- the traditional name of the directory for installed
libraries. Current duplication is fine for the default installation
(with PREFIX = /usr/local) but it does not play nicely with systems
supporing multiple architectures.

For example, Debian systems allow the users to install libraries for
multiple architectures simultaneously: e.g., 32-bit and 64-bit libraries
for AMD-64 CPUs go into separate directories:

  - 64-bit: /usr/lib/x86_64-linux-gnu/libchibi-scheme.so.0.8.0
  - 32-bit: /usr/lib/i386-linux-gnu/libchibi-scheme.so.0.8.0

Other Linux systems (Red Hat family) use different paths like /usr/lib64
and /usr/lib, but the general idea is the same.

In order to achive this, packaging toolchain supplies appropriate value
of LIBDIR which takes care of these details more or less automagically.

However, with Chibi you currently need to additionally override SOLIBDIR
and BINMODDIR to have all the libraries installed into multiarch-enabled
locations. While definitely doable, it's not convenient.

Redefine SOLIBDIR and BINMODDIR in terms of LIBDIR so that you only need
to override LIBDIR to get the packaging correctly. This does not change
the default installation paths and it is still possible to override
these values individually if necessary.
2020-02-02 10:48:39 +02:00

95 lines
2.7 KiB
Text

# -*- makefile-gmake -*-
# Include-able makefile for building Chibi libraries - see README.libs
# for usage.
.PHONY: all all-libs clean clean-libs dist-clean dist-clean-libs install install-libs uninstall uninstall-libs doc doc-libs
.PRECIOUS: %.c lib/%.c
# install configuration
CC ?= cc
AR ?= ar
CD ?= cd
RM ?= rm -f
LS ?= ls
CP ?= cp
LN ?= ln -sf
INSTALL ?= install
INSTALL_EXE ?= $(INSTALL)
MKDIR ?= $(INSTALL) -d
RMDIR ?= rmdir
TAR ?= tar
DIFF ?= diff
GIT ?= git
GREP ?= grep
FIND ?= find
SYMLINK ?= ln -s
LDCONFIG ?= ldconfig
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
SOLIBDIR ?= $(LIBDIR)
INCDIR ?= $(PREFIX)/include/chibi
MODDIR ?= $(PREFIX)/share/chibi
BINMODDIR ?= $(SOLIBDIR)/chibi
PKGCONFDIR ?= $(SOLIBDIR)/pkgconfig
MANDIR ?= $(PREFIX)/share/man/man1
DESTDIR ?=
########################################################################
# System configuration - if not using GNU make, set PLATFORM and the
# flags from Makefile.detect (at least SO, EXE, CLIBFLAGS) as necessary.
include Makefile.detect
########################################################################
all-libs: $(COMPILED_LIBS)
lib/%.c: lib/%.stub $(CHIBI_FFI_DEPENDENCIES)
$(CHIBI_FFI) $<
lib/chibi/pty$(SO): lib/chibi/pty.c $(INCLUDES) libchibi-scheme$(SO)
$(CC) $(CLIBFLAGS) $(CLINKFLAGS) $(XCPPFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ $< -L. $(RLDFLAGS) $(XLIBS) -lchibi-scheme -lutil
lib/%$(SO): lib/%.c $(INCLUDES) libchibi-scheme$(SO)
$(CC) $(CLIBFLAGS) $(CLINKFLAGS) $(XCPPFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ $< -L. $(RLDFLAGS) $(XLIBS) -lchibi-scheme
doc-libs: $(HTML_LIBS)
doc/lib/%.html: lib/%.sld $(CHIBI_DOC_DEPENDENCIES)
$(MKDIR) $(dir $@)
$(CHIBI_DOC) --html $(subst /,.,$*) > $@
clean-libs:
$(RM) $(COMPILED_LIBS)
$(RM) -r $(patsubst %,%.dSYM,$(COMPILED_LIBS))
$(RM) $(HTML_LIBS)
dist-clean-libs: clean-libs
$(RM) $(patsubst %.stub, %.c, $(shell $(FIND) lib -name \*.stub))
install-libs: all-libs
for dir in $(dir $(patsubst lib/%,%,$(COMPILED_LIBS))) ; do \
$(MKDIR) $(DESTDIR)$(BINMODDIR)/$$dir; \
done
for file in $(patsubst lib/%,%,$(COMPILED_LIBS)) ; do \
$(INSTALL) lib/$$file $(DESTDIR)$(BINMODDIR)/$$file ; \
done
for dir in $(dir $(patsubst lib/%,%,$(SCM_LIBS))) ; do \
$(MKDIR) $(DESTDIR)$(MODDIR)/$$dir; \
done
for file in $(patsubst lib/%,%,$(SCM_LIBS)) ; do \
$(INSTALL) lib/$$file $(DESTDIR)$(MODDIR)/$$file ; \
done
uninstall-libs:
for file in $(patsubst lib/%,%,$(COMPILED_LIBS)) ; do \
$(RM) $(DESTDIR)$(BINMODDIR)/$$file ; \
done
for file in $(patsubst lib/%,%,$(SCM_LIBS)) ; do \
$(RM) $(DESTDIR)$(MODDIR)/$$file ; \
done