# Makefile for research/wordtuples
#
# (c) Mark Johnson, 28th March 2001

CXX = g++
CC = gcc
CFLAGS = -MMD -O3 -Wall -ffast-math -fstrict-aliasing -march=i686
# uncomment the next line to turn off optimization and enable debugging with gdb
# CFLAGS = -MMD -g -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions # -I /home/mj/C++/STL 

# CXXFLAGS are the flags used for all C++ compilation.  These are gcc/g++ specific.
#   
#  -MMD         forces the compiler to produce *.d dependency files
#  -O3          maximum optimization
#  -fXXXX       other optimizations
#  -I <dir>     search for header files in <dir>
#  -g           insert debugging information into compiler output

SOURCES = read-files.cc sym.cc wordtuples.cc interaction.c interaction1.c vwordtuples.cc morph.cc
OBJECTS = read-files.o sym.o wordtuples.o interaction.o -lfl
VOBJECTS = read-files.o sym.o vwordtuples.o morph.o interaction.o -lfl /usr/local/lib/libwn.so
OBJECTS1 = read-files.o sym.o wordtuples.o interaction1.o -lfl
VOBJECTS1 = read-files.o sym.o vwordtuples.o morph.o interaction1.o -lfl /usr/local/lib/libwn.so

DATADIRS = wsj brown
WORDTUPLESARGS = 2 0.01

all: wordtuples vwordtuples wordtuples1 vwordtuples1 filenames.txt 
	wordtuples 2 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	wordtuples 3 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	wordtuples 4 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	wordtuples1 3 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	wordtuples1 4 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	vwordtuples 2 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	vwordtuples 3 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	vwordtuples 4 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	vwordtuples1 3 $(WORDTUPLESARGS) filenames.txt
	@echo ""
	vwordtuples1 4 $(WORDTUPLESARGS) filenames.txt

wordtuples: $(OBJECTS)
	g++ $(OBJECTS) -o wordtuples

vwordtuples: $(VOBJECTS) 
	g++ $(VOBJECTS) -o vwordtuples

wordtuples1: $(OBJECTS1)
	g++ $(OBJECTS1) -o wordtuples1

vwordtuples1: $(VOBJECTS1) 
	g++ $(VOBJECTS1) -o vwordtuples1

read-files.cc: read-files.l
	lex -t read-files.l > read-files.cc

# list all .pos files below wsj or brown
filenames.txt: $(DATADIRS)
	find $(DATADIRS) -follow -name "*.pos" -print > filenames.txt  

# make clean  removes all temporary files that can be recomputed
.PHONY: clean
clean:
	rm -f *.o *.d core read-files.cc filenames.txt

# this command tells GNU make to look for dependencies in *.d files
-include $(patsubst %.c,%.d,$(SOURCES:%.cc=%.d))
