2009-03-27 16:11:43 -07:00
|
|
|
|
#!/bin/sh
|
2009-09-23 22:45:07 +02:00
|
|
|
|
PKG_CONFIG_PATH="@pkgconfigdir@:$PKG_CONFIG_PATH"
|
|
|
|
|
|
GUILE_AUTO_COMPILE=0
|
|
|
|
|
|
export PKG_CONFIG_PATH GUILE_AUTO_COMPILE
|
|
|
|
|
|
|
|
|
|
|
|
exec "@installed_guile@" -e main -s $0 "$@"
|
1998-10-03 18:45:14 +00:00
|
|
|
|
!#
|
|
|
|
|
|
;;;; guile-config --- utility for linking programs with Guile
|
|
|
|
|
|
;;;; Jim Blandy <jim@red-bean.com> --- September 1997
|
1998-10-09 15:12:40 +00:00
|
|
|
|
;;;;
|
2009-08-15 12:05:36 +02:00
|
|
|
|
;;;; Copyright (C) 1998, 2001, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
|
1998-10-09 15:12:40 +00:00
|
|
|
|
;;;;
|
2003-04-05 19:15:35 +00:00
|
|
|
|
;;;; This library is free software; you can redistribute it and/or
|
|
|
|
|
|
;;;; modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
;;;; License as published by the Free Software Foundation; either
|
2009-06-17 00:22:09 +01:00
|
|
|
|
;;;; version 3 of the License, or (at your option) any later version.
|
1998-10-09 15:12:40 +00:00
|
|
|
|
;;;;
|
2003-04-05 19:15:35 +00:00
|
|
|
|
;;;; This library is distributed in the hope that it will be useful,
|
1998-10-09 15:12:40 +00:00
|
|
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
;;;; Lesser General Public License for more details.
|
1998-10-09 15:12:40 +00:00
|
|
|
|
;;;;
|
2003-04-05 19:15:35 +00:00
|
|
|
|
;;;; You should have received a copy of the GNU Lesser General Public
|
2009-06-17 00:22:09 +01:00
|
|
|
|
;;;; License along with this library; if not, write to the Free
|
|
|
|
|
|
;;;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
|
;;;; Boston, MA 02110-1301 USA
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
2009-04-06 11:07:22 -07:00
|
|
|
|
;;; This script has been deprecated. Just use pkg-config.
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
2009-04-06 11:07:22 -07:00
|
|
|
|
(use-modules (ice-9 popen)
|
|
|
|
|
|
(ice-9 rdelim))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
2009-09-23 22:45:07 +02:00
|
|
|
|
(define %pkg-config-program "@PKG_CONFIG@")
|
|
|
|
|
|
|
1998-10-03 18:45:14 +00:00
|
|
|
|
;;;; 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)
|
|
|
|
|
|
|
|
|
|
|
|
;;; 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)
|
1998-10-03 20:58:41 +00:00
|
|
|
|
(set! program-name (basename path)))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
(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)
|
1998-10-05 18:52:23 +00:00
|
|
|
|
(display-line-error "Usage: ")
|
|
|
|
|
|
(for-each (lambda (row) ((cadddr row)))
|
|
|
|
|
|
command-table))
|
|
|
|
|
|
|
|
|
|
|
|
(define (usage-help)
|
|
|
|
|
|
(let ((dle display-line-error)
|
|
|
|
|
|
(p program-name))
|
|
|
|
|
|
(dle " " p " --help - show usage info (this message)")
|
|
|
|
|
|
(dle " " p " --help SUBCOMMAND - show help for SUBCOMMAND")))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
2009-08-15 12:05:36 +02:00
|
|
|
|
(define guile-module "guile-2.0")
|
2009-04-06 11:07:22 -07:00
|
|
|
|
|
|
|
|
|
|
(define (pkg-config . args)
|
2009-09-23 22:45:07 +02:00
|
|
|
|
(let* ((real-args (cons %pkg-config-program args))
|
2009-04-06 11:07:22 -07:00
|
|
|
|
(pipe (apply open-pipe* OPEN_READ real-args))
|
|
|
|
|
|
(output (read-delimited "" pipe))
|
|
|
|
|
|
(ret (close-pipe pipe)))
|
|
|
|
|
|
(case (status:exit-val ret)
|
|
|
|
|
|
((0) (if (eof-object? output) "" output))
|
2009-04-21 12:41:19 +02:00
|
|
|
|
(else (display-line-error
|
|
|
|
|
|
(format #f "error: ~s exited with non-zero error code ~A"
|
2009-09-23 22:45:07 +02:00
|
|
|
|
(cons %pkg-config-program args) (status:exit-val ret)))
|
2009-04-21 12:41:19 +02:00
|
|
|
|
;; assume pkg-config sent diagnostics to stdout
|
|
|
|
|
|
(exit (status:exit-val ret))))))
|
2009-04-06 11:07:22 -07:00
|
|
|
|
|
1998-10-03 18:45:14 +00:00
|
|
|
|
(define (show-version args)
|
2009-04-06 11:07:22 -07:00
|
|
|
|
(format (current-error-port) "~A - Guile version ~A"
|
|
|
|
|
|
program-name (pkg-config "--modversion" guile-module)))
|
1998-10-05 18:52:23 +00:00
|
|
|
|
|
|
|
|
|
|
(define (help-version)
|
|
|
|
|
|
(let ((dle display-line-error))
|
|
|
|
|
|
(dle "Usage: " program-name " --version")
|
|
|
|
|
|
(dle "Show the version of this script. This is also the version of")
|
|
|
|
|
|
(dle "Guile this script was installed with.")))
|
|
|
|
|
|
|
|
|
|
|
|
(define (usage-version)
|
|
|
|
|
|
(display-line-error
|
|
|
|
|
|
" " program-name " --version - show installed script and Guile version"))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; 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)
|
2009-04-06 11:07:22 -07:00
|
|
|
|
(display (apply pkg-config "--libs" guile-module args)))
|
2004-10-08 09:46:23 +00:00
|
|
|
|
|
1998-10-03 18:45:14 +00:00
|
|
|
|
(define (help-link)
|
|
|
|
|
|
(let ((dle display-line-error))
|
|
|
|
|
|
(dle "Usage: " program-name " link")
|
|
|
|
|
|
(dle "Print linker flags for building the `guile' executable.")
|
1998-10-05 18:52:23 +00:00
|
|
|
|
(dle "Print the linker command-line flags necessary to link against")
|
|
|
|
|
|
(dle "the Guile library, and any other libraries it requires.")))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
1998-10-05 18:52:23 +00:00
|
|
|
|
(define (usage-link)
|
|
|
|
|
|
(display-line-error
|
|
|
|
|
|
" " program-name " link - print libraries to link with"))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
1998-10-05 18:52:23 +00:00
|
|
|
|
|
|
|
|
|
|
;;;; The "compile" subcommand
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
1998-10-05 19:00:07 +00:00
|
|
|
|
(define (build-compile args)
|
2009-04-06 11:07:22 -07:00
|
|
|
|
(display (apply pkg-config "--cflags" guile-module args)))
|
1998-10-05 19:00:07 +00:00
|
|
|
|
|
|
|
|
|
|
(define (help-compile)
|
|
|
|
|
|
(let ((dle display-line-error))
|
|
|
|
|
|
(dle "Usage: " program-name " compile")
|
|
|
|
|
|
(dle "Print C compiler flags for compiling code that uses Guile.")
|
|
|
|
|
|
(dle "This includes any `-I' flags needed to find Guile's header files.")))
|
|
|
|
|
|
|
|
|
|
|
|
(define (usage-compile)
|
|
|
|
|
|
(display-line-error
|
|
|
|
|
|
" " program-name " compile - print C compiler flags to compile with"))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; The "info" subcommand
|
|
|
|
|
|
|
|
|
|
|
|
(define (build-info args)
|
|
|
|
|
|
(cond
|
2009-04-06 11:07:22 -07:00
|
|
|
|
((null? args)
|
|
|
|
|
|
(display-line-error "guile-config info with no args has been removed")
|
|
|
|
|
|
(quit 2))
|
|
|
|
|
|
((null? (cdr args))
|
|
|
|
|
|
(cond
|
|
|
|
|
|
((string=? (car args) "guileversion")
|
|
|
|
|
|
(display (pkg-config "--modversion" guile-module)))
|
|
|
|
|
|
(else
|
2009-04-20 17:42:35 +02:00
|
|
|
|
(display (pkg-config (format #f "--variable=~A" (car args))
|
|
|
|
|
|
guile-module)))))
|
2009-04-06 11:07:22 -07:00
|
|
|
|
(else (display-line-error "Usage: " program-name " info VAR")
|
1998-10-03 18:45:14 +00:00
|
|
|
|
(quit 2))))
|
|
|
|
|
|
|
|
|
|
|
|
(define (help-info)
|
1998-10-05 18:52:23 +00:00
|
|
|
|
(let ((d display-line-error))
|
2009-04-06 11:07:22 -07:00
|
|
|
|
(d "Usage: " program-name " info VAR")
|
|
|
|
|
|
(d "Display the value of the pkg-config variable VAR used when Guile")
|
|
|
|
|
|
(d "was built.\n")
|
1998-10-05 18:52:23 +00:00
|
|
|
|
(d "Use this command to find out where Guile was installed,")
|
|
|
|
|
|
(d "where it will look for Scheme code at run-time, and so on.")))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
1998-10-05 18:52:23 +00:00
|
|
|
|
(define (usage-info)
|
|
|
|
|
|
(display-line-error
|
2009-04-06 11:07:22 -07:00
|
|
|
|
" " program-name " info VAR - print Guile build directories"))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; trivial utilities
|
|
|
|
|
|
|
|
|
|
|
|
(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)
|
2000-11-01 16:13:38 +00:00
|
|
|
|
(newline port))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; the command table
|
|
|
|
|
|
|
|
|
|
|
|
;;; We define this down here, so Guile builds the list after all the
|
|
|
|
|
|
;;; functions have been defined.
|
|
|
|
|
|
(define command-table
|
|
|
|
|
|
(list
|
1998-10-05 18:52:23 +00:00
|
|
|
|
(list "--version" show-version help-version usage-version)
|
|
|
|
|
|
(list "--help" show-help show-help-overview usage-help)
|
|
|
|
|
|
(list "link" build-link help-link usage-link)
|
|
|
|
|
|
(list "compile" build-compile help-compile usage-compile)
|
|
|
|
|
|
(list "info" build-info help-info usage-info)))
|
1998-10-03 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Local Variables:
|
|
|
|
|
|
;;; mode: scheme
|
|
|
|
|
|
;;; End:
|