# User configuration for this example: change language and script file name
# Prefix is where fungw is installed
PREFIX=/usr/local/lib
SCLANG=fawk
SCRIPT_FN=../00_hello/hello.fawk
#CFLAGS_DBG = -g -Wall

# this variable-in-variable needs a fairly recent make implementation
# should work with GNU make and any modern BSD make. In a more portable
# project the available libs are detected in ./configure and these can
# be generated.
LDFLAGS_SCRIPT = -lfungw_$(SCLANG) $(LDFLAGS_fungw_$(SCLANG))
CFLAGS_SCRIPT = $(CFLAGS_fungw_$(SCLANG))

include $(PREFIX)/puplug/fungw_$(SCLANG).mak
FUNGW=$(PREFIX)/fungw

# You have to have genht installed too
LDFLAGS_FUNGW=-lfungw -lgenht 

# this is how language and script file name is passed in for the example code
# so it doesn't need to do any parsing or run-time decision
CFLAGS_LANG = \
	-DSCLANG=$(SCLANG) \
	-DSCLANG_STR=\"$(SCLANG)\" \
	-DSCRIPT_FN=\"$(SCRIPT_FN)\"

all: hello

hello: hello.o
	$(CC) -o hello hello.o $(LDFLAGS) $(LDFLAGS_SCRIPT) $(LDFLAGS_FUNGW) -lm $(LDLIBS)

hello.o: hello.c Makefile
	$(CC) -c $(CFLAGS) $(CFLAGS_LANG) $(CFLAGS_SCRIPT) $(CFLAGS_DBG) -o hello.o hello.c

clean:
	-rm hello hello.o 2>/dev/null
