diff --git a/guile-config/.cvsignore b/guile-config/.cvsignore new file mode 100644 index 000000000..d634abbfc --- /dev/null +++ b/guile-config/.cvsignore @@ -0,0 +1,2 @@ +Makefile +guile-config diff --git a/guile-config/Makefile.am b/guile-config/Makefile.am new file mode 100644 index 000000000..133cbb231 --- /dev/null +++ b/guile-config/Makefile.am @@ -0,0 +1,22 @@ +#### Makefile.in template for guile-core/guile-config. +#### Jim Blandy --- September 1997 + +bin_SCRIPTS=guile-config +CLEANFILES=guile-config +EXTRA_DIST=guile-config.in + +## We use @-...-@ as the substitution brackets here, instead of the +## usual @...@, so autoconf doesn't go and substitute the values +## directly into the left-hand sides of the sed substitutions. *sigh* +guile-config: guile-config.in + rm -f guile-config.tmp + sed < ${srcdir}/guile-config.in > guile-config.tmp \ + -e s:@-bindir-@:${bindir}: \ + -e s:@-GUILE_VERSION-@:${GUILE_VERSION}: + chmod +x guile-config.tmp + mv guile-config.tmp guile-config + +## Get rid of any copies of the configuration script under the old +## name, so people don't end up running ancient copies of it. +install-exec-local: + rm -f ${bindir}/build-guile diff --git a/guile-config/Makefile.in b/guile-config/Makefile.in new file mode 100644 index 000000000..1b3da0aef --- /dev/null +++ b/guile-config/Makefile.in @@ -0,0 +1,224 @@ +# Makefile.in generated automatically by automake 1.3 from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +#### Makefile.in template for guile-core/guile-config. +#### Jim Blandy --- September 1997 + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AWK = @AWK@ +CC = @CC@ +CPP = @CPP@ +GUILE_LIBS = @GUILE_LIBS@ +GUILE_MAJOR_VERSION = @GUILE_MAJOR_VERSION@ +GUILE_MINOR_VERSION = @GUILE_MINOR_VERSION@ +GUILE_STAMP = @GUILE_STAMP@ +GUILE_VERSION = @GUILE_VERSION@ +LD = @LD@ +LIBLOBJS = @LIBLOBJS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +PACKAGE = @PACKAGE@ +QTHREAD_LTLIBS = @QTHREAD_LTLIBS@ +RANLIB = @RANLIB@ +THREAD_CPPFLAGS = @THREAD_CPPFLAGS@ +THREAD_LIBS_INSTALLED = @THREAD_LIBS_INSTALLED@ +THREAD_LIBS_LOCAL = @THREAD_LIBS_LOCAL@ +THREAD_PACKAGE = @THREAD_PACKAGE@ +VERSION = @VERSION@ +qtdmdb_s = @qtdmdb_s@ +qtmd_h = @qtmd_h@ +qtmdc_c = @qtmdc_c@ +qtmds_s = @qtmds_s@ + +bin_SCRIPTS=guile-config +CLEANFILES=guile-config +EXTRA_DIST=guile-config.in +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../libguile/scmconfig.h +CONFIG_CLEAN_FILES = +SCRIPTS = $(bin_SCRIPTS) + +DIST_COMMON = ChangeLog Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +all: Makefile $(SCRIPTS) + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu guile-config/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(bin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = guile-config + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu guile-config/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-binSCRIPTS install-exec-local + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-binSCRIPTS + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(DATADIR)$(bindir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-generic + +clean: clean-generic mostlyclean + +distclean: distclean-generic clean + -rm -f config.status + -rm -f libtool + +maintainer-clean: maintainer-clean-generic distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: uninstall-binSCRIPTS install-binSCRIPTS tags distdir info dvi \ +installcheck install-exec install-data install uninstall all \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +guile-config: guile-config.in + rm -f guile-config.tmp + sed < ${srcdir}/guile-config.in > guile-config.tmp \ + -e s:@-bindir-@:${bindir}: \ + -e s:@-GUILE_VERSION-@:${GUILE_VERSION}: + chmod +x guile-config.tmp + mv guile-config.tmp guile-config + +install-exec-local: + rm -f ${bindir}/build-guile + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/guile-config/guile-config.in b/guile-config/guile-config.in new file mode 100644 index 000000000..ab0127a57 --- /dev/null +++ b/guile-config/guile-config.in @@ -0,0 +1,214 @@ +#!@-bindir-@/guile \ +-e main -s +!# +;;;; guile-config --- utility for linking programs with Guile +;;;; Jim Blandy --- September 1997 + +;;; TODO: +;;; * Add some plausible structure for returning the right exit status, +;;; just something that encourages people to do the correct thing. +;;; * Implement the static library support. This requires that +;;; some portion of the module system be done. + +(use-modules (ice-9 regex) + (ice-9 string-fun)) + + +;;;; main function, command-line processing + +;;; The script's entry point. +(define (main args) + (set-program-name! (car args)) + (let ((args (cdr args))) + (cond + ((null? args) (show-help '()) + (quit 1)) + ((assoc (car args) command-table) + => (lambda (row) + (set! subcommand-name (car args)) + ((cadr row) (cdr args)))) + (else (show-help '()) + (quit 1))))) + +(define program-name #f) +(define subcommand-name #f) +(define program-version "@-GUILE_VERSION-@") + +;;; Given an executable path PATH, set program-name to something +;;; appropriate f or use in error messages (i.e., with leading +;;; directory names stripped). +(define (set-program-name! path) + (set! program-name + (cond + ((string-match "/([^/]+)$" path) + => (lambda (match) (match:substring match 1))) + (else path)))) + +(define (show-help args) + (cond + ((null? args) (show-help-overview)) + ((assoc (car args) command-table) + => (lambda (row) ((caddr row)))) + (else + (show-help-overview)))) + +(define (show-help-overview) + (let ((dl display-line-error)) + (dl "Usage: ") + (dl " " program-name " link - print libraries to link with") + ;; Not yet implemented. + ;; (dl " " program-name " main - generate initialization code") + (dl " " program-name " info [VAR] - print Guile build directories") + (dl " " program-name " --help - show usage info (this message)") + (dl " " program-name " --help SUBCOMMAND - show help for SUBCOMMAND") + (dl " " program-name " --version - show running version"))) + +(define (show-version args) + (display-line program-name " - Guile version " program-version)) + + +;;;; the "link" subcommand + +;;; Write a set of linker flags to standard output to include the +;;; libraries that libguile needs to link against. +;;; +;;; In the long run, we want to derive these flags from Guile module +;;; declarations files that are installed along the load path. For +;;; now, we're just going to reach into Guile's configuration info and +;;; hack it out. +(define (build-link args) + (if (> (length args) 0) + (error + (string-append program-name + " link: arguments to subcommand not yet implemented"))) + + (let* ((flags + (let loop ((libs + ;; Get the string of linker flags we used to build + ;; Guile, and break it up into a list. + (separate-fields-discarding-char #\space + (get-build-info 'LIBS) + list))) + (cond + ((null? libs) '()) + + ;; Turn any "FOO/libBAR.a" elements into "-lBAR". + ((string-match "^.*/lib([^./]+).a$" (car libs)) + => (lambda (match) + (cons (string-append "-l" (match:substring match 1)) + (loop (cdr libs))))) + + ;; Remove any empty strings that may have seeped in there. + ((string=? (car libs) "") (loop (cdr libs))) + + (else (cons (car libs) (loop (cdr libs))))))) + + ;; Don't omit -lguile itself from the list of flags. + (flags (cons "-lguile" flags))) + + ;; Display the flags, separated by spaces. + (display-separated flags) + (newline))) + +(define (help-link) + (let ((dle display-line-error)) + (dle "Usage: " program-name " link") + (dle "Print linker flags for building the `guile' executable.") + (dle "Print the linker command-line flags necessary to link against the") + (dle "Guile library, and any other libraries it requires."))) + + + +;;;; The "main" subcommand + +;;; We haven't implemented this yet, because we don't have the +;;; mechanisms in place to discover the installed static link +;;; libraries. When we do implement this, remember to fix the message +;;; in show-help-overview. +(define (build-main args) + (display-line-error program-name ": `main' subcommand not yet implemented") + (quit 2)) + +(define (help-main) + (let ((dle display-line-error)) + (dle "Usage: " program-name " main") + (dle "This subcommand is not yet implemented."))) + + +;;;; The "info" subcommand + +(define (build-info args) + (cond + ((null? args) (show-all-vars)) + ((null? (cdr args)) (show-var (car args))) + (else (display-line-error "Usage: " program-name " info [VAR]") + (quit 2)))) + +(define (show-all-vars) + (for-each (lambda (binding) + (display-line (car binding) " = " (cdr binding))) + %guile-build-info)) + +(define (show-var var) + (display (get-build-info (string->symbol var))) + (newline)) + +(define (help-info) + (let ((dle display-line-error)) + (dle "Usage: " program-name " info [VAR]") + (dle "Display the value of the Makefile variable VAR used when Guile") + (dle "was built. If VAR is omitted, display all Makefile variables.") + (dle "Use this command to find out where Guile was installed,") + (dle "where it will look for Scheme code at run-time, and so on."))) + + + +;;;; trivial utilities + +(define (get-build-info name) + (let ((val (assq name %guile-build-info))) + (if (not (pair? val)) + (begin + (display-line-error + program-name " " subcommand-name ": no such build-info: " name) + (quit 2))) + (cdr val))) + +(define (display-line . args) + (apply display-line-port (current-output-port) args)) + +(define (display-line-error . args) + (apply display-line-port (current-error-port) args)) + +(define (display-line-port port . args) + (for-each (lambda (arg) (display arg port)) + args) + (newline)) + +(define (display-separated args) + (let loop ((args args)) + (cond ((null? args)) + ((null? (cdr args)) (display (car args))) + (else (display (car args)) + (display " ") + (loop (cdr args)))))) + + +;;;; the command table + +;;; We define this down here, so Guile builds the list after all the +;;; functions have been defined. +(define command-table + (list + (list "--version" show-version show-help-overview) + (list "--help" show-help show-help-overview) + (list "link" build-link help-link) + (list "main" build-main help-main) + (list "info" build-info help-info))) + + + + +;;; Local Variables: +;;; mode: scheme +;;; End: