CCC=/usr/local/gcc/bin/gcc
CCFLAGS= -O2 -msse -march=pentium4
TFLAGS=-L\#'line %L "%F"%N'
#CCFLAGS= -g -msse -march=pentium4
#TFLAGS=

sources = sse.nw
targets = main.cc \
          qcdsse.hh \
          qcd.hh \
          qcd.cc

.PHONY: all clean realclean tar pdf programs compile sources

all: pdf programs

clean:
	$(RM) *.tex *.log *.dvi *.aux

realclean: clean
	$(RM) *.pdf $(targets)

tar: clean
	base=`basename $$PWD` ; \
	cd .. ; \
	tar -cvf - $$base | bzip2 -9 > $$base.tar.bz2

pdf: $(sources:%.nw=%.pdf)

programs: $(targets)

$(sources:%.nw=%.pdf): %.pdf: %.dvi
	dvipdfm $<

$(sources:%.nw=%.dvi): %.dvi: %.tex
	latex $<

$(sources:%.nw=%.tex): %.tex: %.nw
	noweave -latex -delay $< > $@

$(targets): $(sources)
	notangle $(TFLAGS) -R$@ -c++ $< > $@

compile: $(targets)
	$(CCC) $(CCFLAGS) -o sse main.cc qcd.cc -lstdc++
