On 2011-04-01, at 7:12 PM, Diogo F. S. Ramos wrote:
I'm using Automake -- and Autoconf FWIW -- to compile gambit programs and I wonder if anyone else is doing it.
There is a sample makefile in misc/simple-make-project.tgz in the Gambit distribution. It shows one way to write a makefile for separately compiling a project containing Scheme code and C code.
Marc
# Simple makefile for project built with Gambit-C system.
# Copyright (c) 2010 by Marc Feeley, All Rights Reserved.
# This makefile is designed to depend only on the gsc compiler. The # gsc compiler will invoke the appropriate C compiler and linker, even # for compiling the C source files of the project. This makes this # makefile very portable as many system dependencies have been taken # care of when Gambit was installed. If gsc isn't installed in a # standard location, define GSC accordingly here:
GSC = gsc
# You should redefine C_MODULES and SCHEME_MODULES as needed for your # project. Define ALL_MODULES_O as the set of object files for the C # and Scheme modules. Define PROG_NAME as the program name.
PROG_NAME = prog C_MODULES = mod1.c mod2.c main.c SCHEME_MODULES = mod3.scm mod4.scm SCHEME_MODULES_C = mod3.c mod4.c ALL_MODULES_O = mod1.o mod2.o main.o mod3.o mod4.o
# You may want to add stuff to CC_OPTIONS and LD_OPTIONS (directories # for header files, libraries, etc). You must keep -D___LIBRARY in # CC_OPTIONS so that the compiled Scheme code does not implement its # own "main" function (in the link file generated by gsc).
CC_OPTIONS = -D___LIBRARY LD_OPTIONS =
# The rest of the makefile shouldn't need to be modified.
GSC_OPTIONS = -cc-options "$(CC_OPTIONS)" -ld-options "$(LD_OPTIONS)" #GSC_OPTIONS = -cc-options "$(CC_OPTIONS)" -ld-options "$(LD_OPTIONS)" -verbose ALL_MODULES_C = $(C_MODULES) $(SCHEME_MODULES_C) ALL_MODULES = $(C_MODULES) $(SCHEME_MODULES)
.SUFFIXES: .SUFFIXES: .scm .c .o
all: $(PROG_NAME)
$(PROG_NAME): $(ALL_MODULES_O) $(PROG_NAME)_.o $(GSC) $(GSC_OPTIONS) -exe -o $@ $^
$(PROG_NAME)_.c: $(SCHEME_MODULES_C) $(GSC) -link -o $@ $^
.c.o: $(GSC) $(GSC_OPTIONS) -obj $^
.scm.c: $(GSC) $(GSC_OPTIONS) -c $^
run: $(PROG_NAME) ./$(PROG_NAME)
clean: rm -f $(SCHEME_MODULES_C) $(ALL_MODULES_O) $(PROG_NAME)_.* $(PROG_NAME)
# Note: It is possible to compile and link a program in a single # invocation of gsc but this is not recommended for large projects # which usually benefit from separate compilation. The command is: # # $(GSC) $(GSC_OPTIONS) -exe -o $(PROG_NAME) $(ALL_MODULES) # # Moreover, this requires changing the name of the link file in main.c # from prog_.c to mod4_.c (the name is derived from the last Scheme # source file in ALL_MODULES).