# Apache makefile template (well, suffix).

# This is combined with the information in the "Configuration" file
# by the configure script to make the actual Makefile.

OBJS= alloc.o http_main.o http_core.o http_config.o http_request.o \
  http_log.o http_protocol.o rfc1413.o util.o util_script.o modules.o buff.o\
  md5c.o util_md5.o explain.o http_bprintf.o $(MODULES)

.c.o:
	$(CC) -c $(CFLAGS) $(AUX_CFLAGS) $<

all: Configuration httpd

RANLIB=ranlib
PERL=/usr/bin/perl
PERL_LD_OPTS=`$(PERL) modules/perl/ldopts`

modules/perl/libmodperl.a:
	(cd modules/perl; \
	make CC='$(CC)' AUX_CFLAGS='$(CFLAGS)' RANLIB=$(RANLIB) PERL=$(PERL);)

Configuration: Configuration.tmpl
	@echo "Configuration older than Configuration.tmpl, or doesn't exist."
	@echo "Consider copying Configuration.tmpl to Configuration, editing and rerunning"
	@echo "Configure."
	@echo "If not, you will at least have to touch Configuration."
	@false

httpd: $(OBJS)
	$(CC) $(LFLAGS) $(AUX_LFLAGS) -o httpd $(OBJS) $(EXTRA_LIBS) $(AUX_LIBS) 

clean:
	rm -f httpd $(OBJS) *pure*

dist.tar: 
	# Assure a semi-sensible configuration going out...
	cp Makefile.orig Makefile
	cp modules.c.orig modules.c
	tar cvf dist.tar README INSTALL CHANGES TODO API.html \
		Configuration Configure Makefile.tmpl Makefile *.h *.c

# Work around broken compilers
http_bprintf.o: http_bprintf.c
	$(CC) -c $(CFLAGS) $(AUX_CFLAGS) $(BROKEN_BPRINTF_FLAGS) http_bprintf.c

#Dependencies
#Core code
$(OBJS): Makefile httpd.h alloc.h buff.h conf.h

http_config.o http_core.o http_main.o util.o: http_conf_globals.h
http_config.o http_core.o http_main.o: http_config.h http_log.h
http_log.o http_protocol.o http_request.o modules.o: http_config.h
http_config.o http_core.o http_log.o http_main.o http_protocol.o: http_core.h
http_request.o: http_core.h
http_protocol.o http_request.o util_script.o rfc1413.o: http_log.h
http_core.o http_main.o http_protocol.o http_request.o: http_main.h
http_core.o http_main.o http_protocol.o http_request.o: http_protocol.h
http_config.o http_main.o http_request.o: http_request.h
http_main.o: scoreboard.h
http_core.o rfc1413.o: rfc1413.h

#Modules
$(MODULES): http_config.h httpd.h
mod_dld.o: http_conf_globals.h
mod_ai_backcompat.o mod_auth.o mod_auth_dbm.o mod_cgi.o mod_dir.o: http_core.h
mod_access.o mod_imap.o mod_include.o mod_negotiation.o: http_core.h
mod_asis.o mod_auth.o mod_auth_dbm.o mod_cgi.o mod_dir.o: http_core.h
mod_status.o mod_cookies.o mod_log_common.o: http_core.h
mod_access.o mod_proxy.o mod_imap.o mod_include.o mod_negotiation.o: http_log.h
mod_proxy.o mod_asis.o mod_cgi.o mod_dir.o mod_imap.o: http_main.h
mod_status.o mod_include.o: http_main.h
mod_proxy.o mod_asis.o mod_auth.o mod_auth_dbm.o mod_cgi.o: http_protocol.h
mod_status.o mod_dir.o: http_protocol.h
mod_imap.o mod_include.o: http_protocol.h
mod_cgi.o mod_dir.o mod_imap.o mod_include.o mod_negotiation.o: http_request.h
mod_proxy.o: md5.h
mod_status.o: util_script.h
mod_asis.o mod_cgi.o mod_dir.o mod_imap.o mod_include.o: util_script.h
mod_digest.o: util_md5.h
mod_status.o: scoreboard.h

#Utils
md5c.o: md5.h
util.o: http_conf_globals.h
util_script.o: http_core.h http_main.h http_protocol.h util_script.h
util_md5.o: md5.h

