#lib phtml_parse is a library for parsing php and asp files
#Copyright (C) 2003 Michael De La Rue

#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

BASE=/usr/local/
FLEX_OPT=-v
VERSION=0.4

all: phtml_parse_demo phtml_parse.la

clean:
	libtool rm -f phtml_parse.lo libphtmlparse.la
	libtool rm -f phtml_parse_demo
	rm -f test-out/*.php
	rm -f test-out2/*.php

dist: phtml_parse-$(VERSION).tar.gz phtml_parse.c phtmlparse.1

phtmlparse.1: phtmlparse.pod
	pod2man phtmlparse.pod phtmlparse.1

distclean: clean 
	rm -rf phtml_parse-$(VERSION)
	libtool rm -f phtml_parse_demo phtml_parse.la phtml_parse.lo
	rm -f *~ 

#not everyone has flex installed so we leave the flex output in place
#for distribution

realclean: distclean
	rm -f phtml_parse.c phtmlparse.1

phtml_parse_demo: phtml_parse.c phtml_parse_demo.c phtml_parse.h phtml_parse.la
	libtool gcc -Wall -g phtml_parse_demo.c libphtmlparse.la -lfl -o phtml_parse_demo;

phtml_parse.c: phtml_parse.l phtml_parse.h
	flex $(FLEX_OPT) -ophtml_parse.c phtml_parse.l ; 

phtml_parse_debug.c: phtml_parse.l phtml_parse.h
	flex $(FLEX_OPT) -ophtml_parse_debug.c -d phtml_parse.l ; 

phtml_parse.lo:  phtml_parse.c phtml_parse.h
	libtool gcc -Wall -g -O -c phtml_parse.c

phtml_parse.la: phtml_parse.lo
	libtool gcc -Wall -g -O -o libphtmlparse.la phtml_parse.lo -rpath /usr/local/lib

install: phtml_parse.la
	libtool install -d $(BASE)/lib $(BASE)/include
	libtool install libphtmlparse.la $(BASE)/lib/libphtmlparse.la 
	libtool --finish $(BASE)/lib
	install phtml_parse.h $(BASE)/include

test: all
	sh ./test.sh

test-verb: all
	sh -v ./test.sh

manifest: distclean
	rm -f phtml_parse-$(VERSION)
	find . -type f -print | egrep -v '(.libs)|(CVS)|(/\.#)' > MANIFEST
	find . -type d -print | egrep -v '(.libs)|CVS'> MANIFEST.DIR


phtml_parse-$(VERSION).tar.gz: distclean phtml_parse.c phtmlparse.1
	rm -rf phtml_parse-$(VERSION)
	mkdir phtml_parse-$(VERSION)
	for i in `cat MANIFEST.DIR`; do \
		mkdir phtml_parse-$(VERSION)/$$i; done
	for i in `cat MANIFEST`; do cp $$i phtml_parse-$(VERSION)/$$i; done
	tar cvvzf phtml_parse-$(VERSION).tar.gz phtml_parse-$(VERSION)

.PHONY: install clean dist phtml_parse-$(VERSION).tar.gz
