gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] Makefile to compile Modula code


From: dukeofperl
Subject: Re: [Gm2] Makefile to compile Modula code
Date: Thu, 21 Oct 2010 12:39:58 -0600 (MDT)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Thu, 21 Oct 2010, Duke Normandin wrote:

> On Thu, 21 Oct 2010, Gaius Mulley wrote:
>
> > Duke Normandin <address@hidden> writes:
> >
> > > Hello Gaius and list...
> > >
> > > @Gaius
> > >
> > > How good are you at creating Makefiles?
> > >
> > > I have a Makefile that I use to compile Oberon-2 code which works very
> > > well. I adapted it to gm2, but I can't get the bloody thing to create
> > > the object file using gm2. Are you up to having a look at this
> > > Makefile?
> >
> > Hi Duke,
> >
> > yes sure, post the Makefile..

Here's the latest and greatest, and it seems to work OK. Please, all
of you in gm2 userland, try it out and let me know if it bombs out.

[code]
# Generic Makefile for use with Gaius Mulley's
#              GNU Modula-2 Compiler
# Author: Duke Normandin - address@hidden
# with the help of:
#       Edward Welbourne eddy(at)chaos(dot)org(dot)uk
#       Henrik Carlqvist hc123(at)poolhem.se
# 5 Oct. 2010 -> 1st edition
#
# If you make improvements, please forward me a
# copy, so that I too can get a clue. Thanks!
# enjoy!

define assert
$(call assert,$($ARGS), The variable "$ARGS" is null)
endef

# save CLI arguments
EXEC-FILE = $(word 1, $(ARGS))
SRCS = $(wordlist 2, 999, $(ARGS))

# The GM2 Compiler is pretty simple to operate
#
# to compile a 1+ modules "long-hand" would require:
# gm2 -c module-1.mod
# gm2 -c module-2.mod
# gm2 -o exec-file module-1.o module-2.o
#

LINK = gm2
MODULA = gm2 -c


# Rule #1 generate the executable file from its dependencies (source files)
# In turn generate the object code (.o files) from its like-named source (.mod) 
file
# Using the command on the TAB-indented line
$(EXEC-FILE): $(SRCS:%.mod=%.o)
        $(LINK) $(SRCS) -o $@

# Rule #2 generate the object code (.o files) from its like-named source (.mod) 
file
# Using the command on the TAB-indented line
%.o:%.mod
        $(MODULA) $<

.PHONY: usage
usage:
        @echo "Usage:"
        @echo "make ARGS=\"exec-file src-1.mod scr-2.mod ... src-n.mod\""
        @echo "Make sure that the IMPORTed modules precede the \"main\" module"
        @echo "in the command line ARGS. Enjoy!"

.PHONY: clean
clean:
        rm -rf *.o
[/code]

-- 
Duke



reply via email to

[Prev in Thread] Current Thread [Next in Thread]