Makefile.rules.ss
;; mzsocket: BSD/POSIX sockets library for mzscheme
;; Copyright (C) 2007 Dimitris Vyzovitis <vyzo@media.mit.edu>
;;
;; 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
;; version 2.1 of the License, or (at your option) any later version.
;;
;; This library 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
;; Lesser General Public License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public
;; License along with this library; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
;; USA

(require (only "install.ss" system-path gc-type))

(define Makefile.rules "Makefile.rules")

(define libdir (format "LIBDIR = ~a" (system-path)))

(define 3m-rules "
libs: libdir xform $(OBJECTS) $(LIBS)

xform: $(XSOURCES)

%.3m.c: %.c $(PRE)
	mzc --3m --xform $<

%.o: %.3m.c
	mzc --3m --cc $<

%.so: %.o
	mzc --3m --ld $(LIBDIR)/$@ $<

")

(define cgc-rules "
libs: libdir $(OBJECTS) $(LIBS)

%.o: %.c $(PRE)
	mzc --cgc --cc $<

%.so: %.o
	mzc --cgc --ld $(LIBDIR)/$@ $<
")

(define old-cgc-rules "
libs: libdir $(OBJECTS) $(LIBS)

%.o: %.c $(PRE)
	mzc --cc $<

%.so: %.o
	mzc --ld $(LIBDIR)/$@ $<
")

(parameterize 
    ((current-output-port (open-output-file Makefile.rules 'truncate)))
  (printf "## Autogenerated by Makefile.rules.ss~n")
  (printf "~a~n" libdir)
  (case (gc-type)
     ((3m) (display 3m-rules))
     ((cgc) (display cgc-rules))
     ((old-cgc) (display old-cgc-rules))))