## 

APXS=@APXS@
OS=@OS@
JAVA_HOME=@JAVA_HOME@
CP=@CP@
APACHE_DIR=@APACHE_DIR@
MKDIR=@MKDIR@
APXSCFLAGS=@APXSCFLAGS@
APXSCPPFLAGS=@APXSCPPFLAGS@
CC=@CC@

# Defaults
libexecdir=${APACHE_DIR}/modules

JK=../common/
# Defines APACHE_OBJECTS - the list of all common files
include ../common/list.mk

# Apache2 settings, values guessed by Apache config and used to build it
# Will define libexecdir, LIBTOOL, etc
include @APACHE_CONFIG_VARS@

# Local settings ( overriding/appending to Apache's ) 
COMMON=../common
JK_INCL=-DUSE_APACHE_MD5 -I ${COMMON} 
JAVA_INCL=-I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/${OS}
JAVA_LIB=-L ${JAVA_HOME}/jre/lib/${ARCH} -L ${JAVA_HOME}/lib/${ARCH}/native_threads
CFLAGS=@apache_include@ @CFLAGS@ ${JK_INCL} ${JAVA_INCL} ${APXSCPPFLAGS} ${APXSCFLAGS} ${EXTRA_CFLAGS} ${EXTRA_CPPFLAGS}


# Implicit rules
include ../scripts/build/rules.mk

OEXT=.lo

all: Makefile @LIB_JK_TYPE@ 
install: @INSTALL_TYPE@

Makefile: Makefile.in
	echo Regenerating Makefile
	( cd ..; ./config.status )

lib_jk.la: mod_jk.lo ${APACHE_OBJECTS}
	$(LIBTOOL) --mode=link $(CC) -o lib_jk.la -static -rpath ${libexecdir}/jk mod_jk.lo $(APACHE_OBJECTS)

install_static:
	@echo ""
	@echo "Copying files to Apache Modules Directory..."
	-${MKDIR} ${APACHE_DIR}/modules/jk
	${CP} config.m4 ${APACHE_DIR}/modules/jk
	${LIBTOOL} --mode=install cp lib_jk.la ${APACHE_DIR}/modules/jk
	@echo ""
	@echo "Please be sure to re-compile Apache..."
	@echo ""
	@echo "cd ${APACHE_DIR}"
	@echo "./buildconf"
	@echo "./configure --with-mod_jk"
	@echo "make"
	@echo ""

#################### Dynamic .so file ####################
# APXS will compile every file, this is derived from apxs

mod_jk.la: mod_jk.lo $(APACHE_OBJECTS)
	$(LIBTOOL) --mode=link ${COMPILE} `${APXS} -q LDFLAGS` -o $@ -module -rpath ${libexecdir} -avoid-version mod_jk.lo $(APACHE_OBJECTS)

mod_jk.so: mod_jk.la
	$(LIBTOOL) --mode=install cp mod_jk.la `pwd`/$@

install_dynamic:
	@echo ""
	@echo "Installing files to Apache Modules Directory..."
	$(APXS) -i mod_jk.la
	@echo ""
	@echo "Please be sure to arrange ${APACHE_DIR}/conf/httpd.conf..."
	@echo ""

clean:
	rm -f *.o *.lo *.a *.la *.so *.so.* *.slo
	rm -rf .libs
