CFLAGS =  -O2
prefix=/usr/local/
exec_prefix=${prefix}
sbindir=${exec_prefix}/sbin
etcdir=${prefix}/etc

lan_fils :=$(wildcard ../etc/havp/templates/[a-z]*/*.html)

OBJECTS = filehandler.o helper.o logfile.o scannerfilehandler.o connectiontobrowser.o \
          genericscanner.o httphandler.o params.o sockethandler.o connectiontoserver.o havp.o \
          proxyhandler.o whitelist.o trophiescanner.o
all: 	havp

havp: $(OBJECTS)
	$(CXX) -DHAVE_CONFIG_H -I. -I. -I.. $(CFLAGS) -o havp $(OBJECTS) -lvsapi

install: all
	install -d $(sbindir)
	install -m 755 havp $(sbindir)/havp
	install -d /var/log/havp/
	install -d /var/tmp/havp/
	install -d /var/run/havp/
	chmod a+rw /var/run/havp/
	install -d /etc/init.d/
	install -m 755 ../etc/init.d/havp /etc/init.d/
	install -m 644 -D ../etc/havp/havp.config $(etcdir)/havp/havp.config
	install -m 644 -D ../etc/havp/whitelist $(etcdir)/havp/whitelist
	install -m 644 -D ../etc/havp/blacklist $(etcdir)/havp/blacklist
	@list='${lan_fils}'; for fil in $$list;do \
	install -m 755 -D $$fil $(etcdir)/$${fil#../etc*}; \
	done



%.o:	%.cpp %.h
	$(CXX) -DHAVE_CONFIG_H -I. -I. -I.. $(CFLAGS) -c $< -o $@

clean:
	-rm -f havp $(OBJECTS)

