
# TYPE is either debug, prof, static or the empty string
TYPE = 

# comment (or uncomment) the following line if hash_map is not found
SGILIB = -DSGIext

#AC = -DPRINT_ASSOC_SCORES

CXX = g++
WARNING = -Wall -Wcast-qual -Wconversion -Wno-deprecated

ifeq ($(TYPE),debug)
  DEBUG = -ggdb
  OPTIMIZATION = -O0
else
  DEBUG = -DNDEBUG
  ifeq ($(TYPE),prof)
    OPTIMIZATION = -O2
    PROFILE = -pg
  else
    OPTIMIZATION = -O3 -ffast-math
    ifeq ($(TYPE),static)
      STATIC = -static
    endif
  endif
endif

CFLAGS = $(DEBUG) $(PROFILE) $(OPTIMIZATION) $(WARNING) $(SGILIB) $(BITS) $(AC)
LDFLAGS = $(DEBUG) $(PROFILE) $(STATIC) $(LOPT)

CXXFLAGS = $(CFLAGS)
LXXFLAGS = $(LDFLAGS)

PROGRAM = bitpar


OBJ = grammar.o lexicon.o apply.o po-apply.o bitop.o baseparser.o process.o \
	estimate-freqs.o parser.o vitparser.o bitpar.o traces.o wordclass.o \
	quote.o tree.o scanner.o retagging.o lexicalize.o nbest.o

.PHONY: all clean realclean archive

all: $(PROGRAM)

bitpar: $(OBJ)

tree.o: tree.C

tree.C: tree.y
	bison -d -b y ${YFLAGS} $^
	mv y.tab.c $@

scanner.o: scanner.C

scanner.C: scanner.l
	flex -t $^ > $@

%: $(OBJ) %.o
	$(CXX) -o $@ $^ $(LDFLAGS)


clean:
	-rm -f y.tab.h y.output scanner.C tree.C *.o *~ Makefile.bak man1/*~ 2>&- > /dev/null

realclean: clean
	-rm -f $(PROGRAM) 2>&- > /dev/null

archive: 
	-gtar -zhcf BITPAR-`date '+%y%m%d'`.tar.gz *.[Chyl] Makefile man1/*

Makefile: *.C *.h
	-makedepend -Y -- $(CFLAGS) -- *.C 2>/dev/null 


# DO NOT DELETE

apply.o: parser.h baseparser.h lexicon.h string-set.h grammar.h bitop.h
apply.o: traces.h symbol-table.h prob.h wordclass.h
baseparser.o: baseparser.h lexicon.h string-set.h grammar.h bitop.h traces.h
baseparser.o: symbol-table.h prob.h wordclass.h
bitop.o: bitop.h
bitpar.o: parser.h baseparser.h lexicon.h string-set.h grammar.h bitop.h
bitpar.o: traces.h symbol-table.h prob.h wordclass.h vitparser.h retagging.h
bitpar.o: tree.h
estimate-freqs.o: parser.h baseparser.h lexicon.h string-set.h grammar.h
estimate-freqs.o: bitop.h traces.h symbol-table.h prob.h wordclass.h
grammar.o: basic-functions.h grammar.h bitop.h traces.h symbol-table.h prob.h
lexicalize.o: parser.h baseparser.h lexicon.h string-set.h grammar.h bitop.h
lexicalize.o: traces.h symbol-table.h prob.h wordclass.h
lexicon.o: lexicon.h string-set.h grammar.h bitop.h traces.h symbol-table.h
lexicon.o: prob.h wordclass.h
nbest.o: quote.h parser.h baseparser.h lexicon.h string-set.h grammar.h
nbest.o: bitop.h traces.h symbol-table.h prob.h wordclass.h
parser.o: parser.h baseparser.h lexicon.h string-set.h grammar.h bitop.h
parser.o: traces.h symbol-table.h prob.h wordclass.h print.h quote.h
parser.o: print-YAP.h
po-apply.o: parser.h baseparser.h lexicon.h string-set.h grammar.h bitop.h
po-apply.o: traces.h symbol-table.h prob.h wordclass.h
process.o: parser.h baseparser.h lexicon.h string-set.h grammar.h bitop.h
process.o: traces.h symbol-table.h prob.h wordclass.h
retagging.o: retagging.h baseparser.h lexicon.h string-set.h grammar.h
retagging.o: bitop.h traces.h symbol-table.h prob.h wordclass.h tree.h
scanner.o: tree.h y.tab.h
traces.o: parser.h baseparser.h lexicon.h string-set.h grammar.h bitop.h
traces.o: traces.h symbol-table.h prob.h wordclass.h
tree.o: tree.h
vitparser.o: vitparser.h baseparser.h lexicon.h string-set.h grammar.h
vitparser.o: bitop.h traces.h symbol-table.h prob.h wordclass.h quote.h
wordclass.o: wordclass.h
