stk/Extensions/stk-genmake.in

81 lines
2.6 KiB
Scheme

#!/bin/sh
:;exec snow -f "$0" "$@" # -*- Scheme -*-
;;;;
;;;;
;;;; stk-genmake -- Generate a Makefile for STk extensions
;;;;
;;;; Copyright © 1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;; Permission to use, copy, and/or distribute this software and its
;;;; documentation for any purpose and without fee is hereby granted, provided
;;;; that both the above copyright notice and this permission notice appear in
;;;; all copies and derived works. Fees for distribution or use of this
;;;; software or derived works may only be charged with express written
;;;; permission of the copyright holder.
;;;; This software is provided ``as is'' without express or implied warranty.
;;;;
;;;; $Id: stk-genmake.in 1.1 Sat, 06 Jun 1998 14:19:03 +0200 eg $
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 1-Jun-1998 18:44
;;;; Last file update: 2-Jun-1998 17:51
(define version "0.1")
(define config.make-file ; Complete path name of the Config.make file
(string-append (%library-location) "/" (machine-type) "/Config/config.make"))
(define (abort . l)
(apply format (current-error-port) l)
(newline (current-error-port))
(exit 0))
(define (generate-prelude targets)
(format #t "# Makefile automatically generated by ~A version ~A. DO NOT EDIT\n"
*program-name* version)
(if (file-exists? config.make-file)
;; Copy the content of config.make
(with-input-from-file config.make-file
(lambda ()
(do ((l (read-line) (read-line)))
((eof-object? l) l)
(format #t "~A\n" l))))
;; config.make doesn't exists
(abort "~A: File ~S does not exist (you probably need a \"make install.libs\""
*program-name*))
;; Generate the .SUFFIXES rules
(format #t "CFLAGS= $(SH_CCFLAGS) $(STKCFLAGS) $(DFLGS) -DUSE_TK @DEFS@ \\\n")
(format #t "-I$(incdir)\n\n\n")
(format #t ".SUFFIXES: .$(SH_SUFFIX) .o .c\n\n")
(format #t ".o.$(SH_SUFFIX):\n")
(format #t "\t$(SH_LOADER) $(SH_LDFLAGS) $*.$(SH_SUFFIX) $<\n")
(format #t "\tif test -f a.out ;then mv a.out $*.$(SH_SUFFIX); fi\n\n")
;; Generate the main target
(format #t "\nall:\t")
(for-each (lambda (x) (format #t "~A.$(SH_SUFFIX) " x)) targets)
(format #t "\n\n"))
(define (generate-target target)
(format #t "\n~A.$(SH_SUFFIX): ~A.o\n\n" target target))
(define (generate-postlude)
(format #t "clean:\n")
(format #t "\t@/bin/rm -f *.o *.$(SH_SUFFIX) core *~\n")
(format #t "#End of Makefile\n"))
;;;;
;;;; Program starts here
;;;;
(if (zero? *argc*)
(abort "Usage: ~A target [target ...]" *program-name*))
(generate-prelude *argv*)
(for-each generate-target *argv*)
(generate-postlude)