prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
sysconfdir = @sysconfdir@
datadir = @datadir@
localstatedir = @localstatedir@

CC = @CC@
CFLAGS = -Wall @CFLAGS@ @DEFS@
CPPFLAGS = @CPPFLAGS@ @DEFS@ "-DSYSCONFDIR=\"$(sysconfdir)\"" "-DHTPD_PIDFILE=\"$(localstatedir)/run/htpd.pid\""
LDFLAGS = @LDFLAGS@ @LIBS@
INSTALL = @INSTALL@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@

BINS = htpdate$(EXEEXT) htpd$(EXEEXT)

all: $(BINS)
htpd$(EXEEXT): htpd.o htp.o @LIBOBJS@
	$(CC) $(CPPFLAGS) $(CFLAGS) -o htpd$(EXEEXT) htpd.o htp.o @LIBOBJS@ $(LDFLAGS)
htpdate$(EXEEXT): htpdate.o htp.o @LIBOBJS@
	$(CC) $(CPPFLAGS) $(CFLAGS) -o htpdate$(EXEEXT) htpdate.o htp.o @LIBOBJS@ $(LDFLAGS)

htp.o: htp.c htp.h config.h
htpdate.o: htpdate.c htp.h config.h
htpd.o: htpd.c htp.h config.h

.PHONY: clean distclean install all
clean:
	rm -f *.o $(BINS) *~

distclean: clean
	rm -f Makefile config.h config.status config.log htpd.init

install: all
	-$(INSTALL) -d $(bindir)
	-$(INSTALL) -d $(mandir)
	-$(INSTALL) -d $(sysconfdir)
	-$(INSTALL) -d $(mandir)/man5
	-$(INSTALL) -d $(mandir)/man8
	-$(INSTALL) -d $(localstatedir)
	-$(INSTALL) -d $(localstatedir)/run
	$(INSTALL) -m 755 htpd$(EXEEXT) $(bindir)/htpd$(EXEEXT)
	$(INSTALL) -m 755 htpdate$(EXEEXT) $(bindir)/htpdate$(EXEEXT)
	$(INSTALL) -m 644 htpd.8 $(mandir)/man8/htpd.8
	$(INSTALL) -m 644 htpdate.8 $(mandir)/man8/htpdate.8
	$(INSTALL) -m 644 htpd.conf.5 $(mandir)/man5/htpdate.conf.5
	@if [ -f "$(sysconfdir)/htpd.conf" ]; then \
		echo $(INSTALL) -m 644 htpd.conf $(sysconfdir)/htpd.conf.dist; \
		$(INSTALL) -m 644 htpd.conf $(sysconfdir)/htpd.conf.dist; \
	else \
		echo $(INSTALL) -m 644 htpd.conf $(sysconfdir)/htpd.conf; \
		$(INSTALL) -m 644 htpd.conf $(sysconfdir)/htpd.conf; \
	fi
