Makefile 1.32 KB
SRC =	        
OBJ = 		flatzinc.tab.o
GENCFILES = 	flatzinc.tab.c lex.yy.c 
OTHER = 	flatzinc.output 

PLFILES =       $(filter-out out-%.pl,$(wildcard *.pl))
PLOFILES =   	$(patsubst %.pl,%.o,$(PLFILES))

# XXX/output.pl produces fz-XXX, the flatzinc-to-XXX compiler
FZBACKS =       $(patsubst %/output.pl,%,$(wildcard */output.pl))
FZSEM =  	$(patsubst %/output.pl,fz-%,$(wildcard */output.pl))
FZPLFILES =     $(foreach B,$(FZBACKS),$(wildcard $B/*.pl))
FZOFILES =      $(patsubst %.pl,%.o,$(FZPLFILES))
FZAFILES =      $(patsubst %,lib%.a,$(FZBACKS))

# NOTE: we need to pass the `-l' flag to ensure the scanner internal
# variable `yylineno' is available.
#
LEX =		flex
LEXFLAGS =      -l
LEXLIB =	

YACC =		bison
YACCFLAGS =	-v

CC =		gcc	
CFLAGS =	-g -O

GPLC =		gplc

RM =		/bin/rm -f

%.ast:: %.fzn
	fzp < $< > $@

all: fzp $(FZSEM) $(PLOFILES) $(FZOFILES) $(FZAFILES)

fzp:	$(OBJ)
	$(CC) $(CFLAGS) -o $@ $(OBJ) $(LEXLIB)

fz-%:	$(PLOFILES) lib%.a
	$(GPLC) -o $@ $+

lib%.a: $(FZOFILES)
	ar rv $@ $+

%.o: %.pl
	$(GPLC) $(GPLCFLAGS) -c $<

flatzinc.tab.c:	flatzinc.y lex.yy.c
	$(YACC) $(YACCFLAGS) flatzinc.y

lex.yy.c:	flatzinc.l
	$(LEX) $(LEXFLAGS) flatzinc.l

clean:
	$(RM)					\
	  $(OBJ) $(PLOFILES)			\
	  $(FZOFILES) $(FZAFILES)		\
	  $(GENCFILES) $(OTHER) core

clobber:	clean
	$(RM) $(EXE_FILE)

.PHONY: distclean
distclean: clobber