diff options
author | Paul Smith <psmith@gnu.org> | 2012-01-15 22:41:53 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2012-01-15 22:41:53 +0000 |
commit | c992c4d80f51540699f33fed067caf6b7c38df79 (patch) | |
tree | 2e8bee26fd19820b85422752724e87639d1b0c77 | |
parent | 3057357c0a5c2507eef2b61eef9ebfb569b30230 (diff) | |
download | gunmake-c992c4d80f51540699f33fed067caf6b7c38df79.tar.gz |
Add GNU Guile as an optional embedded scripting language for make.
On configure-enabled systems, configure will detect Guile installed
(using pkg-config, which is how GNU Guile is distributed) and enable
it if so.
On all non-configure-enabled systems, currently, the default is for
Guile support to be disabled.
-rw-r--r-- | .cvsignore | 2 | ||||
-rw-r--r-- | AUTHORS | 4 | ||||
-rw-r--r-- | ChangeLog | 36 | ||||
-rw-r--r-- | Makefile.DOS.template | 2 | ||||
-rw-r--r-- | Makefile.am | 26 | ||||
-rw-r--r-- | Makefile.ami | 22 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | NMakefile.template | 5 | ||||
-rw-r--r-- | SMakefile.template | 17 | ||||
-rw-r--r-- | build_w32.bat | 9 | ||||
-rw-r--r-- | config.ami.template | 3 | ||||
-rw-r--r-- | config.h-vms.template | 6 | ||||
-rw-r--r-- | config.h.W32.template | 3 | ||||
-rw-r--r-- | config/Makefile.am | 37 | ||||
-rw-r--r-- | configure.in | 427 | ||||
-rw-r--r-- | doc/make.texi | 456 | ||||
-rw-r--r-- | dosbuild.bat | 2 | ||||
-rw-r--r-- | function.c | 18 | ||||
-rw-r--r-- | gmk-default.scm | 57 | ||||
-rw-r--r-- | guile.c | 104 | ||||
-rw-r--r-- | main.c | 11 | ||||
-rw-r--r-- | make.h | 5 | ||||
-rw-r--r-- | make_msvc_net2003.vcproj | 8 | ||||
-rw-r--r-- | makefile.vms | 9 | ||||
-rw-r--r-- | po/ChangeLog | 4 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | tests/scripts/functions/guile | 81 |
27 files changed, 988 insertions, 372 deletions
@@ -22,6 +22,8 @@ config.ami configh.dos config.h.W32 config.h-vms loadavg loadavg.c make +gmk-default.h + .deps .dep_segment ID TAGS _* @@ -47,7 +47,9 @@ Other contributors: Janet Carson <janet_carson@tivoli.com> Howard Chu <hyc@highlandsun.com> + Ludovic Courtès <ludo@gnu.org> Paul Eggert <eggert@twinsun.com> + Ramon Garcia Fernandez <ramon.garcia.f@gmail.com> Klaus Heinz <kamar@ease.rhein-main.de> Michael Joosten Jim Kelton <jim_kelton@tivoli.com> @@ -55,12 +57,12 @@ Other contributors: Tim Magill <tim.magill@telops.gte.com> Markus Mauhart <qwe123@chello.at> Greg McGary <greg@mcgary.org> + Thien-Thi Nguyen <ttn@gnuvola.org> Thomas Riedl <thomas.riedl@siemens.com> Han-Wen Nienhuys <hanwen@cs.uu.nl> Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> Carl Staelin (Princeton University) Ian Stewartson (Data Logic Limited) - Ramon Garcia Fernandez <ramon.garcia.f@gmail.com> David A. Wheeler <dwheeler@dwheeler.com> With suggestions/comments/bug reports from a cast of ... well ... @@ -1,10 +1,44 @@ +2012-01-12 Paul Smith <psmith@gnu.org> + + Support GNU Guile as an embedded extension language for GNU make. + + * NEWS: Note the new Guile capability. + * Makefile.am (EXTRA_DIST, make_SOURCES): Add new guile source files. + (AM_CFLAGS): Add Guile compiler flags. + (guile): Add a rule for converting default SCM into a C header. + * configure.in: Add support for --with-guile. + Also, convert the entire file to properly escaped autoconf m4, and + utilize newer features such as AS_IF() and AS_CASE(). + * doc/make.texi (Guile Function): Document the GNU guile integration. + * make.h (guile_eval_string, guile_boot): Prototypes for Guile. + * main.c (main): Run guile_boot() to handle main(). + (real_main): All the previous content of main() is here. + (real_main): Add "guile" to the .FEATURES variable. + * function.c (func_guile): Call Guile. + * guile.c: New file implementing GNU make integration with GNU Guile. + * gmk-default.scm: The integration of GNU make with Guile uses + Guile itself for much of the parsing and conversion of return + types, etc. This implementation is embedded into GNU make. + * config.h-vms.template: Disable Guile support. + * config.h.W32.template: Ditto. + * configh.dos.template: Ditto. + * config.ami.template: Ditto. + * makefile.vms: Add new Guile files. + * Makefile.DOS.template: Ditto. + * Makefile.ami: Ditto. + * NMakefile.template: Ditto. + * SMakefile.template: Ditto. + * build_w32.bat: Ditto. + * dosbuild.bat: Ditto. + * make_msvc_net2001.vcproj: Ditto. + 2011-11-15 Paul Smith <psmith@gnu.org> * main.c (main): Use %ld when printing DWORD values. * job.c (new_job): Ditto. * w32/include/sub_proc.h: Use const. * w32/subproc/sub_proc.c (open_jobserver_semaphore): Use const. - Fixes Savannah bug #34830. Patches suggested by Ozkan Sezer. + Fixes Savannah bug #34830. Changes suggested by Ozkan Sezer. * configure.in (MAKE_JOBSERVER): Enable jobserver on W32 systems. * config.h.W32.template (MAKE_JOBSERVER): Ditto. diff --git a/Makefile.DOS.template b/Makefile.DOS.template index a42e588..83cd698 100644 --- a/Makefile.DOS.template +++ b/Makefile.DOS.template @@ -89,7 +89,7 @@ INCLUDES = -I$(srcdir)/glob -DLIBDIR=\"$(prefix)$(libdir)\" -DINCLUDEDIR=\"$(pre BUILT_SOURCES = README build.sh-in -EXTRA_DIST = $(BUILT_SOURCES) $(man_MANS) README.customs remote-cstms.c make-stds.texi texinfo.tex SCOPTIONS SMakefile Makefile.ami README.Amiga config.ami amiga.c amiga.h NMakefile README.DOS configh.dos configure.bat makefile.com README.W32 build_w32.bat config.h-W32 subproc.bat make.lnk config.h-vms makefile.vms readme.vms vmsdir.h vmsfunctions.c vmsify.c +EXTRA_DIST = $(BUILT_SOURCES) $(man_MANS) README.customs remote-cstms.c make-stds.texi texinfo.tex SCOPTIONS SMakefile Makefile.ami README.Amiga config.ami amiga.c amiga.h NMakefile README.DOS configh.dos configure.bat makefile.com README.W32 build_w32.bat config.h-W32 subproc.bat make.lnk config.h-vms makefile.vms readme.vms vmsdir.h vmsfunctions.c vmsify.c gmk-default.scm gmk-default.h SUBDIRS = glob doc mkinstalldirs = ${exec_prefix}/bin/gmkdir -p diff --git a/Makefile.am b/Makefile.am index c747ada..d5e7a82 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,18 +39,23 @@ else remote = remote-stub.c endif - make_SOURCES = ar.c arscan.c commands.c default.c dir.c expand.c file.c \ function.c getopt.c getopt1.c implicit.c job.c main.c \ - misc.c read.c remake.c $(remote) rule.c signame.c \ - strcache.c variable.c version.c vpath.c hash.c + misc.c read.c remake.c rule.c signame.c \ + strcache.c variable.c version.c vpath.c hash.c \ + $(remote) + +if HAVE_GUILE + make_SOURCES += guile.c +endif EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \ debug.h getopt.h gettext.h hash.h -make_LDADD = @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@ +make_LDADD = @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@ \ + $(GUILE_LIBS) # Only process if target is MS-Windows if WINDOWSENV make_LDADD += $(W32LIB) @@ -61,6 +66,7 @@ man_MANS = make.1 DEFS = -DLOCALEDIR=\"$(localedir)\" -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" @DEFS@ AM_CPPFLAGS = $(GLOBINC) +AM_CFLAGS = $(GUILE_CFLAGS) # Only process if target is MS-Windows if WINDOWSENV AM_CPPFLAGS += $(W32INC) @@ -77,7 +83,8 @@ EXTRA_DIST = README build.sh.in $(man_MANS) \ README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat \ make_msvc_net2003.sln make_msvc_net2003.vcproj \ readme.vms makefile.vms makefile.com config.h-vms \ - vmsdir.h vmsfunctions.c vmsify.c + vmsdir.h vmsfunctions.c vmsify.c \ + gmk-default.scm gmk-default.h # This is built during configure, but behind configure's back @@ -123,6 +130,15 @@ install-exec-local: fi; \ else true; fi +# --------------- Generate the Guile default module content + +guile.$(OBJEXT): gmk-default.h +gmk-default.h: $(srcdir)/gmk-default.scm + (echo 'static const char *const GUILE_module_defn = " '\\ \ + && sed -e 's/;.*//' -e '/^[ \t]*$$/d' -e 's/"/\\"/g' -e 's/$$/ \\/' \ + $(srcdir)/gmk-default.scm \ + && echo '";') > $@ + # --------------- Local DIST Section # Install the w32 and tests subdirectories diff --git a/Makefile.ami b/Makefile.ami index 8cc67df..29f092d 100644 --- a/Makefile.ami +++ b/Makefile.ami @@ -118,20 +118,23 @@ TEXI2DVI = texi2dvi ETAGS = etags -w CTAGS = ctags -w -objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o \ - rule.o implicit.o default.o variable.o expand.o function.o \ - vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o \ - remote-$(REMOTE).o $(GETOPT) $(ALLOCA) $(extras) +#guile = guile.o + +objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o \ + rule.o implicit.o default.o variable.o expand.o function.o \ + vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o \ + remote-$(REMOTE).o $(GETOPT) $(ALLOCA) $(extras) $(guile) + srcs = $(srcdir)commands.c $(srcdir)job.c $(srcdir)dir.c \ $(srcdir)file.c $(srcdir)getloadavg.c $(srcdir)misc.c \ $(srcdir)main.c $(srcdir)read.c $(srcdir)remake.c \ $(srcdir)rule.c $(srcdir)implicit.c $(srcdir)default.c \ $(srcdir)variable.c $(srcdir)expand.c $(srcdir)function.c \ $(srcdir)vpath.c $(srcdir)version.c $(srcdir)hash.c \ - $(srcdir)remote-$(REMOTE).c \ - $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c \ - $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC) \ - $(srcdir)commands.h $(srcdir)dep.h $(srcdir)filedep.h \ + $(srcdir)guile.c $(srcdir)remote-$(REMOTE).c \ + $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c \ + $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC) \ + $(srcdir)commands.h $(srcdir)dep.h $(srcdir)filedep.h \ $(srcdir)job.h $(srcdir)make.h $(srcdir)rule.h \ $(srcdir)variable.h $(ALLOCA_SRC) $(srcdir)config.h.in @@ -179,8 +182,6 @@ glob/libglob.a: FORCE config.h cd glob; $(MAKE) libglob.a FORCE: -tagsrcs = $(srcs) $(srcdir)remote-*.c - .PHONY: install installdirs install: installdirs \ $(bindir)$(binprefix)make $(infodir)make.info \ @@ -281,6 +282,7 @@ file.o: file.c make.h dep.h filedef.h job.h commands.h variable.h misc.o: misc.c make.h dep.h main.o: main.c make.h dep.h filedef.h variable.h job.h commands.h \ getopt.h +guile.o: guile.c make.h dep.h debug.h variable.h gmk-default.h read.o: read.c make.h dep.h filedef.h job.h commands.h variable.h \ glob/glob.h remake.o: remake.c make.h filedef.h job.h commands.h dep.h @@ -32,6 +32,11 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=101&set interpreted as shell assignment. Change your assignment to add whitespace between the "!" and "=": "variable! = value" +* New Feature: GNU Guile integration + This version of GNU make can be compiled with GNU Guile integration. + GNU Guile serves as an embedded extension language for make. + See the "Guile Function" section in the GNU Make manual for details. + * New command line option: --trace enables tracing of targets. When enabled the recipe to be invoked is printed even if it would otherwise be suppressed by .SILENT or a "@" prefix character. Also before each recipe is run the diff --git a/NMakefile.template b/NMakefile.template index 35fafbe..57a1d82 100644 --- a/NMakefile.template +++ b/NMakefile.template @@ -73,6 +73,8 @@ $(OUTDIR): LIBS = kernel32.lib user32.lib advapi32.lib +#guile = $(OUTDIR)/guile.obj + OBJS = \ $(OUTDIR)/ar.obj \ $(OUTDIR)/arscan.obj \ @@ -102,7 +104,8 @@ OBJS = \ $(OUTDIR)/glob.obj \ $(OUTDIR)/fnmatch.obj \ $(OUTDIR)/dirent.obj \ - $(OUTDIR)/pathstuff.obj + $(OUTDIR)/pathstuff.obj \ + $(guile) $(OUTDIR)/make.exe: $(OUTDIR) $(OBJS) $(LINK) @<< diff --git a/SMakefile.template b/SMakefile.template index 7e9229e..5c69908 100644 --- a/SMakefile.template +++ b/SMakefile.template @@ -124,19 +124,22 @@ TEXI2DVI = texi2dvi ETAGS = etags -w CTAGS = ctags -w -objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o \ - rule.o implicit.o default.o variable.o expand.o function.o \ - vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o \ - remote-$(REMOTE).o $(GLOB) $(GETOPT) $(ALLOCA) $(extras) +#guile = guile.o + +objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o \ + rule.o implicit.o default.o variable.o expand.o function.o \ + vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o \ + remote-$(REMOTE).o $(GLOB) $(GETOPT) $(ALLOCA) $(extras) $(guile) + srcs = $(srcdir)commands.c $(srcdir)job.c $(srcdir)dir.c \ $(srcdir)file.c $(srcdir)getloadavg.c $(srcdir)misc.c \ $(srcdir)main.c $(srcdir)read.c $(srcdir)remake.c \ $(srcdir)rule.c $(srcdir)implicit.c $(srcdir)default.c \ $(srcdir)variable.c $(srcdir)expand.c $(srcdir)function.c \ $(srcdir)vpath.c $(srcdir)version.c $(srcdir)hash.c \ - $(srcdir)remote-$(REMOTE).c \ - $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c \ - $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC) \ + $(srcdir)guile.c $(srcdir)remote-$(REMOTE).c \ + $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c \ + $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC) \ $(srcdir)commands.h $(srcdir)dep.h $(srcdir)file.h \ $(srcdir)job.h $(srcdir)make.h $(srcdir)rule.h \ $(srcdir)variable.h $(ALLOCA_SRC) $(srcdir)config.h.in diff --git a/build_w32.bat b/build_w32.bat index de758b0..4ace531 100644 --- a/build_w32.bat +++ b/build_w32.bat @@ -92,6 +92,8 @@ cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D echo WinDebug\fnmatch.obj >>link.dbg
cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c .\w32\pathstuff.c
echo WinDebug\pathstuff.obj >>link.dbg
+rem cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c guile.c
+rem echo WinDebug\guile.obj >>link.dbg
echo off
echo "Linking WinDebug/%make%.exe"
rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /OUT:.\WinDebug/%make%.exe .\WinDebug/variable.obj .\WinDebug/rule.obj .\WinDebug/remote-stub.obj .\WinDebug/commands.obj .\WinDebug/file.obj .\WinDebug/getloadavg.obj .\WinDebug/default.obj .\WinDebug/signame.obj .\WinDebug/expand.obj .\WinDebug/dir.obj .\WinDebug/main.obj .\WinDebug/getopt1.obj .\WinDebug/job.obj .\WinDebug/read.obj .\WinDebug/version.obj .\WinDebug/getopt.obj .\WinDebug/arscan.obj .\WinDebug/remake.obj .\WinDebug/hash.obj .\WinDebug/strcache.obj .\WinDebug/misc.obj .\WinDebug/ar.obj .\WinDebug/function.obj .\WinDebug/vpath.obj .\WinDebug/implicit.obj .\WinDebug/dirent.obj .\WinDebug/glob.obj .\WinDebug/fnmatch.obj .\WinDebug/pathstuff.obj
@@ -159,6 +161,8 @@ cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WIND echo WinRel\fnmatch.obj >>link.rel
cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c .\w32\pathstuff.c
echo WinRel\pathstuff.obj >>link.rel
+rem cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c guile.c
+rem echo WinRel\guile.obj >>link.rel
echo off
echo "Linking WinRel/%make%.exe"
rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /OUT:.\WinRel/%make%.exe .\WinRel/variable.obj .\WinRel/rule.obj .\WinRel/remote-stub.obj .\WinRel/commands.obj .\WinRel/file.obj .\WinRel/getloadavg.obj .\WinRel/default.obj .\WinRel/signame.obj .\WinRel/expand.obj .\WinRel/dir.obj .\WinRel/main.obj .\WinRel/getopt1.obj .\WinRel/job.obj .\WinRel/read.obj .\WinRel/version.obj .\WinRel/getopt.obj .\WinRel/arscan.obj .\WinRel/remake.obj .\WinRel/misc.obj .\WinRel/hash.obj .\WinRel/strcache.obj .\WinRel/ar.obj .\WinRel/function.obj .\WinRel/vpath.obj .\WinRel/implicit.obj .\WinRel/dirent.obj .\WinRel/glob.obj .\WinRel/fnmatch.obj .\WinRel/pathstuff.obj
@@ -198,6 +202,9 @@ gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 - gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/glob.c -o glob.o
gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/fnmatch.c -o fnmatch.o
gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./w32/pathstuff.c -o pathstuff.o
-gcc -mthreads -gdwarf-2 -g3 -o gnumake.exe variable.o rule.o remote-stub.o commands.o file.o getloadavg.o default.o signame.o expand.o dir.o main.o getopt1.o job.o read.o version.o getopt.o arscan.o remake.o misc.o hash.o strcache.o ar.o function.o vpath.o implicit.o glob.o fnmatch.o pathstuff.o w32_misc.o sub_proc.o w32err.o -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
+rem gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c guile.c
+rem set guile=guile.o
+set guile=
+gcc -mthreads -gdwarf-2 -g3 -o gnumake.exe variable.o rule.o remote-stub.o commands.o file.o getloadavg.o default.o signame.o expand.o dir.o main.o getopt1.o %guile% job.o read.o version.o getopt.o arscan.o remake.o misc.o hash.o strcache.o ar.o function.o vpath.o implicit.o glob.o fnmatch.o pathstuff.o w32_misc.o sub_proc.o w32err.o -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
:BuildEnd
echo on
diff --git a/config.ami.template b/config.ami.template index 3a5a29e..db7c64e 100644 --- a/config.ami.template +++ b/config.ami.template @@ -66,6 +66,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ /* Define if you have the getmntent function. */ /* #undef HAVE_GETMNTENT */ +/* Embed GNU Guile support */ +/* #undef HAVE_GUILE */ + /* Define if the `long double' type works. */ /* #undef HAVE_LONG_DOUBLE */ diff --git a/config.h-vms.template b/config.h-vms.template index cf9d5e4..d194a57 100644 --- a/config.h-vms.template +++ b/config.h-vms.template @@ -35,6 +35,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ /* Define as 1 if you have gettext and don't want to use GNU gettext. */ /* #undef HAVE_GETTEXT */ +/* Embed GNU Guile support */ +/* #undef HAVE_GUILE */ + /* Define to 1 if your locale.h file contains LC_MESSAGES. */ /* #undef HAVE_LC_MESSAGES */ @@ -260,9 +263,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the gethostname function. */ /* #undef HAVE_GETHOSTNAME */ -/* Define to 1 if you have the getloadavg function. */ -/* #undef HAVE_GETLOADAVG */ - /* Define to 1 if you have the memmove function. */ #define HAVE_MEMMOVE 1 diff --git a/config.h.W32.template b/config.h.W32.template index 03a4316..dd5be8a 100644 --- a/config.h.W32.template +++ b/config.h.W32.template @@ -75,6 +75,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ /* Define if you have the clock_gettime function. */ /* #undef HAVE_CLOCK_GETTIME */ +/* Embed GNU Guile support */ +/* #undef HAVE_GUILE */ + /* Define if the GNU dcgettext() function is already present or preinstalled. */ /* #undef HAVE_DCGETTEXT */ diff --git a/config/Makefile.am b/config/Makefile.am index 203a5ee..766dcb2 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -16,9 +16,34 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see <http://www.gnu.org/licenses/>. -EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 nls.m4 \ - intdiv0.m4 inttypes-pri.m4 inttypes.m4 inttypes_h.m4 \ - isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 \ - progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 longlong.m4 \ - dospaths.m4 po.m4 signed.m4 longdouble.m4 wchar_t.m4 \ - wint_t.m4 intmax.m4 printf-posix.m4 xsize.m4 size_max.m4 +EXTRA_DIST = \ + codeset.m4 \ + dospaths.m4 \ + gettext.m4 \ + glibc21.m4 \ + iconv.m4 \ + intdiv0.m4 \ + intmax.m4 \ + inttypes-pri.m4 \ + inttypes.m4 \ + inttypes_h.m4 \ + isc-posix.m4 \ + isc-posix.m4 \ + lcmessage.m4 \ + lib-ld.m4 \ + lib-link.m4 \ + lib-prefix.m4 \ + longdouble.m4 \ + longlong.m4 \ + nls.m4 \ + po.m4 \ + printf-posix.m4 \ + progtest.m4 \ + signed.m4 \ + size_max.m4 \ + stdint_h.m4 \ + uintmax_t.m4 \ + ulonglong.m4 \ + wchar_t.m4 \ + wint_t.m4 \ + xsize.m4 diff --git a/configure.in b/configure.in index 5bcbc4b..214193d 100644 --- a/configure.in +++ b/configure.in @@ -19,13 +19,13 @@ AC_INIT([GNU make],[3.82.90],[bug-make@gnu.org]) -AC_PREREQ(2.59) -AC_REVISION([[$Id$]]) +AC_PREREQ([2.59]) +AC_REVISION([$Id$]) # Autoconf setup -AC_CONFIG_AUX_DIR(config) -AC_CONFIG_SRCDIR(vpath.c) -AC_CONFIG_HEADERS(config.h) +AC_CONFIG_AUX_DIR([config]) +AC_CONFIG_SRCDIR([vpath.c]) +AC_CONFIG_HEADERS([config.h]) # Automake setup AM_INIT_AUTOMAKE([1.9]) @@ -35,9 +35,9 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_RANLIB AC_PROG_CPP -AC_CHECK_PROG(AR, ar, ar, ar) +AC_CHECK_PROG([AR], [ar], [ar], [ar]) # Perl is needed for the test suite (only) -AC_CHECK_PROG(PERL, perl, perl, perl) +AC_CHECK_PROG([PERL], [perl], [perl], [perl]) # Specialized system macros AC_CANONICAL_HOST @@ -47,7 +47,7 @@ AC_MINIX # Enable gettext, in "external" mode. -AM_GNU_GETTEXT_VERSION(0.14.1) +AM_GNU_GETTEXT_VERSION([0.14.1]) AM_GNU_GETTEXT([external]) # This test must come as early as possible after the compiler configuration @@ -56,25 +56,25 @@ AM_GNU_GETTEXT([external]) AC_SYS_LARGEFILE # Checks for libraries. -AC_SEARCH_LIBS(getpwnam, [sun]) +AC_SEARCH_LIBS([getpwnam], [sun]) # Checks for header files. AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_STAT AC_HEADER_TIME -AC_CHECK_HEADERS(stdlib.h locale.h unistd.h limits.h fcntl.h string.h \ - memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h) +AC_CHECK_HEADERS([stdlib.h locale.h unistd.h limits.h fcntl.h string.h \ + memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h]) # Set a flag if we have an ANSI C compiler -if test "$ac_cv_prog_cc_stdc" != no; then - AC_DEFINE(HAVE_ANSI_COMPILER, 1, - [Define to 1 if your compiler conforms to the ANSI C standard.]) -fi +AS_IF([test "$ac_cv_prog_cc_stdc" != no], +[ AC_DEFINE([HAVE_ANSI_COMPILER], [1], + [Define to 1 if your compiler conforms to the ANSI C standard.]) +]) # Determine what kind of variadic function calls we support -AC_CHECK_HEADERS(stdarg.h varargs.h, break) +AC_CHECK_HEADERS([stdarg.h varargs.h], [break]) AM_PROG_CC_C_O AC_C_CONST @@ -84,45 +84,40 @@ AC_TYPE_PID_T # Find some definition for uintmax_t -AC_CHECK_TYPE(uintmax_t,,[ - uintmax_t="unsigned long" - AC_CHECK_TYPE(unsigned long long,[uintmax_t="unsigned long long"]) - AC_DEFINE_UNQUOTED(uintmax_t,$uintmax_t, - [Define uintmax_t if not defined in <stdint.h> or <inttypes.h>.])]) +AC_CHECK_TYPE([uintmax_t],[], +[ uintmax_t="unsigned long" + AC_CHECK_TYPE([unsigned long long],[uintmax_t="unsigned long long"]) + AC_DEFINE_UNQUOTED([uintmax_t], [$uintmax_t], + [Define uintmax_t if not defined in <stdint.h> or <inttypes.h>.]) +]) # Find out whether our struct stat returns nanosecond resolution timestamps. AC_STRUCT_ST_MTIM_NSEC -AC_MSG_CHECKING([whether to use high resolution file timestamps]) -AC_CACHE_VAL(make_cv_file_timestamp_hi_res, [ - make_cv_file_timestamp_hi_res=no - if test "$ac_cv_struct_st_mtim_nsec" != no; then - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -# if HAVE_INTTYPES_H -# include <inttypes.h> -# endif]], +AC_CACHE_CHECK([whether to use high resolution file timestamps], + [make_cv_file_timestamp_hi_res], +[ make_cv_file_timestamp_hi_res=no + AS_IF([test "$ac_cv_struct_st_mtim_nsec" != no], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if HAVE_INTTYPES_H +# include <inttypes.h> +#endif]], [[char a[0x7fffffff < (uintmax_t)-1 >> 30 ? 1 : -1];]])], - [make_cv_file_timestamp_hi_res=yes], - []) - fi]) -AC_MSG_RESULT($make_cv_file_timestamp_hi_res) -if test "$make_cv_file_timestamp_hi_res" = yes; then - val=1 -else - val=0 -fi -AC_DEFINE_UNQUOTED(FILE_TIMESTAMP_HI_RES, $val, + [make_cv_file_timestamp_hi_res=yes]) + ])]) +AS_IF([test "$make_cv_file_timestamp_hi_res" = yes], [val=1], [val=0]) +AC_DEFINE_UNQUOTED([FILE_TIMESTAMP_HI_RES], [$val], [Use high resolution file timestamps if nonzero.]) -if test "$make_cv_file_timestamp_hi_res" = yes; then - # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. +AS_IF([test "$make_cv_file_timestamp_hi_res" = yes], +[ # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. - AC_SEARCH_LIBS(clock_gettime, [rt posix4]) - if test "$ac_cv_search_clock_gettime" != no; then - AC_DEFINE(HAVE_CLOCK_GETTIME, 1, + AC_SEARCH_LIBS([clock_gettime], [rt posix4]) + AS_IF([test "$ac_cv_search_clock_gettime" != no], + [ AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define to 1 if you have the clock_gettime function.]) - fi -fi + ]) +]) # Check for DOS-style pathnames. pds_AC_DOS_PATHS @@ -130,7 +125,7 @@ pds_AC_DOS_PATHS # See if we have a standard version of gettimeofday(). Since actual # implementations can differ, just make sure we have the most common # one. -AC_CACHE_CHECK([for standard gettimeofday], ac_cv_func_gettimeofday, +AC_CACHE_CHECK([for standard gettimeofday], [ac_cv_func_gettimeofday], [ac_cv_func_gettimeofday=no AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/time.h> int main () @@ -142,16 +137,16 @@ AC_CACHE_CHECK([for standard gettimeofday], ac_cv_func_gettimeofday, [ac_cv_func_gettimeofday=yes], [ac_cv_func_gettimeofday=no], [ac_cv_func_gettimeofday="no (cross-compiling)"])]) -if test "$ac_cv_func_gettimeofday" = yes; then - AC_DEFINE(HAVE_GETTIMEOFDAY, 1, +AS_IF([test "$ac_cv_func_gettimeofday" = yes], +[ AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define to 1 if you have a standard gettimeofday function]) -fi +]) -AC_CHECK_FUNCS( strdup strndup mkstemp mktemp fdopen fileno \ +AC_CHECK_FUNCS([strdup strndup mkstemp mktemp fdopen fileno \ dup2 getcwd realpath sigsetmask sigaction \ getgroups seteuid setegid setlinebuf setreuid setregid \ getrlimit setrlimit setvbuf pipe strerror strsignal \ - lstat readlink atexit) + lstat readlink atexit]) # We need to check declarations, not just existence, because on Tru64 this # function is not declared without special flags, which themselves cause @@ -163,7 +158,7 @@ AC_FUNC_SETVBUF_REVERSED # Rumor has it that strcasecmp lives in -lresolv on some odd systems. # It doesn't hurt much to use our own if we can't find it so I don't # make the effort here. -AC_CHECK_FUNCS(strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp) +AC_CHECK_FUNCS([strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp]) # strcoll() is used by the GNU glob library AC_FUNC_STRCOLL @@ -173,23 +168,43 @@ AC_FUNC_FORK([]) AC_FUNC_VPRINTF AC_FUNC_CLOSEDIR_VOID +# See if the user wants to add (or not) GNU Guile support +PKG_PROG_PKG_CONFIG +AC_ARG_WITH([guile], [AS_HELP_STRING([--with-guile], + [Support GNU Guile for embedded scripting])]) + +# For some strange reason, at least on Ubuntu, each version of Guile +# comes with it's own PC file so we have to specify them as individual +# packages. Ugh. +AS_IF([test "x$with_guile" != xno], +[ PKG_CHECK_MODULES([GUILE], [guile-2.0], [have_guile=yes], + [PKG_CHECK_MODULES([GUILE], [guile-1.8], [have_guile=yes], + [PKG_CHECK_MODULES([GUILE], [guile-1.6], [have_guile=yes], + [have_guile=no])])]) +]) + +AS_IF([test "$have_guile" = yes], + [AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])]) + +AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = yes]) + AC_FUNC_GETLOADAVG # AC_FUNC_GETLOADAVG is documented to set the NLIST_STRUCT value, but it # doesn't. So, we will. -if test "$ac_cv_header_nlist_h" = yes; then - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]], +AS_IF([test "$ac_cv_header_nlist_h" = yes], +[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]], [[struct nlist nl; nl.n_name = "string"; return 0;]])], [make_cv_nlist_struct=yes], [make_cv_nlist_struct=no]) - if test "$make_cv_nlist_struct" = yes; then - AC_DEFINE(NLIST_STRUCT, 1, + AS_IF([test "$make_cv_nlist_struct" = yes], + [ AC_DEFINE([NLIST_STRUCT], [1], [Define to 1 if struct nlist.n_name is a pointer rather than an array.]) - fi -fi + ]) +]) AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , , [AC_INCLUDES_DEFAULT @@ -202,11 +217,10 @@ AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , , # Check out the wait reality. -AC_CHECK_HEADERS(sys/wait.h,,,[[#include <sys/types.h>]]) -AC_CHECK_FUNCS(waitpid wait3) -AC_MSG_CHECKING(for union wait) -AC_CACHE_VAL(make_cv_union_wait, [dnl - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> +AC_CHECK_HEADERS([sys/wait.h],[],[],[[#include <sys/types.h>]]) +AC_CHECK_FUNCS([waitpid wait3]) +AC_CACHE_CHECK([for union wait], [make_cv_union_wait], +[ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> #include <sys/wait.h>]], [[union wait status; int pid; pid = wait (&status); #ifdef WEXITSTATUS @@ -225,141 +239,130 @@ AC_CACHE_VAL(make_cv_union_wait, [dnl #endif ]])], [make_cv_union_wait=yes], - [make_cv_union_wait=no])]) -if test "$make_cv_union_wait" = yes; then - AC_DEFINE(HAVE_UNION_WAIT, 1, + [make_cv_union_wait=no]) +]) +AS_IF([test "$make_cv_union_wait" = yes], +[ AC_DEFINE([HAVE_UNION_WAIT], [1], [Define to 1 if you have the \`union wait' type in <sys/wait.h>.]) -fi -AC_MSG_RESULT($make_cv_union_wait) +]) # If we're building on Windows/DOS/OS/2, add some support for DOS drive specs. -if test "$PATH_SEPARATOR" = ';'; then - AC_DEFINE(HAVE_DOS_PATHS, 1, +AS_IF([test "$PATH_SEPARATOR" = ';'], +[ AC_DEFINE([HAVE_DOS_PATHS], [1], [Define to 1 if your system requires backslashes or drive specs in pathnames.]) -fi +]) # See if the user wants to use pmake's "customs" distributed build capability -AC_SUBST(REMOTE) REMOTE=stub +AC_SUBST([REMOTE]) REMOTE=stub use_customs=false -AC_ARG_WITH(customs, - AC_HELP_STRING([--with-customs=DIR], - [enable remote jobs via Customs--see README.customs]), - [case $withval in - n|no) : ;; - *) make_cppflags="$CPPFLAGS" - case $withval in - y|ye|yes) : ;; - *) CPPFLAGS="$CPPFLAGS -I$with_customs/include/customs" - make_ldflags="$LDFLAGS -L$with_customs/lib" ;; - esac - CF_NETLIBS - AC_CHECK_HEADER(customs.h, - [use_customs=true - REMOTE=cstms - LIBS="$LIBS -lcustoms" LDFLAGS="$make_ldflags"], - [with_customs=no - CPPFLAGS="$make_cppflags" make_badcust=yes]) - ;; - esac]) +AC_ARG_WITH([customs], +[ AC_HELP_STRING([--with-customs=DIR], + [enable remote jobs via Customs--see README.customs])], +[ AS_CASE([$withval], [n|no], [:], + [make_cppflags="$CPPFLAGS" + AS_CASE([$withval], + [y|ye|yes], [:], + [CPPFLAGS="$CPPFLAGS -I$with_customs/include/customs" + make_ldflags="$LDFLAGS -L$with_customs/lib"]) + CF_NETLIBS + AC_CHECK_HEADER([customs.h], + [use_customs=true + REMOTE=cstms + LIBS="$LIBS -lcustoms" LDFLAGS="$make_ldflags"], + [with_customs=no + CPPFLAGS="$make_cppflags" make_badcust=yes]) + ]) +]) + # Tell automake about this, so it can include the right .c files. -AM_CONDITIONAL(USE_CUSTOMS, test "$use_customs" = true) +AM_CONDITIONAL([USE_CUSTOMS], [test "$use_customs" = true]) # See if the user asked to handle case insensitive file systems. -AH_TEMPLATE(HAVE_CASE_INSENSITIVE_FS, [Use case insensitive file names]) -AC_ARG_ENABLE(case-insensitive-file-system, +AH_TEMPLATE([HAVE_CASE_INSENSITIVE_FS], [Use case insensitive file names]) +AC_ARG_ENABLE([case-insensitive-file-system], AC_HELP_STRING([--enable-case-insensitive-file-system], [assume file systems are case insensitive]), - [case $enableval in - yes) AC_DEFINE(HAVE_CASE_INSENSITIVE_FS) ;; - esac]) + [AS_IF([test "$enableval" = yes], [AC_DEFINE([HAVE_CASE_INSENSITIVE_FS])])]) # See if we can handle the job server feature, and if the user wants it. -AC_ARG_ENABLE(job-server, +AC_ARG_ENABLE([job-server], AC_HELP_STRING([--disable-job-server], [disallow recursive make communication during -jN]), [make_cv_job_server="$enableval" user_job_server="$enableval"], [make_cv_job_server="yes"]) -has_wait_nohang=yes -case "$ac_cv_func_waitpid/$ac_cv_func_wait3" in - no/no) has_wait_nohang=no ;; -esac +AS_IF([test "$ac_cv_func_waitpid" = no && test "$ac_cv_func_wait3" = no], + [has_wait_nohang=no], + [has_wait_nohang=yes]) -AC_CACHE_CHECK(for SA_RESTART, make_cv_sa_restart, [ +AC_CACHE_CHECK([for SA_RESTART], [make_cv_sa_restart], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[return SA_RESTART;]])], [make_cv_sa_restart=yes], [make_cv_sa_restart=no])]) -if test "$make_cv_sa_restart" != no; then - AC_DEFINE(HAVE_SA_RESTART, 1, +AS_IF([test "$make_cv_sa_restart" != no], +[ AC_DEFINE([HAVE_SA_RESTART], [1], [Define to 1 if <signal.h> defines the SA_RESTART constant.]) -fi +]) # Only allow jobserver on systems that support it -case "/$ac_cv_func_pipe/$ac_cv_func_sigaction/$make_cv_sa_restart/$has_wait_nohang/" in - */no/*) make_cv_job_server=no ;; -esac +AS_CASE([/$ac_cv_func_pipe/$ac_cv_func_sigaction/$make_cv_sa_restart/$has_wait_nohang/], + [*/no/*], [make_cv_job_server=no]) # Also supported on OS2 and MinGW -case "$host_os" in - os2*|mingw*) make_cv_job_server=yes ;; -esac +AS_CASE([$host_os], [os2*|mingw*], [make_cv_job_server=yes]) # If we support it and the user didn't disable it, build with jobserver -case "/$make_cv_job_server/$user_job_server/" in - */no/*) : no jobserver ;; - *) AC_DEFINE(MAKE_JOBSERVER, 1, - [Define to 1 to enable job server support in GNU make.]) ;; -esac +AS_CASE([/$make_cv_job_server/$user_job_server/], + [*/no/*], [: no jobserver], + [AC_DEFINE(MAKE_JOBSERVER, 1, + [Define to 1 to enable job server support in GNU make.]) + ]) # if we have both lstat() and readlink() then we can support symlink # timechecks. -case "$ac_cv_func_lstat/$ac_cv_func_readlink" in - yes/yes) - AC_DEFINE(MAKE_SYMLINKS, 1, - [Define to 1 to enable symbolic link timestamp checking.]);; -esac +AS_IF([test "$ac_cv_func_lstat" = yes && test "$ac_cv_func_readlink" = yes], +[ AC_DEFINE([MAKE_SYMLINKS], [1], + [Define to 1 to enable symbolic link timestamp checking.]) +]) # Find the SCCS commands, so we can include them in our default rules. -AC_CACHE_CHECK(for location of SCCS get command, make_cv_path_sccs_get, [ -if test -f /usr/sccs/get; then - make_cv_path_sccs_get=/usr/sccs/get -else - make_cv_path_sccs_get=get -fi]) -AC_DEFINE_UNQUOTED(SCCS_GET, ["$make_cv_path_sccs_get"], +AC_CACHE_CHECK([for location of SCCS get command], [make_cv_path_sccs_get], [ + AS_IF([test -f /usr/sccs/get], + [make_cv_path_sccs_get=/usr/sccs/get], + [make_cv_path_sccs_get=get]) +]) +AC_DEFINE_UNQUOTED([SCCS_GET], ["$make_cv_path_sccs_get"], [Define to the name of the SCCS 'get' command.]) ac_clean_files="$ac_clean_files s.conftest conftoast" # Remove these later. -if ( /usr/sccs/admin -n s.conftest || admin -n s.conftest ) >/dev/null 2>&1 && - test -f s.conftest; then - # We successfully created an SCCS file. - AC_CACHE_CHECK(if SCCS get command understands -G, make_cv_sys_get_minus_G, [ - if $make_cv_path_sccs_get -Gconftoast s.conftest >/dev/null 2>&1 && - test -f conftoast; then - make_cv_sys_get_minus_G=yes - else - make_cv_sys_get_minus_G=no - fi]) - case "$make_cv_sys_get_minus_G" in - yes) AC_DEFINE(SCCS_GET_MINUS_G, 1, - [Define to 1 if the SCCS 'get' command understands the '-G<file>' option.]);; - esac -fi +AS_IF([(/usr/sccs/admin -n s.conftest || admin -n s.conftest) >/dev/null 2>&1 && + test -f s.conftest], +[ # We successfully created an SCCS file. + AC_CACHE_CHECK([if SCCS get command understands -G], [make_cv_sys_get_minus_G], + [AS_IF([$make_cv_path_sccs_get -Gconftoast s.conftest >/dev/null 2>&1 && + test -f conftoast], + [make_cv_sys_get_minus_G=yes], + [make_cv_sys_get_minus_G=no]) + ]) + AS_IF([test "$make_cv_sys_get_minus_G" = yes], + [AC_DEFINE([SCCS_GET_MINUS_G], [1], + [Define to 1 if the SCCS 'get' command understands the '-G<file>' option.]) + ]) +]) rm -f s.conftest conftoast # Check the system to see if it provides GNU glob. If not, use our # local version. -AC_MSG_CHECKING(if system libc has GNU glob) -AC_CACHE_VAL(make_cv_sys_gnu_glob, [ - AC_EGREP_CPP(gnu glob,[ +AC_CACHE_CHECK([if system libc has GNU glob], [make_cv_sys_gnu_glob], +[ AC_EGREP_CPP([gnu glob],[ #include <features.h> #include <glob.h> #include <fnmatch.h> @@ -370,47 +373,46 @@ AC_CACHE_VAL(make_cv_sys_gnu_glob, [ # if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION gnu glob # endif -#endif - ], [AC_MSG_RESULT(yes) -make_cv_sys_gnu_glob=yes], [AC_MSG_RESULT([no; using local copy]) -make_cv_sys_gnu_glob=no])]) -if test "$make_cv_sys_gnu_glob" = no; then - GLOBINC='-I$(srcdir)/glob' +#endif], + [make_cv_sys_gnu_glob=yes], + [make_cv_sys_gnu_glob=no])]) +AS_IF([test "$make_cv_sys_gnu_glob" = no], +[ GLOBINC='-I$(srcdir)/glob' GLOBLIB=glob/libglob.a -fi -AC_SUBST(GLOBINC) -AC_SUBST(GLOBLIB) +]) +AC_SUBST([GLOBINC]) +AC_SUBST([GLOBLIB]) # Tell automake about this, so it can build the right .c files. -AM_CONDITIONAL(USE_LOCAL_GLOB, test "$make_cv_sys_gnu_glob" = no) +AM_CONDITIONAL([USE_LOCAL_GLOB], [test "$make_cv_sys_gnu_glob" = no]) # Let the makefile know what our build host is -AC_DEFINE_UNQUOTED(MAKE_HOST,"$host",[Build host information.]) +AC_DEFINE_UNQUOTED([MAKE_HOST],["$host"],[Build host information.]) MAKE_HOST="$host" -AC_SUBST(MAKE_HOST) +AC_SUBST([MAKE_HOST]) w32_target_env=no -AM_CONDITIONAL([WINDOWSENV], false) +AM_CONDITIONAL([WINDOWSENV], [false]) -case "$host" in - *-*-mingw32) - AM_CONDITIONAL(WINDOWSENV, true) +AS_CASE([$host], + [*-*-mingw32], + [AM_CONDITIONAL([WINDOWSENV], [true]) w32_target_env=yes AC_DEFINE([WINDOWS32], [1], [Use platform specific coding]) AC_DEFINE([HAVE_DOS_PATHS], [1], [Use platform specific coding]) - ;; -esac + ]) -AC_DEFINE_UNQUOTED(PATH_SEPARATOR_CHAR,'$PATH_SEPARATOR',[Define to the character that separates directories in PATH.]) +AC_DEFINE_UNQUOTED([PATH_SEPARATOR_CHAR],['$PATH_SEPARATOR'], + [Define to the character that separates directories in PATH.]) # Include the Maintainer's Makefile section, if it's here. MAINT_MAKEFILE=/dev/null -if test -r "$srcdir/maintMakefile"; then - MAINT_MAKEFILE="$srcdir/maintMakefile" -fi -AC_SUBST_FILE(MAINT_MAKEFILE) +AS_IF([test -r "$srcdir/maintMakefile"], +[ MAINT_MAKEFILE="$srcdir/maintMakefile" +]) +AC_SUBST_FILE([MAINT_MAKEFILE]) # Allow building with dmalloc AM_WITH_DMALLOC @@ -421,48 +423,45 @@ SET_MAKE= # Sanity check and inform the user of what we found -case "$make_badcust" in - yes) echo - echo "WARNING: --with-customs specified but no customs.h could be found;" - echo " disabling Customs support." - echo ;; -esac - -case "$with_customs" in - ""|n|no|y|ye|yes) ;; - *) if test -f "$with_customs/lib/libcustoms.a"; then - : - else - echo - echo "WARNING: '$with_customs/lib' does not appear to contain the" - echo " Customs library. You must build and install Customs" - echo " before compiling GNU make." - echo - fi ;; -esac - -case "$has_wait_nohang" in - no) echo - echo "WARNING: Your system has neither waitpid() nor wait3()." - echo " Without one of these, signal handling is unreliable." - echo " You should be aware that running GNU make with -j" - echo " could result in erratic behavior." - echo ;; -esac - -case "$make_cv_job_server/$user_job_server" in - no/yes) echo - echo "WARNING: Make job server requires a POSIX-ish system that" - echo " supports the pipe(), sigaction(), and either" - echo " waitpid() or wait3() functions. Your system doesn't" - echo " appear to provide one or more of those." - echo " Disabling job server support." - echo ;; -esac +AS_IF([test "x$make_badcust" = xyes], [ +echo +echo "WARNING: --with-customs specified but no customs.h could be found;" +echo " disabling Customs support." +echo +]) + +AS_CASE([$with_customs], +[""|n|no|y|ye|yes], [:], +[AS_IF([test -f "$with_customs/lib/libcustoms.a"], [:], +[ echo + echo "WARNING: '$with_customs/lib' does not appear to contain the" + echo " Customs library. You must build and install Customs" + echo " before compiling GNU make." + echo +])]) + +AS_IF([test "x$has_wait_nohang" = xno], +[ echo + echo "WARNING: Your system has neither waitpid() nor wait3()." + echo " Without one of these, signal handling is unreliable." + echo " You should be aware that running GNU make with -j" + echo " could result in erratic behavior." + echo +]) +AS_IF([test "x$make_cv_job_server" = xno && test "x$user_job_server" = xyes], +[ echo + echo "WARNING: Make job server requires a POSIX-ish system that" + echo " supports the pipe(), sigaction(), and either" + echo " waitpid() or wait3() functions. Your system doesn't" + echo " appear to provide one or more of those." + echo " Disabling job server support." + echo +]) # Specify what files are to be created. -AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile doc/Makefile w32/Makefile) +AC_CONFIG_FILES([Makefile glob/Makefile po/Makefile.in config/Makefile \ + doc/Makefile w32/Makefile]) # OK, do it! @@ -470,10 +469,10 @@ AC_OUTPUT # We only generate the build.sh if we have a build.sh.in; we won't have # one before we've created a distribution. -if test -f "$srcdir/build.sh.in"; then - ./config.status --file build.sh +AS_IF([test -f "$srcdir/build.sh.in"], +[ ./config.status --file build.sh chmod +x build.sh -fi +]) dnl Local Variables: dnl comment-start: "dnl " diff --git a/doc/make.texi b/doc/make.texi index 02c7a68..d363f4e 100644 --- a/doc/make.texi +++ b/doc/make.texi @@ -3,7 +3,7 @@ @setfilename make.info @include version.texi -@set EDITION 0.71 +@set EDITION 0.72 @set RCSID $Id$ @settitle GNU @code{make} @@ -109,28 +109,28 @@ Cover art by Etienne Suvasa. * Complex Makefile:: A real example of a straightforward, but nontrivial, makefile. -* GNU Free Documentation License:: License for copying this manual -* Concept Index:: Index of Concepts -* Name Index:: Index of Functions, Variables, & Directives +* GNU Free Documentation License:: License for copying this manual. +* Concept Index:: Index of Concepts. +* Name Index:: Index of Functions, Variables, & Directives. @detailmenu --- The Detailed Node Listing --- Overview of @code{make} -* Preparing:: Preparing and running make -* Reading:: On reading this text -* Bugs:: Problems and bugs +* Preparing:: Preparing and running @code{make}. +* Reading:: On reading this text. +* Bugs:: Problems and bugs. An Introduction to Makefiles * Rule Introduction:: What a rule looks like. -* Simple Makefile:: A simple makefile -* How Make Works:: How @code{make} processes this makefile -* Variables Simplify:: Variables make makefiles simpler -* make Deduces:: Letting @code{make} deduce the recipe -* Combine By Prerequisite:: Another style of makefile -* Cleanup:: Rules for cleaning the directory +* Simple Makefile:: A simple makefile. +* How Make Works:: How @code{make} processes this makefile. +* Variables Simplify:: Variables make makefiles simpler. +* make Deduces:: Letting @code{make} deduce the recipes. +* Combine By Prerequisite:: Another style of makefile. +* Cleanup:: Rules for cleaning the directory. Writing Makefiles @@ -170,7 +170,7 @@ Writing Rules Using Wildcard Characters in File Names -* Wildcard Examples:: Several examples +* Wildcard Examples:: Several examples. * Wildcard Pitfall:: Problems to avoid. * Wildcard Function:: How to cause wildcard expansion where it does not normally take place. @@ -211,6 +211,7 @@ Recipe Syntax Recipe Execution +* One Shell:: One shell for all lines in a recipe. * Choosing the Shell:: How @code{make} chooses the shell used to run recipes. @@ -235,6 +236,8 @@ How to Use Variables the user has set it with a command argument. * Multi-Line:: An alternate way to set a variable to a multi-line string. +* Undefine Directive:: How to undefine a variable so that it appears + as if it was never set. * Environment:: Variable values can come from the environment. * Target-specific:: Variable values can be defined on a per-target basis. @@ -267,8 +270,15 @@ Functions for Transforming Text * Eval Function:: Evaluate the arguments as makefile syntax. * Origin Function:: Find where a variable got its value. * Flavor Function:: Find out the flavor of a variable. -* Shell Function:: Substitute the output of a shell command. * Make Control Functions:: Functions that control how make runs. +* Shell Function:: Substitute the output of a shell command. +* Guile Function:: Call the GNU Guile embedded scripting language. + +The @code{guile} Function + +* Guile Types:: Converting Guile types to @code{make} strings. +* Guile Interface:: Invoking @code{make} functions from Guile. +* Guile Example:: Example using Guile in @code{make}. How to Run @code{make} @@ -289,7 +299,7 @@ How to Run @code{make} Using Implicit Rules * Using Implicit:: How to use an existing implicit rule - to get the recipe for updating a file. + to get the recipes for updating a file. * Catalogue of Rules:: A list of built-in implicit rules. * Implicit Variables:: How to change what predefined rules do. * Chained Rules:: How to use a chain of implicit rules. @@ -350,9 +360,9 @@ use it to describe any task where some files must be updated automatically from others whenever the others change. @menu -* Preparing:: Preparing and Running Make -* Reading:: On Reading this Text -* Bugs:: Problems and Bugs +* Preparing:: Preparing and running @code{make}. +* Reading:: On reading this text. +* Bugs:: Problems and bugs. @end menu @node Preparing, Reading, Overview, Overview @@ -486,12 +496,12 @@ together to produce the new executable editor. @menu * Rule Introduction:: What a rule looks like. -* Simple Makefile:: A Simple Makefile -* How Make Works:: How @code{make} Processes This Makefile -* Variables Simplify:: Variables Make Makefiles Simpler -* make Deduces:: Letting @code{make} Deduce the Recipes -* Combine By Prerequisite:: Another Style of Makefile -* Cleanup:: Rules for Cleaning the Directory +* Simple Makefile:: A simple makefile. +* How Make Works:: How @code{make} processes this makefile. +* Variables Simplify:: Variables make makefiles simpler. +* make Deduces:: Letting @code{make} deduce the recipes. +* Combine By Prerequisite:: Another style of makefile. +* Cleanup:: Rules for cleaning the directory. @end menu @node Rule Introduction, Simple Makefile, Introduction, Introduction @@ -1241,7 +1251,7 @@ date.)@refill If you know that one or more of your makefiles cannot be remade and you want to keep @code{make} from performing an implicit rule search on them, perhaps for efficiency reasons, you can use any normal method -of preventing implicit rule lookup to do so. For example, you can +of preventing implicit rule look-up to do so. For example, you can write an explicit rule with the makefile as the target, and an empty recipe (@pxref{Empty Recipes, ,Using Empty Recipes}). @@ -1697,7 +1707,7 @@ the makefile (often with a target called @samp{all}). * Wildcards:: Using wildcard characters such as `*'. * Directory Search:: Searching other directories for source files. * Phony Targets:: Using a target that is not a real file's name. -* Force Targets:: You can use a target without recipes +* Force Targets:: You can use a target without a recipe or prerequisites to mark other targets as phony. * Empty Targets:: When only the date matters and the @@ -1934,7 +1944,7 @@ specific file whose name consists of @samp{foo}, an asterisk, and @samp{bar}.@refill @menu -* Wildcard Examples:: Several examples +* Wildcard Examples:: Several examples. * Wildcard Pitfall:: Problems to avoid. * Wildcard Function:: How to cause wildcard expansion where it does not normally take place. @@ -2132,7 +2142,7 @@ just the search paths. * Selective Search:: Specifying a search path for a specified class of names. * Search Algorithm:: When and how search paths are applied. -* Recipes/Search:: How to write recipes that work together +* Recipes/Search:: How to write recipes that work together with search paths. * Implicit/Search:: How search paths affect implicit rules. * Libraries/Search:: Directory search for link libraries. @@ -2468,7 +2478,7 @@ via the @code{.LIBPATTERNS} variable. Each word in the value of this variable is a pattern string. When a prerequisite like @samp{-l@var{name}} is seen, @code{make} will replace the percent in each pattern in the list with @var{name} and perform the above directory -searches using each library filename. +searches using each library file name. The default value for @code{.LIBPATTERNS} is @samp{lib%.so lib%.a}, which provides the default behavior described above. @@ -2541,8 +2551,8 @@ Another example of the usefulness of phony targets is in conjunction with recursive invocations of @code{make} (for more information, see @ref{Recursion, ,Recursive Use of @code{make}}). In this case the makefile will often contain a variable which lists a number of -subdirectories to be built. One way to handle this is with one rule -whose recipe is a shell loop over the subdirectories, like this: +sub-directories to be built. One way to handle this is with one rule +whose recipe is a shell loop over the sub-directories, like this: @example @group @@ -2556,7 +2566,7 @@ subdirs: @end example There are problems with this method, however. First, any error -detected in a submake is ignored by this rule, so it will continue +detected in a sub-make is ignored by this rule, so it will continue to build the rest of the directories even when one fails. This can be overcome by adding shell commands to note the error and exit, but then it will do so even if @code{make} is invoked with the @code{-k} @@ -2565,8 +2575,8 @@ you cannot take advantage of @code{make}'s ability to build targets in parallel (@pxref{Parallel, ,Parallel Execution}), since there is only one rule. -By declaring the subdirectories as phony targets (you must do this as -the subdirectory obviously always exists; otherwise it won't be built) +By declaring the sub-directories as phony targets (you must do this as +the sub-directory obviously always exists; otherwise it won't be built) you can remove these problems: @example @@ -2584,8 +2594,8 @@ foo: baz @end group @end example -Here we've also declared that the @file{foo} subdirectory cannot be -built until after the @file{baz} subdirectory is complete; this kind of +Here we've also declared that the @file{foo} sub-directory cannot be +built until after the @file{baz} sub-directory is complete; this kind of relationship declaration is particularly important when attempting parallel builds. @@ -2829,7 +2839,7 @@ The high resolution file time stamps of many modern file systems lessen the chance of @command{make} incorrectly concluding that a file is up to date. Unfortunately, some hosts do not provide a way to set a high resolution file time stamp, so commands like @samp{cp -p} that -explicitly set a file's time stamp must discard its subsecond part. +explicitly set a file's time stamp must discard its sub-second part. If a file is created by such a command, you should list it as a prerequisite of @code{.LOW_RESOLUTION_TIME} so that @command{make} does not mistakenly conclude that the file is out of date. For @@ -2843,7 +2853,7 @@ dst: src @end group @end example -Since @samp{cp -p} discards the subsecond part of @file{src}'s time +Since @samp{cp -p} discards the sub-second part of @file{src}'s time stamp, @file{dst} is typically slightly older than @file{src} even when it is up to date. The @code{.LOW_RESOLUTION_TIME} line causes @command{make} to consider @file{dst} to be up to date if its time stamp @@ -3145,7 +3155,7 @@ of the target; see @ref{Automatic Variables}. Each target specified must match the target pattern; a warning is issued for each target that does not. If you have a list of files, only some of which will match the pattern, you can use the @code{filter} function to -remove nonmatching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}): +remove non-matching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}): @example files = foo.elc bar.o lose.o @@ -3713,7 +3723,7 @@ started with @samp{@@}. A rule in the makefile for the special target @vindex @code{SHELL} @r{(recipe execution)} When it is time to execute recipes to update a target, they are -executed by invoking a new subshell for each line of the recipe, +executed by invoking a new sub-shell for each line of the recipe, unless the @code{.ONESHELL} special target is in effect (@pxref{One Shell, ,Using One Shell}) (In practice, @code{make} may take shortcuts that do not affect the results.) @@ -3744,7 +3754,7 @@ problems (in this case it would certainly cause @file{../foo} to be truncated, at least). @menu -* One Shell:: One shell for all lines in a recipe +* One Shell:: One shell for all lines in a recipe. * Choosing the Shell:: How @code{make} chooses the shell used to run recipes. @end menu @@ -4192,9 +4202,9 @@ times to prevent other sorts of trouble. Recursive use of @code{make} means using @code{make} as a command in a makefile. This technique is useful when you want separate makefiles for various subsystems that compose a larger system. For example, suppose you -have a subdirectory @file{subdir} which has its own makefile, and you would +have a sub-directory @file{subdir} which has its own makefile, and you would like the containing directory's makefile to run @code{make} on the -subdirectory. You can do it by writing this: +sub-directory. You can do it by writing this: @example subsystem: @@ -4730,7 +4740,7 @@ commands based on the file names involved @cindex +, and @code{define} In recipe execution, each line of a canned sequence is treated just as if the line appeared on its own in the rule, preceded by a tab. In -particular, @code{make} invokes a separate subshell for each line. You +particular, @code{make} invokes a separate sub-shell for each line. You can use the special prefix characters that affect command lines (@samp{@@}, @samp{-}, and @samp{+}) on each line of a canned sequence. @xref{Recipes, ,Writing Recipes in Rules}. @@ -5233,7 +5243,7 @@ expands to @samp{$(y)} which in turn expands to @samp{z}; now we have @samp{$(z)}, which becomes @samp{u}. References to recursively-expanded variables within a variable name are -reexpanded in the usual fashion. For example: +re-expanded in the usual fashion. For example: @example x = $(y) @@ -5759,7 +5769,7 @@ two-lines = echo foo; echo $(bar) @noindent since two commands separated by semicolon behave much like two separate shell commands. However, note that using two separate lines means -@code{make} will invoke the shell twice, running an independent subshell +@code{make} will invoke the shell twice, running an independent sub-shell for each line. @xref{Execution, ,Recipe Execution}. If you want variable definitions made with @code{define} to take @@ -6163,12 +6173,12 @@ value. @vindex .FEATURES @r{(list of supported features)} @item .FEATURES Expands to a list of special features supported by this version of -@code{make}. Possible values include: +@code{make}. Possible values include, but are not limited to: @table @samp @item archives -Supports @code{ar} (archive) files using special filename syntax. +Supports @code{ar} (archive) files using special file name syntax. @xref{Archives, ,Using @code{make} to Update Archive Files}. @item check-symlink @@ -6206,6 +6216,10 @@ Supports target-specific and pattern-specific variable assignments. @item undefine Supports the @code{undefine} directive. @xref{Undefine Directive}. +@item guile +Has GNU Guile available as an embedded extension language. +@xref{Guile Function}. + @end table @vindex .INCLUDE_DIRS @r{(list of include directories)} @@ -6552,8 +6566,9 @@ be substituted. * Eval Function:: Evaluate the arguments as makefile syntax. * Origin Function:: Find where a variable got its value. * Flavor Function:: Find out the flavor of a variable. -* Shell Function:: Substitute the output of a shell command. * Make Control Functions:: Functions that control how make runs. +* Shell Function:: Substitute the output of a shell command. +* Guile Function:: Call the GNU Guile embedded scripting language. @end menu @node Syntax of Functions, Text Functions, Functions, Functions @@ -6580,7 +6595,7 @@ $@{@var{function} @var{arguments}@} Here @var{function} is a function name; one of a short list of names that are part of @code{make}. You can also essentially create your own -functions by using the @code{call} builtin function. +functions by using the @code{call} built-in function. The @var{arguments} are the arguments of the function. They are separated from the function name by one or more spaces or tabs, and if @@ -7259,7 +7274,7 @@ files := $(foreach dir,$(dirs),$(find_files)) @noindent Here we use the variable @code{find_files} this way. We use plain @samp{=} to define a recursively-expanding variable, so that its value contains an -actual function call to be reexpanded under the control of @code{foreach}; +actual function call to be re-expanded under the control of @code{foreach}; a simply-expanded variable would not do, since @code{wildcard} would be called only once at the time of defining @code{find_files}. @@ -7319,13 +7334,13 @@ a @samp{$} or parentheses when writing it. (You can, however, use a variable reference in the name if you want the name not to be a constant.) -If @var{variable} is the name of a builtin function, the builtin function +If @var{variable} is the name of a built-in function, the built-in function is always invoked (even if a @code{make} variable by that name also exists). The @code{call} function expands the @var{param} arguments before assigning them to temporary variables. This means that @var{variable} -values containing references to builtin functions that have special +values containing references to built-in functions that have special expansion rules, like @code{foreach} or @code{if}, may not work as you expect. @@ -7601,7 +7616,7 @@ Here the redefinition takes place if @samp{$(origin bletch)} returns either @samp{environment} or @samp{environment override}. @xref{Text Functions, , Functions for String Substitution and Analysis}. -@node Flavor Function, Shell Function, Origin Function, Functions +@node Flavor Function, Make Control Functions, Origin Function, Functions @section The @code{flavor} Function @findex flavor @cindex variables, flavor of @@ -7641,8 +7656,69 @@ if @var{variable} is a simply expanded variable. @end table +@node Make Control Functions, Shell Function, Flavor Function, Functions +@section Functions That Control Make +@cindex functions, for controlling make +@cindex controlling make + +These functions control the way make runs. Generally, they are used to +provide information to the user of the makefile or to cause make to stop +if some sort of environmental error is detected. + +@table @code +@item $(error @var{text}@dots{}) +@findex error +@cindex error, stopping on +@cindex stopping make +Generates a fatal error where the message is @var{text}. Note that +the error is generated whenever this function is evaluated. So, if +you put it inside a recipe or on the right side of a recursive +variable assignment, it won't be evaluated until later. The +@var{text} will be expanded before the error is generated. + +For example, + +@example +ifdef ERROR1 +$(error error is $(ERROR1)) +endif +@end example + +@noindent +will generate a fatal error during the read of the makefile if the +@code{make} variable @code{ERROR1} is defined. Or, + +@example +ERR = $(error found an error!) + +.PHONY: err +err: ; $(ERR) +@end example + +@noindent +will generate a fatal error while @code{make} is running, if the +@code{err} target is invoked. + +@item $(warning @var{text}@dots{}) +@findex warning +@cindex warnings, printing +@cindex printing user warnings +This function works similarly to the @code{error} function, above, +except that @code{make} doesn't exit. Instead, @var{text} is expanded +and the resulting message is displayed, but processing of the makefile +continues. -@node Shell Function, Make Control Functions, Flavor Function, Functions +The result of the expansion of this function is the empty string. + +@item $(info @var{text}@dots{}) +@findex info +@cindex printing messages +This function does nothing more than print its (expanded) argument(s) +to standard output. No makefile name or line number is added. The +result of the expansion of this function is the empty string. +@end table + +@node Shell Function, Guile Function, Make Control Functions, Functions @section The @code{shell} Function @findex shell @cindex command expansion @@ -7690,67 +7766,213 @@ using a very strange shell, this has the same result as @w{@samp{$(wildcard *.c)}} (as long as at least one @samp{.c} file exists).@refill -@node Make Control Functions, , Shell Function, Functions -@section Functions That Control Make -@cindex functions, for controlling make -@cindex controlling make +@node Guile Function, , Shell Function, Functions +@section The @code{guile} Function +@findex guile +@cindex Guile -These functions control the way make runs. Generally, they are used to -provide information to the user of the makefile or to cause make to stop -if some sort of environmental error is detected. +GNU make may be built with support for GNU Guile as an embedded +extension language. You can check the @code{.FEATURES} variable for +the word @samp{guile} to determine if your version of GNU make +provides this capability. + +GNU Guile implements the Scheme language. A review of GNU Guile and +the Scheme language and its features is beyond the scope of this +manual: see the documentation for GNU Guile and Scheme. + +If GNU Guile is available as an extension language, there will be one +new @code{make} function available: @code{guile}. The @code{guile} +function takes one argument which is first expanded by @code{make} in +the normal fashion, then passed to the GNU Guile evaluator. The +result of the evaluator is converted into a string and used as the +expansion of the @code{guile} function in the makefile. + +Similarly, there are Guile procedures exposed by @code{make} for use +in Guile scripts. + +@menu +* Guile Types:: Converting Guile types to @code{make} strings. +* Guile Interface:: Invoking @code{make} functions from Guile. +* Guile Example:: Example using Guile in @code{make}. +@end menu + +@node Guile Types, Guile Interface, Guile Function, Guile Function +@subsection Conversion of Guile Types +@cindex convert guile types +@cindex guile, conversion of types +@cindex types, conversion of + +There is only one ``data type'' in @code{make}: a string. GNU Guile, +on the other hand, provides a rich variety of different data types. +An important aspect of the interface between @code{make} and GNU Guile +is the conversion of Guile data types into @code{make} strings. + +This conversion is relevant in two places: when a makefile invokes the +@code{guile} function to evaluate a Guile expression, the result of +that evaluation must be converted into a make string so it can be +further evaluated by @code{make}. And secondly, when a Guile script +invokes one of the procedures exported by @code{make} the argument +provided to the procedure must be converted into a string. + +The conversion of Guile types into @code{make} strings is as below: @table @code -@item $(error @var{text}@dots{}) -@findex error -@cindex error, stopping on -@cindex stopping make -Generates a fatal error where the message is @var{text}. Note that -the error is generated whenever this function is evaluated. So, if -you put it inside a recipe or on the right side of a recursive -variable assignment, it won't be evaluated until later. The -@var{text} will be expanded before the error is generated. +@item #f +False is converted into the empty string: in @code{make} conditionals +the empty string is considered false. -For example, +@item #t +True is converted to the string @samp{#t}: in @code{make} conditionals +any non-empty string is considered true. + +@item symbol +@item number +A symbol or number is converted into the string representation of that +symbol or number. + +@item character +A printable character is converted to the same character. + +@item string +A string containing only printable characters is converted to the same +string. + +@item list +A list is converted recursively according to the above rules. This +implies that any structured list will be flattened (that is, a result +of @samp{'(a b (c d) e)} will be converted to the @code{make} string +@samp{a b c d e}). + +@item other +Any other Guile type results in an error. In future versions of +@code{make}, other Guile types may be converted. + +@end table + +The translation of @samp{#f} (to the empty string) and @samp{#t} (to +the non-empty string @samp{#t}) is designed to allow you to use Guile +boolean results directly as @code{make} boolean conditions. For +example: @example -ifdef ERROR1 -$(error error is $(ERROR1)) -endif +$(if $(guile (access? "myfile" R_OK)),$(info myfile exists)) @end example -@noindent -will generate a fatal error during the read of the makefile if the -@code{make} variable @code{ERROR1} is defined. Or, +As a consequence of these conversion rules you must consider the +result of your Guile script, as that result will be converted into a +string and parsed by @code{make}. If there is no natural result for +the script (that is, the script exists solely for its side-effects), +you should add @samp{#f} as the final expression in order to avoid +syntax errors in your makefile. + +@node Guile Interface, Guile Example, Guile Types, Guile Function +@subsection Interfaces from Guile to @code{make} +@cindex make interface to guile +@cindex make procedures in guile + +In addition to the @code{guile} function available in makefiles, +@code{make} exposes some procedures for use in your Guile scripts. At +startup @code{make} creates a new Guile module, @code{gnu make}, and +exports these procedures as public interfaces from that module: + +@table @code +@item gmk-expand +This procedure takes a single argument which is converted into a +string. The string is expanded by @code{make} using normal +@code{make} expansion rules. The result of the expansion is converted +into a Guile string and provided as the result of the procedure. + +@item gmk-eval +This procedure takes a single argument which is converted into a +string. The string is evaluated by @code{make} as if it were a +makefile. This is the same capability available via the @code{eval} +function (@pxref{Eval Function}). The result of the @code{gmk-eval} +procedure is always the empty string. + +@item gmk-var +This procedure takes a single argument which is converted into a +string. The string is assumed to be the name of a @code{make} +variable, which is then expanded. The expansion is converted into a +string and provided as the result of the procedure. + +@end table + +@node Guile Example, , Guile Interface, Guile Function +@subsection Example Using Guile in @code{make} +@cindex Guile example +@cindex example using Guile + +Here is a very simple example using GNU Guile to manage writing to a +file. These Guile procedures simply open a file, allow writing to the +file (one string per line), and close the file. Note that because we +cannot store complex values such as Guile ports in @code{make} +variables, we'll keep the port as a global variable in the Guile +interpreter. + +You can create Guile functions easily using @code{define}/@code{endef} +to create a Guile script, then use the @code{guile} function to +internalize it: @example -ERR = $(error found an error!) +@group +define GUILEIO +;; A simple Guile IO library for GNU make -.PHONY: err -err: ; $(ERR) +(define MKPORT #f) + +(define (mkopen name mode) + (set! MKPORT (open-file name mode)) + #f) + +(define (mkwrite s) + (display s MKPORT) + (newline MKPORT) + #f) + +(define (mkclose) + (close-port MKPORT) + #f) + +#f +endef + +# Internalize the Guile IO functions +$(guile $(GUILEIO)) +@end group @end example -@noindent -will generate a fatal error while @code{make} is running, if the -@code{err} target is invoked. +If you have a significant amount of Guile support code, you might +consider keeping it in a different file (e.g., @file{guileio.scm}) and +then loading it in your makefile using the @code{guile} function: -@item $(warning @var{text}@dots{}) -@findex warning -@cindex warnings, printing -@cindex printing user warnings -This function works similarly to the @code{error} function, above, -except that @code{make} doesn't exit. Instead, @var{text} is expanded -and the resulting message is displayed, but processing of the makefile -continues. +@example +$(guile (load "guileio.scm")) +@end example -The result of the expansion of this function is the empty string. +An advantage to this method is that when editing @file{guileio.scm}, +your editor will understand that this file contains Scheme syntax +rather than makefile syntax. + +Now you can use these Guile functions to create files. Suppose you +need to operate on a very large list, which cannot fit on the command +line, but the utility you're using accepts the list as input as well: + +@example +@group +prog: $(PREREQS) + @@$(guile (mkopen "tmp.out" "w")) \ + $(foreach X,$^,$(guile (mkwrite "$(X)"))) \ + $(guile (mkclose)) + $(LINK) < tmp.out +@end group +@end example + +A more comprehensive suite of file manipulation procedures is possible +of course. You could, for example, maintain multiple output files at +the same time by choosing a symbol for each one and using it as the +key to a hash table, where the value is a port, then returning the +symbol to be stored in a @code{make} variable. -@item $(info @var{text}@dots{}) -@findex info -@cindex printing messages -This function does nothing more than print its (expanded) argument(s) -to standard output. No makefile name or line number is added. The -result of the expansion of this function is the empty string. -@end table @node Running, Implicit Rules, Functions, Top @chapter How to Run @code{make} @@ -8302,7 +8524,7 @@ Prints messages describing the implicit rule searches for each target. This option also enables @samp{basic} messages. @item j (@i{jobs}) -Prints messages giving details on the invocation of specific subcommands. +Prints messages giving details on the invocation of specific sub-commands. @item m (@i{makefile}) By default, the above messages are not enabled while trying to remake @@ -8439,7 +8661,7 @@ specified. This also prints the version information given by the @samp{-v} switch (see below). To print the data base without trying to remake any files, use @w{@samp{make -qp}}. To print the data base of predefined rules and variables, use @w{@samp{make -p -f /dev/null}}. -The data base output contains filename and linenumber information for +The data base output contains file name and line number information for recipe and variable definitions, so it can be a useful debugging tool in complex environments. @@ -8520,7 +8742,7 @@ recipes were done, in order to fool future invocations of Print the entire recipe to be executed, even for recipes that are normally silent (due to @code{.SILENT} or @samp{@@}). Also print the -makefile name and linenumber where the recipe was defined. +makefile name and line number where the recipe was defined. @item -v @cindex @code{-v} @@ -8622,7 +8844,7 @@ retained for compatibility. * Implicit Variables:: How to change what predefined rules do. * Chained Rules:: How to use a chain of implicit rules. * Pattern Rules:: How to define new implicit rules. -* Last Resort:: How to define recipes for rules which +* Last Resort:: How to define a recipe for rules which cannot find any. * Suffix Rules:: The old-fashioned style of implicit rule. * Implicit Rule Search:: The precise algorithm for applying @@ -9348,7 +9570,7 @@ Variables}, and @ref{Functions, ,Functions for Transforming Text}. * Pattern Intro:: An introduction to pattern rules. * Pattern Examples:: Examples of pattern rules. * Automatic Variables:: How to use automatic variables in the - recipes of implicit rules. + recipe of implicit rules. * Pattern Match:: How patterns match. * Match-Anything Rules:: Precautions you should take prior to defining rules that can match any @@ -9448,7 +9670,7 @@ Here is a second built-in rule: @noindent defines a rule that can make any file @file{@var{x}} whatsoever from a -corresponding file @file{@var{x},v} in the subdirectory @file{RCS}. Since +corresponding file @file{@var{x},v} in the sub-directory @file{RCS}. Since the target is @samp{%}, this rule will apply to any file whatever, provided the appropriate prerequisite file exists. The double colon makes the rule @dfn{terminal}, which means that its prerequisite may not be an intermediate @@ -9821,7 +10043,7 @@ remade from any other files; therefore, @code{make} can save time by not looking for ways to remake them.@refill If you do not mark the match-anything rule as terminal, then it is -nonterminal. A nonterminal match-anything rule cannot apply to a file name +non-terminal. A non-terminal match-anything rule cannot apply to a file name that indicates a specific type of data. A file name indicates a specific type of data if some non-match-anything implicit rule target matches it. @@ -9829,18 +10051,18 @@ For example, the file name @file{foo.c} matches the target for the pattern rule @samp{%.c : %.y} (the rule to run Yacc). Regardless of whether this rule is actually applicable (which happens only if there is a file @file{foo.y}), the fact that its target matches is enough to prevent -consideration of any nonterminal match-anything rules for the file +consideration of any non-terminal match-anything rules for the file @file{foo.c}. Thus, @code{make} will not even consider trying to make @file{foo.c} as an executable file from @file{foo.c.o}, @file{foo.c.c}, @file{foo.c.p}, etc.@refill -The motivation for this constraint is that nonterminal match-anything +The motivation for this constraint is that non-terminal match-anything rules are used for making files containing specific types of data (such as executable files) and a file name with a recognized suffix indicates some other specific type of data (such as a C source file). Special built-in dummy pattern rules are provided solely to recognize -certain file names so that nonterminal match-anything rules will not be +certain file names so that non-terminal match-anything rules will not be considered. These dummy rules have no prerequisites and no recipes, and they are ignored for all other purposes. For example, the built-in implicit rule @@ -10060,7 +10282,7 @@ matched against @var{t}; otherwise, against @var{n}. @item If any rule in that list is @emph{not} a match-anything rule, then -remove all nonterminal match-anything rules from the list. +remove all non-terminal match-anything rules from the list. @item Remove from the list all rules with no recipe. @@ -10133,7 +10355,7 @@ prerequisites. @xref{Automatic Variables}. @chapter Using @code{make} to Update Archive Files @cindex archive -@dfn{Archive files} are files containing named subfiles called +@dfn{Archive files} are files containing named sub-files called @dfn{members}; they are maintained with the program @code{ar} and their main use is as subroutine libraries for linking. @@ -10628,7 +10850,7 @@ of archive file @var{file}. The member is chosen, not by name, but by being an object file which defines the linker symbol @var{entry}.@refill This feature was not put into GNU @code{make} because of the -nonmodularity of putting knowledge into @code{make} of the internal +non-modularity of putting knowledge into @code{make} of the internal format of archive file symbol tables. @xref{Archive Symbols, ,Updating Archive Symbol Directories}. @@ -11103,7 +11325,7 @@ option. Errors that are fatal are prefixed with the string Error messages are all either prefixed with the name of the program (usually @samp{make}), or, if the error is found in a makefile, the name -of the file and linenumber containing the problem. +of the file and line number containing the problem. In the table below, these common prefixes are left off. @@ -11117,7 +11339,7 @@ non-0 error code (@samp{Error @var{NN}}), which @code{make} interprets as failure, or it exited in some other abnormal fashion (with a signal of some type). @xref{Errors, ,Errors in Recipes}. -If no @code{***} is attached to the message, then the subprocess failed +If no @code{***} is attached to the message, then the sub-process failed but the rule in the makefile was prefixed with the @code{-} special character, so @code{make} ignored the error. @@ -11157,7 +11379,7 @@ either explicit or implicit (including in the default rules database). If you want that file to be built, you will need to add a rule to your makefile describing how that target can be built. Other possible -sources of this problem are typos in the makefile (if that filename is +sources of this problem are typos in the makefile (if that file name is wrong) or a corrupted source tree (if that file is not supposed to be built, but rather only a prerequisite). diff --git a/dosbuild.bat b/dosbuild.bat index c911e18..df74aef 100644 --- a/dosbuild.bat +++ b/dosbuild.bat @@ -55,6 +55,8 @@ echo commands.o > respf.$$$ for %%f in (job dir file misc main read remake rule implicit default variable) do echo %%f.o >> respf.$$$
for %%f in (expand function vpath hash strcache version ar arscan signame remote-stub getopt getopt1) do echo %%f.o >> respf.$$$
echo glob/libglob.a >> respf.$$$
+rem gcc -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g guile.c -o guile.o
+rem echo guile.o >> respf.$$$
@echo Linking...
@echo on
gcc -o make.new @respf.$$$
@@ -2103,6 +2103,21 @@ func_abspath (char *o, char **argv, const char *funcname UNUSED) return o; } +#ifdef HAVE_GUILE +static char * +func_guile (char *o, char **argv, const char *funcname UNUSED) +{ + if (argv[0] && argv[0][0] != '\0') + { + char *str = guile_eval_string (argv[0]); + o = variable_buffer_output (o, str, strlen (str)); + free (str); + } + + return o; +} +#endif + /* Lookup table for builtin functions. This doesn't have to be sorted; we use a straight lookup. We might gain @@ -2156,6 +2171,9 @@ static struct function_table_entry function_table_init[] = { STRING_SIZE_TUPLE("and"), 1, 0, 0, func_and}, { STRING_SIZE_TUPLE("value"), 0, 1, 1, func_value}, { STRING_SIZE_TUPLE("eval"), 0, 1, 1, func_eval}, +#ifdef HAVE_GUILE + { STRING_SIZE_TUPLE("guile"), 0, 1, 1, func_guile}, +#endif #ifdef EXPERIMENTAL { STRING_SIZE_TUPLE("eq"), 2, 2, 1, func_eq}, { STRING_SIZE_TUPLE("not"), 0, 1, 1, func_not}, diff --git a/gmk-default.scm b/gmk-default.scm new file mode 100644 index 0000000..37db2f7 --- /dev/null +++ b/gmk-default.scm @@ -0,0 +1,57 @@ +;; Contents of the (gnu make) Guile module +;; Copyright (C) 2011 Free Software Foundation, Inc. +;; This file is part of GNU Make. +;; +;; GNU Make is free software; you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free +;; Software Foundation; either version 3 of the License, or (at your option) +;; any later version. +;; +;; GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +;; details. +;; +;; You should have received a copy of the GNU General Public License along +;; with this program. If not, see <http://www.gnu.org/licenses/>. + +(define (to-string-maybe x) + (cond + ;; In GNU make, "false" is the empty string + ((or (not x) + (unspecified? x) + (null? x) + (and (string? x) (string-null? x))) + #f) + ;; We want something not false... not sure about this + ((eq? x #t) "#t") + ;; Basics + ((or (symbol? x) (number? x)) + (object->string x)) + ((char? x) + (string x)) + ;; Printable string (no special characters) + ((and (string? x) + (eq? (string-length (string-delete x char-set:printing)) 0)) + x) + ;; No idea: fail + (else (error "Unknown object:" x)))) + +(define (obj-to-str x) + (let ((acc '())) + (define (walk x) + (cond ((pair? x) (walk (car x)) (walk (cdr x))) + ((to-string-maybe x) => (lambda (s) (set! acc (cons s acc)))))) + (walk x) + (string-join (reverse! acc)))) + +;; eval (GNU make eval) the input string S +(define (gmk-eval s) + (gmk-expand (format #f "$(eval ~a)" (obj-to-str s)))) + +;; Return the value of the GNU make variable V +(define (gmk-var v) + (gmk-expand (format #f "$(~a)" (obj-to-str v)))) + +;; Export the public interfaces +(export gmk-expand gmk-eval gmk-var) @@ -0,0 +1,104 @@ +/* GNU Guile interface for GNU Make. +Copyright (C) 2011 Free Software Foundation, Inc. +This file is part of GNU Make. + +GNU Make is free software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the Free Software +Foundation; either version 3 of the License, or (at your option) any later +version. + +GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "make.h" +#include "debug.h" +#include "dep.h" +#include "variable.h" + +#include <libguile.h> + +static SCM make_mod = SCM_EOL; +static SCM obj_to_str = SCM_EOL; + +/* Convert an SCM object into a string. */ +static char * +cvt_scm_to_str (SCM obj) +{ + return scm_to_locale_string (scm_call_1 (obj_to_str, obj)); +} + +/* Perform the GNU make expansion function. */ +static SCM +guile_expand_wrapper (SCM obj) +{ + char *str = cvt_scm_to_str (obj); + SCM ret; + char *res; + + DB (DB_BASIC, (_("guile: Expanding '%s'\n"), str)); + res = allocated_variable_expand (str); + ret = scm_from_locale_string (res); + + free (str); + free (res); + + return ret; +} + +/* Invoked by scm_c_define_module(), in the context of the GNU make module. */ +static void +guile_define_module (void *data UNUSED) +{ +/* Ingest the predefined Guile module for GNU make. */ +#include "gmk-default.h" + + /* Register a subr for GNU make's eval capability. */ + scm_c_define_gsubr ("gmk-expand", 1, 0, 0, guile_expand_wrapper); + + /* Define the rest of the module. */ + scm_c_eval_string (GUILE_module_defn); +} + +/* Initialize the GNU make Guile module. */ +static void * +guile_init (void *arg UNUSED) +{ + /* Define the module. */ + make_mod = scm_c_define_module ("gnu make", guile_define_module, NULL); + + /* Get a reference to the object-to-string translator, for later. */ + obj_to_str = scm_variable_ref (scm_c_module_lookup (make_mod, "obj-to-str")); + + /* Import the GNU make module exports into the generic space. */ + scm_c_eval_string ("(use-modules (gnu make))"); + + return NULL; +} + +static void * +internal_guile_eval (void *arg) +{ + return cvt_scm_to_str (scm_c_eval_string (arg)); +} + +/* ----- Public interface ----- */ + +/* This is the make interface for passing programs to Guile. */ +char * +guile_eval_string (char *str) +{ + return scm_with_guile (internal_guile_eval, str); +} + +void +setup_guile () +{ + scm_with_guile (guile_init, NULL); + + /* Add 'guile' to the list of features. */ + do_variable_definition (NILF, ".FEATURES", "guile", o_default, f_append, 0); +} @@ -910,7 +910,6 @@ open_tmpfile(char **name, const char *template) #endif } - #ifdef _AMIGA int main (int argc, char **argv) @@ -958,7 +957,7 @@ main (int argc, char **argv, char **envp) #endif /* Needed for OS/2 */ - initialize_main(&argc, &argv); + initialize_main (&argc, &argv); reading_file = 0; @@ -1125,6 +1124,7 @@ main (int argc, char **argv, char **envp) } else directory_before_chdir = xstrdup (current_directory); + #ifdef __MSDOS__ /* Make sure we will return to the initial directory, come what may. */ atexit (msdos_return_to_initial_directory); @@ -1156,6 +1156,11 @@ main (int argc, char **argv, char **envp) define_variable_cname (".FEATURES", features, o_default, 0); } +#ifdef HAVE_GUILE + /* Configure GNU Guile support */ + setup_guile (); +#endif + /* Read in variables from the environment. It is important that this be done before $(MAKE) is figured out so its definitions will not be from the environment. */ @@ -2362,7 +2367,7 @@ main (int argc, char **argv, char **envp) } /* NOTREACHED */ - return 0; + exit(0); } /* Parsing of arguments, decoding of switches. */ @@ -465,6 +465,11 @@ const char *strcache_add (const char *str); const char *strcache_add_len (const char *str, unsigned int len); int strcache_setbufsize (unsigned int size); +/* Guile support */ +char *guile_eval_string (char *str); +void setup_guile (void); + + #ifdef HAVE_VFORK_H # include <vfork.h> #endif diff --git a/make_msvc_net2003.vcproj b/make_msvc_net2003.vcproj index 357dfba..cfb0deb 100644 --- a/make_msvc_net2003.vcproj +++ b/make_msvc_net2003.vcproj @@ -154,6 +154,11 @@ <File
RelativePath=".\getopt1.c">
</File>
+<!--
+ <File
+ RelativePath=".\guile.c">
+ </File>
+-->
<File
RelativePath=".\hash.c">
</File>
@@ -264,6 +269,9 @@ RelativePath=".\gettext.h">
</File>
<File
+ RelativePath=".\gmk-default.h">
+ </File>
+ <File
RelativePath=".\hash.h">
</File>
<File
diff --git a/makefile.vms b/makefile.vms index 1e6a88e..54f0267 100644 --- a/makefile.vms +++ b/makefile.vms @@ -89,11 +89,15 @@ mandir = [] # Number to put on the man page filename. manext = 1 +#guile = ,guile.obj + objs = commands.obj,job.obj,dir.obj,file.obj,misc.obj,hash.obj,\ main.obj,read.obj,remake.obj,rule.obj,implicit.obj,\ default.obj,variable.obj,expand.obj,function.obj,strcache.obj,\ - vpath.obj,version.obj$(ARCHIVES)$(ALLOCA)$(extras)$(getopt)$(glob) -srcs = commands.c job.c dir.c file.c misc.c hash.c \ + vpath.obj,version.obj\ + $(ARCHIVES)$(ALLOCA)$(extras)$(getopt)$(glob)$(guile) + +srcs = commands.c job.c dir.c file.c misc.c guile.c hash.c \ main.c read.c remake.c rule.c implicit.c \ default.c variable.c expand.c function.c strcache.c \ vpath.c version.c vmsfunctions.c vmsify.c $(ARCHIVES_SRC) $(ALLOCASRC) \ @@ -124,6 +128,7 @@ misc.obj: misc.c make.h dep.h hash.obj: hash.c make.h hash.h strcache.obj: strcache.c make.h hash.h main.obj: main.c make.h commands.h dep.h filedef.h variable.h job.h +guile.obj: guile.c make.h debug.h dep.h gmk-default.h read.obj: read.c make.h commands.h dep.h filedef.h variable.h remake.obj: remake.c make.h commands.h job.h dep.h filedef.h rule.obj: rule.c make.h commands.h dep.h filedef.h variable.h rule.h diff --git a/po/ChangeLog b/po/ChangeLog index f518e70..ca08741 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2012-01-12 Paul Smith <psmith@gnu.org> + + * POTFILES.in: Add new guile.c file. + 2011-09-26 Paul Smith <psmith@gnu.org> * LINGUAS: Added new translation file for Czech (cs). diff --git a/po/POTFILES.in b/po/POTFILES.in index 05208bb..1f31763 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -24,6 +24,7 @@ expand.c file.c function.c getopt.c +guile.c hash.c implicit.c job.c diff --git a/tests/scripts/functions/guile b/tests/scripts/functions/guile new file mode 100644 index 0000000..82c02bc --- /dev/null +++ b/tests/scripts/functions/guile @@ -0,0 +1,81 @@ +# -*-perl-*- + +$description = 'Test the $(guile ...) function.'; + +$details = 'This only works on systems that support it.'; + +# If this instance of make doesn't support GNU Guile, skip it +exists $FEATURES{guile} or return -1; + +# Verify simple data type conversions +# Currently we don't support vectors: +# echo '$(guile (vector 1 2 3))'; \ +run_make_test(q! +x:;@echo '$(guile #f)'; \ + echo '$(guile #t)'; \ + echo '$(guile #\c)'; \ + echo '$(guile 1234)'; \ + echo '$(guile 'foo)'; \ + echo '$(guile "bar")'; \ + echo '$(guile (cons 'a 'b))'; \ + echo '$(guile '(a b (c . d) 1 (2) 3))' +!, + '', "\n#t\nc\n1234\nfoo\nbar\na b\na b c d 1 2 3"); + +# Verify the gmk-expand function +run_make_test(q! +VAR = $(guile (gmk-expand "$(shell echo hi)")) +x:;@echo '$(VAR)' +!, + '', "hi"); + +# Verify the gmk-eval function +run_make_test(q! +$(guile (gmk-eval "VAR = hi $(shell echo there)")) +x:;@echo '$(VAR)' +!, + '', "hi there"); + +# Verify the gmk-eval function with a list +run_make_test(q! +$(guile (gmk-eval '(VAR = 1 (2) () 3))) +x:;@echo '$(VAR)' +!, + '', "1 2 3"); + +# Verify the gmk-var function +run_make_test(q! +VALUE = hi $(shell echo there) +VAR = $(guile (gmk-var "VALUE")) +x:;@echo '$(VAR)' +!, + '', "hi there"); + +# Verify the gmk-var function with a symbol +run_make_test(q! +VALUE = hi $(shell echo there) +VAR = $(guile (gmk-var 'VALUE)) +x:;@echo '$(VAR)' +!, + '', "hi there"); + +# Write a Guile program using define and run it +run_make_test(q! +# Define the "fib" function in Guile +define fib +;; A procedure for counting the n:th Fibonacci number +;; See SICP, p. 37 +(define (fib n) + (cond ((= n 0) 0) + ((= n 1) 1) + (else (+ (fib (- n 1)) + (fib (- n 2)))))) +endef +$(guile $(fib)) + +# Now run it +x:;@echo $(guile (fib $(FIB))) +!, + 'FIB=10', "55"); + +1; |