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

(define Makefile.rules "Makefile.rules")

(define mzc "MZC=/usr/local/plt/bin/mzc")
(define libdir (format "LIBDIR = ~a" (system-path)))

(define 3m-rules "
SOURCES = _constants.c _socket.c
XSOURCES = $(SOURCES:.c=.3m.c)
OBJECTS = _constants_3m.o _socket_3m.o
LIBS = _constants_ss.so _socket_ss.so
libs: libdir xform $(OBJECTS) $(LIBS)

xform: $(XSOURCES)

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

_constants_3m.o: _constants.3m.c
	$(MZC) --3m --cc $<
_socket_3m.o: _socket.3m.c
	$(MZC) --3m --cc $<
_constants_ss.so: _constants_3m.o
	$(MZC) --3m --ld $(LIBDIR)/$@ $<
_socket_ss.so: _socket_3m.o
	$(MZC) --3m --ld $(LIBDIR)/$@ $<
")

#;(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 #:exists 'truncate)))
  (printf "## Autogenerated by Makefile.rules.ss~n")
  (printf "~a~n" mzc)
  (printf "~a~n" libdir)
  (case (gc-type)
     ((3m) (display 3m-rules))
     ;;((cgc) (display cgc-rules))
     ;;((old-cgc) (display old-cgc-rules)))
     (else (error 'Makefile.rules "FIXME: gc"))))