CPC=lisp -core /usr/local/lib/cpc.core 
# CPC=clisp -M/usr/local/lib/cpc.mem

CFLAGS=-O3 -Wall -I../runtime -g

LDLIBS=-lcpc /usr/local/lib/cpc_runtime.o -pthread

LDFLAGS = -lst
				       
.SUFFIXES: .cpc .cpi

.PHONY: all

all: barrier conditions done fork loops sleep sleep_cond tcat \
     trivial-httpd trivial-httpd-fork trivial-httpd-nptl trivial-httpd-st\
     static-httpd static-httpd-fork static-httpd-nptl static-httpd-st\
	 trivial-httpd-pth static-httpd-pth

clean:
	rm -f *.o *~ *.cpi
	rm -f barrier conditions done fork loops sleep sleep_cond tcat \
	 trivial-httpd trivial-httpd-fork trivial-httpd-nptl trivial-httpd-st\
 	 static-httpd static-httpd-fork static-httpd-nptl static-httpd-st\
	 trivial-httpd-pth static-httpd-pth

barrier: barrier.o

conditions: conditions.o

done: done.o

fork: fork.o

loops: loops.o

sleep: sleep.o

sleep_cond: sleep_cond.o

tcat: tcat.o

trivial-httpd: trivial-httpd.o

trivial-httpd-fork: trivial-httpd-fork.o

trivial-httpd-st: trivial-httpd-st.o

trivial-httpd-pth: trivial-httpd-pth.o

trivial-httpd-nptl: trivial-httpd-nptl.o

static-httpd: static-httpd.o

static-httpd-fork: static-httpd-fork.o

static-httpd-st: static-httpd-st.o

static-httpd-pth: static-httpd-pth.o

static-httpd-nptl: static-httpd-nptl.o

static-httpd.cpi: trivial-httpd.cpc
	$(CC) -E -P $(CFLAGS) -D__extension__= -D'__attribute__(x)=' \
	-DSTATIC - <$< >$@

static-httpd-fork.o: trivial-httpd-fork.c
	$(CC) -DSTATIC -o $@  -c $(CFLAGS) trivial-httpd-fork.c

static-httpd-st.o: trivial-httpd-st.c
	$(CC) -DSTATIC -o $@ -c $(CFLAGS) trivial-httpd-st.c

static-httpd-pth.o: trivial-httpd-pth.c
	$(CC) -DSTATIC -o $@ -c $(CFLAGS) trivial-httpd-pth.c

static-httpd-nptl.o: trivial-httpd-nptl.c
	$(CC) -DSTATIC -o $@ -c $(CFLAGS) trivial-httpd-nptl.c

.PHONY: clean
	-rm -f *.cpi

.cpc.cpi:
	$(CC) -E -P $(CFLAGS) -D__extension__= -D'__attribute__(x)=' - \
	    <$< >$@

.cpi.c:
	$(CPC) $< $@

