 # Copyright (C) 2000, 2001, 2013 Gregory Trubetskoy
 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Apache Software Foundation
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
 #  You may obtain a copy of the License at
 #
 #      http://www.apache.org/licenses/LICENSE-2.0
 #
 #  Unless required by applicable law or agreed to in writing, software
 #  distributed under the License is distributed on an "AS IS" BASIS,
 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 #
 # Originally developed by Gregory Trubetskoy.
 #

CC=@CC@
AR=@AR@
APXS=@APXS@
MKDEP=@MKDEP@

# requires flex 2.5.31 for reentrant support
LEX=@LEX@
INCLUDES=@INCLUDES@
CPPFLAGS=@CPPFLAGS@
CFLAGS=@CFLAGS@
LDLIBS=@LDLIBS@
LDFLAGS=@LDFLAGS@
srcdir=.

SRCS=	mod_python.c _apachemodule.c requestobject.c tableobject.c util.c \
		serverobject.c connobject.c filterobject.c hlist.c \
		hlistobject.c finfoobject.c version.c \
		include/_apachemodule.h  include/filterobject.h  include/hlist.h \
		include/mod_python.h  include/psp_flex.h include/psp_parser.h  \
		include/requestobject.h include/tableobject.h include/connobject.h \
		include/finfoobject.h include/hlistobject.h include/mp_version.h \
		include/_pspmodule.h  include/psp_string.h  include/serverobject.h \
		include/util.h

.PHONY: version

all:	@ALL@

psp_parser.c: psp_parser.l
	@rm -f psp_parser.c
	$(LEX) -R -opsp_parser.c --header-file=include/psp_flex.h psp_parser.l

dso:	mod_python.so

mod_python.so: $(SRCS) @SOLARIS_HACKS@
	@echo
	@echo 'Building mod_python.so.'
	@echo
	$(APXS) $(INCLUDES) $(CPPFLAGS) $(APXSFLAGS) $(CFLAGS) -c $(SRCS) $(LDFLAGS) $(LDLIBS) @SOLARIS_HACKS@
	@rm -f mod_python.so
	@ln -s .libs/mod_python.so mod_python.so
clean:
	rm -rf $(OBJS) version.c core libpython.a mod_python.so *~ .libs *.o *.slo *.lo *.la

distclean: clean
	rm -f Makefile .depend

version.c:
	@echo > version.c ; \
	echo "/* THIS FILE IS AUTO-GENERATED BY Makefile */" >> version.c ; \
	echo "#include \"mp_version.h\"" >> version.c ; \
	echo "const int mp_version_major = MP_VERSION_MAJOR;" >> version.c ; \
	echo "const int mp_version_minor = MP_VERSION_MINOR;" >> version.c ; \
	echo "const int mp_version_patch = MP_VERSION_PATCH;" >> version.c ; \
	echo "const char * const mp_version_string = \"`../dist/version.sh`\";" >> version.c ; \
	echo "const char * const mp_version_component = \"mod_python/\" \"`../dist/version.sh`\";" >> version.c

# this is a hack to help avoid a gcc/solaris problem
# python uses assert() which needs _eprintf(). See
# SOLARIS_HACKS above
_eprintf.o:
	ar -x `gcc -print-libgcc-file-name` _eprintf.o
_floatdidf.o:
	ar -x `gcc -print-libgcc-file-name` _floatdidf.o
_muldi3.o:
	ar -x `gcc -print-libgcc-file-name` _muldi3.o

# DO NOT DELETE THIS LINE
