# written by Guido Socher 
PREFIX=/usr
INSTALL=install
MANP=man1/srcgrep.1 man1/hrefgrep.1 man1/blnkcheck.1 man1/lshtmlref.1 man1/httpcheck.1 man1/webfgrep.1 man1/taggrep.1
#-----------
# Linux and other platforms with gcc
CC=gcc 
CFLAGS= -Wall -O2
CFLAGS= -Wall -Wno-unused 
#-----------
# sun c/c++-compiler:
#CC=CC
#CFLAGS= -O 
#-----------
# HPUX by gdoyle@connect.org.uk 
# for HP 9000/780/C160 running HP-UX 11.00
# C compiler used:  Version A.11.01.02
# http://hpux.connect.org.uk/hppd/cgi-bin/search?package=&term=webgrep-
#CC=cc
#CFLAGS= -O -Ae
#PREFIX=/opt/webgrep
#INSTALL=bsdinst
#-----------
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/man/man1

all: taggrep lshtmlref srcgrep hrefgrep webfgrep blnkcheck htmlpp

taggrep: taggrep.o 
	$(CC) -o $@ taggrep.o 
taggrep.o: taggrep.c config.h
	$(CC) $(CFLAGS) -c taggrep.c 
lshtmlref: lshtmlref.o hashlist.o hashfunct.o htag.o
	$(CC) -o $@ lshtmlref.o hashlist.o hashfunct.o htag.o
lshtmlref.o: lshtmlref.c config.h
	$(CC) $(CFLAGS) -c lshtmlref.c 
blnkcheck: blnkcheck.o htag.o hashlist.o hashfunct.o
	$(CC) -o $@ blnkcheck.o htag.o hashlist.o hashfunct.o
webfgrep: webfgrep.c config.h
	$(CC) $(CFLAGS) -o $@ webfgrep.c 
htmlpp: htmlpp.o htag.o 
	$(CC) -o $@ htmlpp.o htag.o
hrefgrep: hrefgrep.o htag.o 
	$(CC) -o $@ hrefgrep.o htag.o
srcgrep: srcgrep.o htag.o
	$(CC) -o $@ srcgrep.o htag.o 
blnkcheck.o: blnkcheck.c htag.h hash.h config.h
	$(CC) $(CFLAGS) -c blnkcheck.c
htmlpp.o: htmlpp.c config.h
	$(CC) $(CFLAGS) -c htmlpp.c
hrefgrep.o: hrefgrep.c config.h
	$(CC) $(CFLAGS) -c hrefgrep.c
srcgrep.o: srcgrep.c config.h
	$(CC) $(CFLAGS) -c srcgrep.c
htag.o: htag.c htag.h config.h
	$(CC) $(CFLAGS) -c htag.c
# a storage class:
hashlist.o: hashlist.c  hash.h config.h
	$(CC) $(CFLAGS) -c hashlist.c
hashfunct.o: hashfunct.c hash.h  config.h
	$(CC) $(CFLAGS) -c hashfunct.c

install: srcgrep hrefgrep blnkcheck lshtmlref httpcheck webfgrep taggrep htmlpp $(MANP)
	@echo Using the program \"$(INSTALL)\" to install the software 
	[ -d "$(BINDIR)" ] || mkdir -p $(BINDIR)
	[ -d "$(MANDIR)" ] || mkdir -p $(MANDIR)
	$(INSTALL) -m 755 srcgrep $(BINDIR)
	$(INSTALL) -m 755 hrefgrep $(BINDIR)
	$(INSTALL) -m 755 blnkcheck $(BINDIR)
	$(INSTALL) -m 755 lshtmlref $(BINDIR)
	$(INSTALL) -m 755 httpcheck $(BINDIR)
	$(INSTALL) -m 755 webfgrep $(BINDIR)
	$(INSTALL) -m 755 taggrep $(BINDIR)
	$(INSTALL) -m 755 htmlpp $(BINDIR)
	$(INSTALL) -m 644 $(MANP) $(MANDIR)

install_with_cp: srcgrep hrefgrep taggrep lshtmlref blnkcheck httpcheck webfgrep htmlpp $(MANP)
	@echo Using the program \"cp\" to install the software 
	[ -d "$(BINDIR)" ] || mkdir -p $(BINDIR)
	cp taggrep srcgrep lshtmlref hrefgrep blnkcheck httpcheck webfgrep htmlpp $(BINDIR)
	chmod 755 $(BINDIR)/srcgrep 
	chmod 755 $(BINDIR)/hrefgrep 
	chmod 755 $(BINDIR)/webfgrep 
	chmod 755 $(BINDIR)/lshtmlref 
	chmod 755 $(BINDIR)/httpcheck 
	chmod 755 $(BINDIR)/blnkcheck 
	chmod 755 $(BINDIR)/taggrep 
	chmod 755 $(BINDIR)/htmlpp 
	chmod 644 $(MANP)
	[ -d "$(MANDIR)" ] || mkdir -p $(MANDIR)
	cp $(MANP) $(MANDIR)

clean:
	rm -f taggrep hrefgrep lshtmlref htmlpp webfgrep srcgrep blnkcheck mtest *.o core
