Codebase list libmawk / debian/1.0.1-1 scconfig / src / tmpasm / regression / test.gasm
debian/1.0.1-1

Tree @debian/1.0.1-1 (Download .tar.gz)

test.gasm @debian/1.0.1-1raw · history · blame

### set up internal variables ###
put /local/cflags {-std=c99 -Wall}
put /local/ldflags {-lm}
put /local/objs {main.o foo.o bar.o}

# turn off optimization and add -g in debug mode
if /local/debug then
	append /local/cflags {-g}
else
	append /local/cflags {-O2}
end

# if somelib is selected, add -I and -l
isempty /local/r /local/somelib
invert  /local/r
if /local/r then
	append /local/cflags { -I/usr/include/somelib}
	append /local/ldflags { -lsomelib}
end

### Generate the Makefile ###
print [@
# Makefile generated by scconfig - DO NOT EDIT - please edit Makefile.in
CFLAGS=@/local/cflags@
LDFLAGS=@/local/ldflags@
OBJS=@/local/objs@

all: main

main: $(OBJS)
	$(CC) $(LDFLAGS)

@]

# loop over each object and generate an explicit rule
# (we are generating a dumb Makefile that would work with any
# old version of make)
foreach /local/o in /local/objs
	put /local/c /local/o
	sub /local/c {.o$} {.c}
	print [@
@/local/o@: @/local/c@
	$(CC) -c $(CFLAGS) @/local/c@ -o @/local/o@
	@]
end

print {#end\n}