Gambit and Automake
I'm using Automake -- and Autoconf FWIW -- to compile gambit programs and I wonder if anyone else is doing it. I've setup a Makefile.am but I'm not very happy with it. I fell that there probably is a better way. Is anyone doing it? I know I could have done something like: foo: $(foo_SOURCES) gsc -o $@ -exe $^ But I wanted something more fine grained. Well, here goes my Makefile.am: LDFLAGS = -lgambc -lm -ldl -lutil bin_PROGRAMS = foo foo_SOURCES = foo.scm linker.c CLEANFILES=linker.c .scm.o: LINK=gcc -o $@ $(LDFLAGS) %.o: %.scm linker.c gsc -obj $< linker.c: $(filter %.scm,$(foo_SOURCES)) gsc -o $@ -link $^ -- Diogo F. S. Ramos
Afficher les réponses par date
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).
Marc Feeley <feeley@iro.umontreal.ca> writes:
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.
Great! Thank you. -- Diogo F. S. Ramos
Marc Feeley <feeley@iro.umontreal.ca> writes:
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.
The file 'main.c' from 'misc/simple-make-project.tgz' has ___VERSION set to 406000 at 'gambc-v4_6_1-devel.tgz' distribution, so gsc refuses to build it. Changing to 406001 fixes it. -- Diogo F. S. Ramos
participants (2)
-
Diogo F. S. Ramos -
Marc Feeley