
# Makefile to build shared modules to be loaded by Apache at startup by
# the LoadModule directive.
#
# Yves Arrouye <arrouye@debian.org>
# Modified for Apache 1.1.3 by Johnie Ingram <johnie@debian.org>

# Note: the .so files for the modules should have the name of the module
# (e.g. mod_log_config compiles to config_log_module.so); the Debian
# installation script for Apache will use nm if available to get the real
# name of a module, but nothing tells you nm will be available then...

prefix = /usr

INCDIR = . -I $(prefix)/include/apache
LIBDIR = $(prefix)/lib/apache

MODDIR = $(LIBDIR)/modules

CC = gcc
CFLAGS = -fPIC -O2 -I$(INCDIR) -DDEBIAN -DLINUX -DHAVE_POSIX_REGEX
LDFLAGS = -shared -Wl,-S
MODSRCS = $(wildcard mod_*.c)
MODOBJS = $(MODSRCS:.c=.so)
MODNAMES = $(MODSRCS:.c=)

INSTALL = install

.SUFFIXES: .gz .so


%: %.gz
	gunzip -c $< >$@


%.so: %.c
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@

all: modules

modules: $(MODOBJS)


mod_auth_db.so: mod_auth_db.c
	$(CC) -I/usr/include/db $(CFLAGS) $(LDFLAGS) $< -o $@ -ldb

mod_auth_dbm.so: mod_auth_dbm.c
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ -lgdbm

mod_auth_msql.so: mod_auth_msql.c
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ -lmsql

mod_rewrite.so: mod_rewrite.o
	$(CC) $(LDFLAGS) $< -o $@ -lgdbm regexp/libregexp.a


install:
	$(INSTALL) -s -m 644 $(MODOBJS) $(MODDIR)


clean:
	$(RM) $(MODSRCS:.c=.o)

distclean: clean
	$(RM) $(MODOBJS) *~ \#*\# *%

.PHONY: all modules install clean distclean

