# IMPORTANT:
# text of the form __var__ will be substituted by 'make pushweb'
# with values from the root Makefile.  ignore the instructions above
# lines of that form unless you want to set them yourself.
#
# this doesn't appear to be getting set right at the moment, so:
LIBEXT=a
LIB=libmod_pushweb.$(LIBEXT)
OBJS=mod_pushweb.o keys.o hmac_md5.o user_table.o otp.o
# the patch utility
PATCH=__PATCH__
# the path to perl
PERL=__PERL__
# if you move the absent include files or build apache from someplace
# strange, replace this with the path to the include files.  if you
# just unpacked apache in the root of the pushweb source tree, you can
# leave this alone.
# IMPORTANT: if you make this path relative, it'll be relative to the
# apache module directory for mod_pushweb, usually
# apache-1.3.6/src/modules/mod_pushweb
LOCINC=__LOCINC__
# same for opie; this path needs to find the opie tree
OPIE=__OPIEDIR__
# ... the opie include files
INCOPIE=__INCOPIE__
# ... and the location of libopie.a
LIBOPIE=__LIBOPIE__
# ... and the truerand library
LIBRAND=__LIBRAND__

all: otp lib

lib: $(LIB)

libmod_pushweb.a: $(OBJS)
	rm -f $@
	ar cr $@ $(OBJS)
	$(RANLIB) $@

libmod_pushweb.so: $(OBJS_PIC)
	rm -f $@
	$(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(OBJS_PIC) $(LIBS_SHLIB)

mod_pushweb.o: mod_pushweb.c
	$(CC) -c $(INCLUDES) -I$(LOCINC) $(CFLAGS) mod_pushweb.c

mod_pushweb.lo: mod_pushweb.c
	$(CC) -c $(INCLUDES) $(CFLAGS) -I$(LOCINC) $(CFLAGS_SHLIB) \
	mod_pushweb.c && \
	mv mod_pushweb.o mod_pushweb.lo

patch:	../../main/http_main.c http_main.diff ../../Makefile
	cd ../../main && \
	cp http_main.c http_main.c.preabsent && \
	$(PATCH) < ../modules/mod_pushweb/http_main.diff
#
# "otp" is a perl front-end to the opie routines
otp:		user_table.o otp.o ${LIBOPIE}/libopie.a
		cd Otp && ${PERL} Makefile.PL && ${MAKE}
clean:
	rm -f mod_pushweb.o $(LIB)

distclean: clean
	-rm -f Makefile
