#
# APR (Apache Portable Runtime) library Makefile.
#
CPP = gcc -E

#
# Macros for supporting directories
#
INCDIR=./include
INCDIR1=../include
INCLUDES=-I$(INCDIR) -I$(INCDIR1)

#
# Macros for target determination
#
SUBDIRS=strings passwd tables  file_io/unix  network_io/unix  threadproc/unix  misc/unix  locks/unix  time/unix  mmap/unix  shmem/unix  i18n/unix  user/unix  memory/unix  atomic/unix  dso/unix 
CLEAN_SUBDIRS= . test build
INSTALL_SUBDIRS=none

TARGET_LIB = libapr.la

#
# Rules for building specific targets, starting with 'all' for
# building the entire package.
#
TARGETS = delete-lib $(TARGET_LIB) delete-exports export_vars.h apr.exp

# bring in rules.mk for standard functionality
include /home/aaron/downloads/httpd-2.0.39/srclib/apr/build/rules.mk

CLEAN_TARGETS = 
DISTCLEAN_TARGETS = config.cache config.log config.status \
	include/apr.h include/arch/unix/apr_private.h \
	APRVARS libtool apr.exp apr-config
EXTRACLEAN_TARGETS = configure aclocal.m4 include/arch/unix/apr_private.h.in \
	exports.c export_vars.h

prefix=/home/aaron/downloads/httpd-2.0.39/bindist
exec_prefix=/home/aaron/downloads/httpd-2.0.39/bindist
bindir=${prefix}/bin
libdir=${prefix}/lib
includedir=/home/aaron/downloads/httpd-2.0.39/bindist/include
installbuilddir=${prefix}/build
srcdir=/home/aaron/downloads/httpd-2.0.39/srclib/apr
VPATH=/home/aaron/downloads/httpd-2.0.39/srclib/apr
top_srcdir=/home/aaron/downloads/httpd-2.0.39/srclib/apr
top_blddir=

EXPORT_FILES = $(top_srcdir)/include/*.h

delete-lib:
	@if test -f $(TARGET_LIB); then \
	    for i in $(SUBDIRS); do objects="$$objects $$i/*.lo"; done ; \
	    if test -n "`find $$objects -newer $(TARGET_LIB)`"; then \
		echo Found newer objects. Will relink $(TARGET_LIB). ; \
		echo $(RM) -f $(TARGET_LIB) ; \
		$(RM) -f $(TARGET_LIB) ; \
	    fi \
	fi

install: $(TARGET_LIB)
	if [ ! -d $(DESTDIR)$(includedir) ]; then \
	    $(top_srcdir)/build/mkdir.sh $(DESTDIR)$(includedir); \
	fi;
	cp -p $(top_srcdir)/include/*.h $(DESTDIR)$(includedir);

	if test -n "$(top_blddir)"; then \
	    cp -p $(top_blddir)/include/*.h $(DESTDIR)$(includedir); \
	fi;
	if [ ! -d $(DESTDIR)$(libdir) ]; then \
	    $(top_srcdir)/build/mkdir.sh $(DESTDIR)$(libdir); \
	fi;
	$(LIBTOOL) --mode=install cp $(TARGET_LIB) $(DESTDIR)$(libdir)
	$(LIBTOOL) --mode=install cp APRVARS $(DESTDIR)$(libdir)
	$(LIBTOOL) --mode=install cp apr.exp $(DESTDIR)$(libdir)
	if [ ! -d $(DESTDIR)$(installbuilddir) ]; then \
	   	$(top_srcdir)/build/mkdir.sh $(DESTDIR)$(installbuilddir); \
	fi; 
	if [ -f libtool ]; then \
		$(LIBTOOL) --mode=install cp libtool $(DESTDIR)$(installbuilddir); \
	fi;
	if [ -f shlibtool ]; then \
		$(LIBTOOL) --mode=install cp shlibtool $(DESTDIR)$(installbuilddir); \
	fi;
	if [ ! -d $(DESTDIR)$(bindir) ]; then \
	    $(top_srcdir)/build/mkdir.sh $(DESTDIR)$(bindir); \
	fi;
	$(LIBTOOL) --mode=install cp apr-config $(DESTDIR)$(bindir)
	chmod 755 $(DESTDIR)$(bindir)/apr-config
	@if [ $(INSTALL_SUBDIRS) != "none" ]; then \
            for i in $(INSTALL_SUBDIRS); do \
	        ( cd $$i ; $(MAKE) DESTDIR=$(DESTDIR) install ); \
	    done \
	fi

$(TARGET_LIB):
	@for i in $(SUBDIRS); do objects="$$objects $$i/*.lo"; done ; \
	    tmpcmd="$(LINK) -rpath $(libdir) $$objects "; \
	    echo $$tmpcmd; \
	    $$tmpcmd

delete-exports:
	@if test -f apr.exp; then \
	    headers="`find include/*.h -newer apr.exp`" ; \
	    if test -n "$$headers"; then \
		echo Found newer headers. Will rebuild apr.exp. ; \
		echo $(RM) -f apr.exp exports.c export_vars.h ; \
		$(RM) -f apr.exp exports.c export_vars.h ; \
	    fi \
	fi

exports.c:
	$(AWK) -f $(top_srcdir)/build/make_exports.awk $(EXPORT_FILES) > $@

export_vars.h:
	$(AWK) -f $(top_srcdir)/build/make_var_export.awk $(EXPORT_FILES) > $@

apr.exp: exports.c export_vars.h
	@echo "#! libapr.so" > $@
	@echo "* This file was AUTOGENERATED at build time." >> $@
	@echo "* Please do not edit by hand." >> $@
	$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/' >> $@
	$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) export_vars.h | sed -e 's/^\#[^!]*//' | sed -e '/^$$/d' >> $@

dox:
	doxygen $(top_srcdir)/docs/doxygen.conf

test: $(TARGET_LIB)
	(cd test; make clean; make; \
	for prog in `find . -type f -perm -u+x -name "test*" -print`; do \
	    ./$$prog; \
	    if [ $$? -eq 255 ]; then \
	        echo "$$prog failed"; \
	        break; \
	    fi \
	done )

# DO NOT REMOVE
docs: $(INCDIR)/*.h
