# Add -pg to both for profiling
CFLAGS=-g -O2 -Wall --std=c99 `xml2-config --cflags`
LFLAGS=`xml2-config --libs`
HEADERS=  mediawikiformat.h mediawikimarkup.h upstr.h bag.h
EXTRAOBJS=mediawikiformat.o mediawikimarkup.o upstr.o bag.o
BINARIES=autotest dumptitles dumpall passthrough discardnonart randomsubset categorise

DISTDATE=`ddate +%Y%q%d`
# To get numeric season output (instead of textual %b), patch your ddate with this:
#   case 'q': sprintf(snarf, "%d", dt.season+1); wibble=snarf; break;
# Consult your pineal gland to determine exactly where that belongs.

.PHONY: all cleanish dist
all: ${BINARIES}

cleanish:
	-rm ${BINARIES}

dist:
	tar cvjhf wikistudytools-$(DISTDATE).tar.bz2 Makefile LICENCE.txt README.txt enwiki-trunchard.xml.bz2 CatAggr.pm cataggr compstrmags *.c *.h *.gp
# h dereferences the .gp symlinks from ../9mr/

% : %.o ${EXTRAOBJS}
	gcc ${LFLAGS} $^ -o $@

%.o : %.c ${HEADERS}
	gcc ${CFLAGS} -c $< -o $@

# Disable the naughty implicit rule
% : %.c

