mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-11 06:57:33 +02:00
Refactoring of Makefile for use by third parties (patch from Alan Watson).
This commit is contained in:
parent
202195f4f0
commit
ee017262c6
5 changed files with 319 additions and 135 deletions
2
AUTHORS
2
AUTHORS
|
@ -7,6 +7,7 @@ written by Chris Hanson and John Lamping.
|
||||||
|
|
||||||
Thanks to the following people for patches and bug reports:
|
Thanks to the following people for patches and bug reports:
|
||||||
|
|
||||||
|
* Alan Watson
|
||||||
* Alexander Shendi
|
* Alexander Shendi
|
||||||
* Andreas Rottman
|
* Andreas Rottman
|
||||||
* Bakul Shah
|
* Bakul Shah
|
||||||
|
@ -26,6 +27,7 @@ Thanks to the following people for patches and bug reports:
|
||||||
* Michal Kowalski (sladegen)
|
* Michal Kowalski (sladegen)
|
||||||
* Rajesh Krishnan
|
* Rajesh Krishnan
|
||||||
* Taylor Venable
|
* Taylor Venable
|
||||||
|
* Travis Cross
|
||||||
* Zhang Meng
|
* Zhang Meng
|
||||||
|
|
||||||
If you would prefer not to be listed, or are one of the users listed
|
If you would prefer not to be listed, or are one of the users listed
|
||||||
|
|
175
Makefile
175
Makefile
|
@ -1,116 +1,25 @@
|
||||||
# -*- makefile-gmake -*-
|
# -*- makefile-gmake -*-
|
||||||
|
|
||||||
.PHONY: all libs dist clean cleaner dist-clean install uninstall test checkdefs
|
.PHONY: dist mips-dist cleaner test checkdefs
|
||||||
.PRECIOUS: %.c
|
|
||||||
|
|
||||||
# install configuration
|
CHIBI_FFI ?= $(CHIBI) tools/chibi-ffi
|
||||||
|
CHIBI_FFI_DEPENDENCIES ?= $(CHIBI_DEPENDENCIES) tools/chibi-ffi
|
||||||
|
|
||||||
CC ?= cc
|
CHIBI_DOC ?= $(CHIBI) tools/chibi-doc
|
||||||
CD ?= cd
|
CHIBI_DOC_DEPENDENCIES ?= $(CHIBI_DEPENDENCIES) tools/chibi-doc
|
||||||
RM ?= rm -f
|
|
||||||
LS ?= ls
|
|
||||||
INSTALL ?= install
|
|
||||||
MKDIR ?= $(INSTALL) -d
|
|
||||||
RMDIR ?= rmdir
|
|
||||||
TAR ?= tar
|
|
||||||
DIFF ?= diff
|
|
||||||
GREP ?= grep
|
|
||||||
FIND ?= find
|
|
||||||
SYMLINK ?= ln -s
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
BINDIR ?= $(PREFIX)/bin
|
|
||||||
LIBDIR ?= $(PREFIX)/lib
|
|
||||||
SOLIBDIR ?= $(PREFIX)/lib
|
|
||||||
INCDIR ?= $(PREFIX)/include/chibi
|
|
||||||
MODDIR ?= $(PREFIX)/share/chibi
|
|
||||||
BINMODDIR ?= $(PREFIX)/lib/chibi
|
|
||||||
MANDIR ?= $(PREFIX)/share/man/man1
|
|
||||||
|
|
||||||
DESTDIR ?=
|
|
||||||
|
|
||||||
GENSTUBS ?= ./tools/chibi-ffi
|
|
||||||
GENSTATIC ?= ./tools/chibi-genstatic
|
GENSTATIC ?= ./tools/chibi-genstatic
|
||||||
|
|
||||||
|
CHIBI ?= LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./chibi-scheme$(EXE)
|
||||||
|
CHIBI_DEPENDENCIES = ./chibi-scheme$(EXE)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# system configuration - if not using GNU make, set PLATFORM and the
|
# Library config.
|
||||||
# following flags as necessary.
|
#
|
||||||
|
# This is to allow "make SEXP_USE_BOEHM=1" and "make SEXP_USE_DL=0" to
|
||||||
#
|
# automatically include the necessary compiler and linker flags in
|
||||||
LIBDL = -ldl
|
# addition to setting those features. If not using GNU make just
|
||||||
|
# comment out the ifs and use the else branches for the defaults.
|
||||||
ifndef PLATFORM
|
|
||||||
ifeq ($(shell uname),Darwin)
|
|
||||||
PLATFORM=macosx
|
|
||||||
else
|
|
||||||
ifeq ($(shell uname),FreeBSD)
|
|
||||||
PLATFORM=FreeBSD
|
|
||||||
else
|
|
||||||
ifeq ($(shell uname -o),Msys)
|
|
||||||
PLATFORM=mingw
|
|
||||||
SOLIBDIR = $(BINDIR)
|
|
||||||
DIFFOPTS = -b
|
|
||||||
else
|
|
||||||
ifeq ($(shell uname -o),Cygwin)
|
|
||||||
PLATFORM=cygwin
|
|
||||||
SOLIBDIR = $(BINDIR)
|
|
||||||
DIFFOPTS = -b
|
|
||||||
else
|
|
||||||
ifeq ($(shell uname -o),GNU/Linux)
|
|
||||||
PLATFORM=linux
|
|
||||||
else
|
|
||||||
PLATFORM=unix
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),macosx)
|
|
||||||
SO = .dylib
|
|
||||||
EXE =
|
|
||||||
CLIBFLAGS = -dynamiclib
|
|
||||||
STATICFLAGS = -static-libgcc -DSEXP_USE_DL=0
|
|
||||||
else
|
|
||||||
ifeq ($(PLATFORM),mingw)
|
|
||||||
SO = .dll
|
|
||||||
EXE = .exe
|
|
||||||
CC = gcc
|
|
||||||
CLIBFLAGS = -shared
|
|
||||||
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0 -DBUILDING_DLL
|
|
||||||
LDFLAGS += -Wl,--out-implib,libchibi-scheme$(SO).a
|
|
||||||
STATICFLAGS = -DSEXP_USE_DL=0
|
|
||||||
LIBDL =
|
|
||||||
else
|
|
||||||
ifeq ($(PLATFORM),cygwin)
|
|
||||||
SO = .dll
|
|
||||||
EXE = .exe
|
|
||||||
CC = gcc
|
|
||||||
CLIBFLAGS = -shared
|
|
||||||
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0
|
|
||||||
LDFLAGS += -Wl,--out-implib,libchibi-scheme$(SO).a
|
|
||||||
else
|
|
||||||
SO = .so
|
|
||||||
EXE =
|
|
||||||
CLIBFLAGS = -fPIC -shared
|
|
||||||
STATICFLAGS = -static -DSEXP_USE_DL=0
|
|
||||||
ifeq ($(PLATFORM),FreeBSD)
|
|
||||||
LIBDL=
|
|
||||||
RLDFLAGS=-Wl,-R$(DESTDIR)$(LIBDIR)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),unix)
|
|
||||||
#RLDFLAGS=-rpath $(LIBDIR)
|
|
||||||
RLDFLAGS=-Wl,-R$(LIBDIR)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_BOEHM),1)
|
|
||||||
SEXP_USE_BOEHM = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(SEXP_USE_BOEHM),1)
|
ifeq ($(SEXP_USE_BOEHM),1)
|
||||||
GCLDFLAGS := -lgc
|
GCLDFLAGS := -lgc
|
||||||
|
@ -130,28 +39,30 @@ endif
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
all: chibi-scheme$(EXE) libs lib/chibi/ast$(SO)
|
CHIBI_COMPILED_LIBS = lib/chibi/filesystem$(SO) lib/chibi/process$(SO) \
|
||||||
|
|
||||||
CHIBI ?= LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)" ./chibi-scheme$(EXE)
|
|
||||||
|
|
||||||
CHIBI_COMPILED_LIBS := lib/chibi/filesystem$(SO) lib/chibi/process$(SO) \
|
|
||||||
lib/chibi/time$(SO) lib/chibi/system$(SO) lib/chibi/stty$(SO) \
|
lib/chibi/time$(SO) lib/chibi/system$(SO) lib/chibi/stty$(SO) \
|
||||||
lib/chibi/weak$(SO) lib/chibi/heap-stats$(SO) lib/chibi/disasm$(SO) \
|
lib/chibi/weak$(SO) lib/chibi/heap-stats$(SO) lib/chibi/disasm$(SO) \
|
||||||
lib/chibi/net$(SO)
|
lib/chibi/net$(SO)
|
||||||
CHIBI_IO_COMPILED_LIBS := lib/chibi/io/io$(SO)
|
CHIBI_IO_COMPILED_LIBS = lib/chibi/io/io$(SO)
|
||||||
CHIBI_OPT_COMPILED_LIBS := lib/chibi/optimize/rest$(SO) \
|
CHIBI_OPT_COMPILED_LIBS = lib/chibi/optimize/rest$(SO) \
|
||||||
lib/chibi/optimize/profile$(SO)
|
lib/chibi/optimize/profile$(SO)
|
||||||
COMPILED_LIBS := $(CHIBI_COMPILED_LIBS) $(CHIBI_IO_COMPILED_LIBS) \
|
COMPILED_LIBS = $(CHIBI_COMPILED_LIBS) $(CHIBI_IO_COMPILED_LIBS) \
|
||||||
$(CHIBI_OPT_COMPILED_LIBS) lib/srfi/18/threads$(SO) \
|
$(CHIBI_OPT_COMPILED_LIBS) lib/srfi/18/threads$(SO) \
|
||||||
lib/srfi/27/rand$(SO) lib/srfi/33/bit$(SO) lib/srfi/39/param$(SO) \
|
lib/srfi/27/rand$(SO) lib/srfi/33/bit$(SO) lib/srfi/39/param$(SO) \
|
||||||
lib/srfi/69/hash$(SO) lib/srfi/95/qsort$(SO) lib/srfi/98/env$(SO) \
|
lib/srfi/69/hash$(SO) lib/srfi/95/qsort$(SO) lib/srfi/98/env$(SO) \
|
||||||
lib/scheme/time$(SO)
|
lib/scheme/time$(SO)
|
||||||
|
|
||||||
libs: $(COMPILED_LIBS)
|
|
||||||
|
|
||||||
BASE_INCLUDES = include/chibi/sexp.h include/chibi/features.h include/chibi/install.h include/chibi/bignum.h
|
BASE_INCLUDES = include/chibi/sexp.h include/chibi/features.h include/chibi/install.h include/chibi/bignum.h
|
||||||
INCLUDES = $(BASE_INCLUDES) include/chibi/eval.h
|
INCLUDES = $(BASE_INCLUDES) include/chibi/eval.h
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
include Makefile.libs
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
all: chibi-scheme$(EXE) all-libs lib/chibi/ast$(SO)
|
||||||
|
|
||||||
include/chibi/install.h: Makefile
|
include/chibi/install.h: Makefile
|
||||||
echo '#define sexp_so_extension "'$(SO)'"' > $@
|
echo '#define sexp_so_extension "'$(SO)'"' > $@
|
||||||
echo '#define sexp_default_module_path "'$(MODDIR):$(BINMODDIR)'"' >> $@
|
echo '#define sexp_default_module_path "'$(MODDIR):$(BINMODDIR)'"' >> $@
|
||||||
|
@ -189,40 +100,34 @@ chibi-scheme-ulimit$(EXE): main.o eval.o sexp-ulimit.o
|
||||||
clibs.c: $(GENSTATIC) chibi-scheme$(EXE)
|
clibs.c: $(GENSTATIC) chibi-scheme$(EXE)
|
||||||
$(FIND) lib -name \*.sld | $(CHIBI) $(GENSTATIC) > $@
|
$(FIND) lib -name \*.sld | $(CHIBI) $(GENSTATIC) > $@
|
||||||
|
|
||||||
%.c: %.stub $(GENSTUBS) chibi-scheme$(EXE)
|
|
||||||
-$(CHIBI) $(GENSTUBS) $<
|
|
||||||
|
|
||||||
# A special case, this needs to be linked with the LDFLAGS in case
|
# A special case, this needs to be linked with the LDFLAGS in case
|
||||||
# we're using Boehm.
|
# we're using Boehm.
|
||||||
lib/chibi/ast$(SO): lib/chibi/ast.c $(INCLUDES)
|
lib/chibi/ast$(SO): lib/chibi/ast.c $(INCLUDES)
|
||||||
-$(CC) $(CLIBFLAGS) $(XCPPFLAGS) $(XCFLAGS) -o $@ $< $(XLDFLAGS) -L. -lchibi-scheme
|
-$(CC) $(CLIBFLAGS) $(XCPPFLAGS) $(XCFLAGS) -o $@ $< $(XLDFLAGS) -L. -lchibi-scheme
|
||||||
|
|
||||||
lib/%$(SO): lib/%.c $(INCLUDES)
|
doc/lib/chibi/%.html: lib/chibi/%.sld $(CHIBI_DOC_DEPENDENCIES)
|
||||||
-$(CC) $(CLIBFLAGS) $(XCPPFLAGS) $(XCFLAGS) -o $@ $< -L. -lchibi-scheme
|
$(CHIBI_DOC) chibi.$* > $@
|
||||||
|
|
||||||
%.html: %.scrbl tools/chibi-doc chibi-scheme$(EXE)
|
|
||||||
$(CHIBI) tools/chibi-doc $< > $@
|
|
||||||
|
|
||||||
doc/lib/chibi/%.html: lib/chibi/%.sld tools/chibi-doc chibi-scheme$(EXE)
|
|
||||||
$(CHIBI) tools/chibi-doc chibi.$* > $@
|
|
||||||
|
|
||||||
MODULE_DOCS := ast disasm equiv filesystem generic heap-stats io loop \
|
MODULE_DOCS := ast disasm equiv filesystem generic heap-stats io loop \
|
||||||
match mime modules net pathname process repl scribble stty \
|
match mime modules net pathname process repl scribble stty \
|
||||||
system test time trace type-inference uri weak
|
system test time trace type-inference uri weak
|
||||||
|
|
||||||
doc: doc/chibi.html $(MODULE_DOCS:%=doc/lib/chibi/%.html)
|
doc: doc/chibi.html doc-libs
|
||||||
|
|
||||||
clean:
|
HTML_LIBS = $(MODULE_DOCS:%=doc/lib/chibi/%.html)
|
||||||
$(RM) *.o *.i *.s *.8
|
|
||||||
$(RM) tests/basic/*.out tests/basic/*.err
|
%.html: %.scrbl $(CHIBI_DOC_DEPENDENCIES)
|
||||||
|
$(CHIBI_DOC) $< > $@
|
||||||
|
|
||||||
|
clean: clean-libs
|
||||||
|
-$(RM) *.o *.i *.s *.8 tests/basic/*.out tests/basic/*.err
|
||||||
|
|
||||||
cleaner: clean
|
cleaner: clean
|
||||||
$(RM) chibi-scheme$(EXE) chibi-scheme-static$(EXE) chibi-scheme-ulimit$(EXE) libchibi-scheme$(SO) *.a include/chibi/install.h
|
-$(RM) chibi-scheme$(EXE) chibi-scheme-static$(EXE) chibi-scheme-ulimit$(EXE) \
|
||||||
$(FIND) lib -name \*$(SO) -exec $(RM) -r '{}' \;
|
libchibi-scheme$(SO) *.a include/chibi/install.h \
|
||||||
$(FIND) lib -name \*.o -exec $(RM) -r '{}' \;
|
$(shell $(FIND) lib -name \*.o)
|
||||||
|
|
||||||
dist-clean: cleaner
|
dist-clean: dist-clean-libs cleaner
|
||||||
for f in `find lib -name \*.stub`; do $(RM) $${f%.stub}.c; done
|
|
||||||
|
|
||||||
checkdefs:
|
checkdefs:
|
||||||
@for d in $(D); do \
|
@for d in $(D); do \
|
||||||
|
|
78
Makefile.detect
Normal file
78
Makefile.detect
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
# -*- makefile-gmake -*-
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Detect the PLATFORM with uname.
|
||||||
|
|
||||||
|
ifndef PLATFORM
|
||||||
|
ifeq ($(shell uname),Darwin)
|
||||||
|
PLATFORM=macosx
|
||||||
|
else
|
||||||
|
ifeq ($(shell uname),FreeBSD)
|
||||||
|
PLATFORM=FreeBSD
|
||||||
|
else
|
||||||
|
ifeq ($(shell uname -o),Msys)
|
||||||
|
PLATFORM=mingw
|
||||||
|
SOLIBDIR = $(BINDIR)
|
||||||
|
DIFFOPTS = -b
|
||||||
|
else
|
||||||
|
ifeq ($(shell uname -o),Cygwin)
|
||||||
|
PLATFORM=cygwin
|
||||||
|
SOLIBDIR = $(BINDIR)
|
||||||
|
DIFFOPTS = -b
|
||||||
|
else
|
||||||
|
ifeq ($(shell uname -o),GNU/Linux)
|
||||||
|
PLATFORM=linux
|
||||||
|
else
|
||||||
|
PLATFORM=unix
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Set default variables for the platform.
|
||||||
|
|
||||||
|
LIBDL = -ldl
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM),macosx)
|
||||||
|
SO = .dylib
|
||||||
|
EXE =
|
||||||
|
CLIBFLAGS = -dynamiclib
|
||||||
|
STATICFLAGS = -static-libgcc -DSEXP_USE_DL=0
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),mingw)
|
||||||
|
SO = .dll
|
||||||
|
EXE = .exe
|
||||||
|
CC = gcc
|
||||||
|
CLIBFLAGS = -shared
|
||||||
|
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0 -DBUILDING_DLL
|
||||||
|
LDFLAGS += -Wl,--out-implib,libchibi-scheme$(SO).a
|
||||||
|
STATICFLAGS = -DSEXP_USE_DL=0
|
||||||
|
LIBDL =
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),cygwin)
|
||||||
|
SO = .dll
|
||||||
|
EXE = .exe
|
||||||
|
CC = gcc
|
||||||
|
CLIBFLAGS = -shared
|
||||||
|
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0
|
||||||
|
LDFLAGS += -Wl,--out-implib,libchibi-scheme$(SO).a
|
||||||
|
else
|
||||||
|
SO = .so
|
||||||
|
EXE =
|
||||||
|
CLIBFLAGS = -fPIC -shared
|
||||||
|
STATICFLAGS = -static -DSEXP_USE_DL=0
|
||||||
|
ifeq ($(PLATFORM),FreeBSD)
|
||||||
|
LIBDL=
|
||||||
|
RLDFLAGS=-Wl,-R$(DESTDIR)$(LIBDIR)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM),unix)
|
||||||
|
#RLDFLAGS=-rpath $(LIBDIR)
|
||||||
|
RLDFLAGS=-Wl,-R$(LIBDIR)
|
||||||
|
endif
|
91
Makefile.libs
Normal file
91
Makefile.libs
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
# -*- 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
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
|
# install configuration
|
||||||
|
|
||||||
|
CC ?= cc
|
||||||
|
CD ?= cd
|
||||||
|
RM ?= rm -f
|
||||||
|
LS ?= ls
|
||||||
|
INSTALL ?= install
|
||||||
|
MKDIR ?= $(INSTALL) -d
|
||||||
|
RMDIR ?= rmdir
|
||||||
|
TAR ?= tar
|
||||||
|
DIFF ?= diff
|
||||||
|
GREP ?= grep
|
||||||
|
FIND ?= find
|
||||||
|
SYMLINK ?= ln -s
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BINDIR ?= $(PREFIX)/bin
|
||||||
|
LIBDIR ?= $(PREFIX)/lib
|
||||||
|
SOLIBDIR ?= $(PREFIX)/lib
|
||||||
|
INCDIR ?= $(PREFIX)/include/chibi
|
||||||
|
MODDIR ?= $(PREFIX)/share/chibi
|
||||||
|
BINMODDIR ?= $(PREFIX)/lib/chibi
|
||||||
|
MANDIR ?= $(PREFIX)/share/man/man1
|
||||||
|
|
||||||
|
DESTDIR ?=
|
||||||
|
|
||||||
|
CHIBI ?= chibi-scheme$(EXE)
|
||||||
|
CHIBI_FFI ?= chibi-ffi
|
||||||
|
CHIBI_DOC ?= chibi-doc
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# 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/%$(SO): lib/%.c $(INCLUDES)
|
||||||
|
$(CC) $(CLIBFLAGS) $(XCPPFLAGS) $(XCFLAGS) -o $@ $< -L. -lchibi-scheme
|
||||||
|
|
||||||
|
doc-libs: $(HTML_LIBS)
|
||||||
|
|
||||||
|
doc/lib/%.html: lib/%.sld
|
||||||
|
$(MKDIR) $(dir $@)
|
||||||
|
$(CHIBI_DOC) $(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
|
108
README.libs
Normal file
108
README.libs
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
Using the Makefile.libs File To Build and Install Libraries
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
The Makefile.libs file distributed with the Chibi Scheme sources
|
||||||
|
can facilitate building and installing Chibi Scheme libraries written
|
||||||
|
in C or Scheme. To use it, follow these instructions:
|
||||||
|
|
||||||
|
1. Copy the Makefile.libs file from the Chibi Scheme source
|
||||||
|
directory to the library source top-level directory.
|
||||||
|
|
||||||
|
2. Place the library source in the subdirectory "lib" of the library
|
||||||
|
source top-level directory. For example,
|
||||||
|
|
||||||
|
lib/foo/bar.c
|
||||||
|
lib/foo/bar.h
|
||||||
|
lib/foo/bar.sld
|
||||||
|
lib/foo/bar.scm
|
||||||
|
|
||||||
|
3. In the Makefile in the library source top-level directory, define
|
||||||
|
the following targets:
|
||||||
|
|
||||||
|
all
|
||||||
|
doc
|
||||||
|
install
|
||||||
|
uninstall
|
||||||
|
clean
|
||||||
|
dist-clean
|
||||||
|
|
||||||
|
These should depend on the corresponding "-libs" target, but
|
||||||
|
can include additional commands. For example:
|
||||||
|
|
||||||
|
all: all-libs
|
||||||
|
install: install-libs
|
||||||
|
cp -r doc $(PREFIX)/share/chibi/
|
||||||
|
uninstall: uninstall-libs
|
||||||
|
doc: doc-libs
|
||||||
|
clean: clean-libs
|
||||||
|
dist-clean: dist-clean-libs
|
||||||
|
|
||||||
|
The all target should be the first target in the Makefile.
|
||||||
|
|
||||||
|
The all-libs target makes the shared libraries in the library.
|
||||||
|
The doc-libs target generates HTML files for the library. The
|
||||||
|
install-libs and uninstall-libs targets install and uninstall
|
||||||
|
the library under the prefix. The clean-libs target removes the
|
||||||
|
shared libraries and generated HTML files. The dist-clean-libs
|
||||||
|
removes any .c files generated from .stub files and also performs
|
||||||
|
a clean-libs.
|
||||||
|
|
||||||
|
4. In the Makefile in the library source top-level directory, define
|
||||||
|
the following variables:
|
||||||
|
|
||||||
|
COMPILED_LIBS: Any shared libraries that should be built and
|
||||||
|
installed. The shared library is build from the corresponding
|
||||||
|
.c or .stub file. The $(SO) variable should be used for the
|
||||||
|
shared-library suffix; in order for this to work COMPILED_LIBS
|
||||||
|
should be defined as a recursively-expanded variable (with
|
||||||
|
=) rather than a simply-expanded variable (with :=).
|
||||||
|
|
||||||
|
INCLUDES: Any other files on which the shared libraries depend.
|
||||||
|
|
||||||
|
SCM_LIBS: Any Scheme source files that should be installed.
|
||||||
|
|
||||||
|
HTML_LIBS: Any HTML files that should be generated. The HTML
|
||||||
|
files are generated from the corresponding .sld files using
|
||||||
|
chibi-doc.
|
||||||
|
|
||||||
|
For example,
|
||||||
|
|
||||||
|
COMPILED_LIBS = lib/foo/bar$(SO)
|
||||||
|
INCLUDES = lib/foo/bar.h
|
||||||
|
SCM_LIBS = lib/foo/bar.sld lib/foo/bar.scm
|
||||||
|
HTML_LIBS = doc/lib/foo/bar.html
|
||||||
|
|
||||||
|
5. Add additional flags as necessary to XCPPFLAGS and XCFLAGS.
|
||||||
|
These flags are passed to the compiler and linker when they
|
||||||
|
generate the shared library. These should probably include at
|
||||||
|
least:
|
||||||
|
|
||||||
|
XCPPFLAGS += -I$(PREFIX)/include
|
||||||
|
XCFLAGS += -L$(PREFIX)/lib
|
||||||
|
|
||||||
|
These additions will ensure that the compiler and linker can
|
||||||
|
find the Chibi Scheme include and library files, even if they
|
||||||
|
are installed under a non-standard prefix.
|
||||||
|
|
||||||
|
6. Include the common Makefile using:
|
||||||
|
|
||||||
|
include Makefile.libs
|
||||||
|
|
||||||
|
A complete example is:
|
||||||
|
|
||||||
|
all: all-libs
|
||||||
|
install: install-libs
|
||||||
|
uninstall: uninstall-libs
|
||||||
|
doc: doc-libs
|
||||||
|
clean: clean-libs
|
||||||
|
dist-clean: dist-clean-libs
|
||||||
|
|
||||||
|
COMPILED_LIBS = lib/foo/bar$(SO)
|
||||||
|
INCLUDES = lib/foo/bar.h
|
||||||
|
SCM_LIBS = lib/foo/bar.sld lib/foo/bar.scm
|
||||||
|
HTML_LIBS = doc/lib/foo/bar.html
|
||||||
|
|
||||||
|
XCPPFLAGS += -I$(PREFIX)/include
|
||||||
|
XCFLAGS += -L$(PREFIX)/lib
|
||||||
|
|
||||||
|
include Makefile.libs
|
Loading…
Add table
Reference in a new issue