PCN_BASE = /usr/local/pcn_2.0
TARGET = default
FLAVOR =
PCNCOMP = $(PCN_BASE)/bin/pcncomp
PCNCOMPFLAGS = $(FLAVOR) -target $(TARGET)

TEST = 
PAMS = $(TEST).pam
OBJS = 
PCNT = pcnt_$(TEST)
MAIN_MOD = $(TEST)
PROG_NAME = $(TEST)

all: $(PROG_NAME)

pams: $(PAMS)

$(PCNT).c: $(PAMS)
	$(PCNCOMP) $(PCNCOMPFLAGS) $(PAMS) -o $(PCNT).c -pcnt \
		-mm $(MAIN_MOD) -v

$(PROG_NAME): $(PCNT).o $(OBJS)
	$(PCNCOMP) $(PCNCOMPFLAGS) $(PCNT).o $(OBJS) -o $(PROG_NAME)

.SUFFIXES: .pcn .pam .c .o .f

.pcn.pam:
	$(PCNCOMP) $(PCNCOMPFLAGS) -c $*.pcn

.c.o:
	$(PCNCOMP) $(PCNCOMPFLAGS) -c $*.c

.f.o:
	$(PCNCOMP) $(PCNCOMPFLAGS) -c $*.f

SUBDIRS = \
	VT \
	array_overrun \
	circle \
	float \
	fortran \
	generic \
	life \
	linker \
	loop \
	sys_test

clean:
	rm -f *.pam *.mod *~ $(PROG_NAME) *.dump pcnt* *.o

clean_subdirs:
	for i in $(SUBDIRS) ; do \
		(cd $${i}; echo "Cleaning $${i}"; make clean) ; \
	done
