# Generated automatically by configure.rb.

srcdir = @srcdir@
topdir = @topdir@
hdrdir = @hdrdir@
VPATH = $(srcdir)

arch = @arch@
ruby_version = @ruby_version@

DESTDIR = 

prefix = $(DESTDIR)@prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
rubylibdir = @rubylibdir@
archdir = @archdir@
sitedir = @sitedir@
sitelibdir = @sitelibdir@
sitearchdir = @sitearchdir@
includedir = @includedir@
mandir = @mandir@

CC = @CC@
AR = @AR@
LD = @LD@
RANLIB = @RANLIB@
RUBY = $(RUBY_INSTALL_NAME)

CFLAGS = @CFLAGS@ -I. -I$(hdrdir) $(APACHE_INCLUDES) $(ERUBY_INCLUDES) @DEFS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
XLDFLAGS = @XLDFLAGS@
DLDFLAGS = @DLDFLAGS@
LDSHARED = @LDSHARED@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DLLIB = @INSTALL_DLLIB@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_DIR = @INSTALL_DIR@

RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@
LIBRUBYARG = @LIBRUBYARG@
LIBRUBY_A = @LIBRUBY_A@
RUBY_SO_NAME = @RUBY_SO_NAME@

APACHE_SRCDIR = @APACHE_SRCDIR@
APACHE_INCLUDES = @APACHE_INCLUDES@
APACHE_LIBEXECDIR = $(DESTDIR)@APACHE_LIBEXECDIR@
APACHE_SRC_UID = @APACHE_SRC_UID@
APACHE_SRC_GID = @APACHE_SRC_GID@

ERUBY_INCLUDES = @ERUBY_INCLUDES@
LIBERUBYARG = @LIBERUBYARG@

TARGET = @TARGET@

MAJOR = @MAJOR@
MINOR = @MINOR@
TEENY = @TEENY@
VERSION = $(MAJOR).$(MINOR).$(TEENY)
TAG = release_$(MAJOR)_$(MINOR)_$(TEENY)

RUBYLIBS	= apache/ruby-run.rb \
		  apache/eruby-run.rb \
		  apache/erb-run.rb \
		  apache/rd2html.rb \
		  apache/ruby-debug.rb \
		  auto-reload.rb

OBJS	= mod_ruby.@OBJEXT@ \
	  ruby_config.@OBJEXT@ \
	  apachelib.@OBJEXT@ \
	  array_header.@OBJEXT@ \
	  table.@OBJEXT@ \
	  connection.@OBJEXT@ \
	  server.@OBJEXT@ \
	  request.@OBJEXT@

.c.@OBJEXT@:
	$(CC) $(CFLAGS) -c $<

all: $(TARGET)

install: @INSTALL_TARGET@ install-ruby

site-install: @INSTALL_TARGET@ install-siteruby

install-ruby:
	$(INSTALL_DIR) $(rubylibdir)/apache
	for file in $(RUBYLIBS); do \
		$(INSTALL_DATA) $(srcdir)/lib/$$file $(rubylibdir)/$$file; \
	done

install-siteruby:
	$(INSTALL_DIR) $(sitelibdir)/apache
	for file in $(RUBYLIBS); do \
		$(INSTALL_DATA) $(srcdir)/lib/$$file $(sitelibdir)/$$file; \
	done

install-static: all
	$(INSTALL_DIR) -o $(APACHE_SRC_UID) -g $(APACHE_SRC_GID) \
		$(APACHE_SRCDIR)/src/modules/ruby
	$(INSTALL_DATA) -o $(APACHE_SRC_UID) -g $(APACHE_SRC_GID) \
		$(TARGET) $(APACHE_SRCDIR)/src/modules/ruby
	$(INSTALL_DATA) -o $(APACHE_SRC_UID) -g $(APACHE_SRC_GID) \
		mod_ruby.c $(APACHE_SRCDIR)/src/modules/ruby
	$(INSTALL_DATA) -o $(APACHE_SRC_UID) -g $(APACHE_SRC_GID) \
		Makefile.tmpl $(APACHE_SRCDIR)/src/modules/ruby
	$(INSTALL_DATA) -o $(APACHE_SRC_UID) -g $(APACHE_SRC_GID) \
		Makefile.libdir $(APACHE_SRCDIR)/src/modules/ruby
	$(INSTALL_DATA) -o $(APACHE_SRC_UID) -g $(APACHE_SRC_GID) \
		libruby.module $(APACHE_SRCDIR)/src/modules/ruby
	$(INSTALL_DATA) -o $(APACHE_SRC_UID) -g $(APACHE_SRC_GID) \
		ruby_shared_stub.c $(APACHE_SRCDIR)/src/modules/ruby

install-shared: all
	$(INSTALL_DIR) $(APACHE_LIBEXECDIR)
	$(INSTALL_DLLIB) $(TARGET) $(APACHE_LIBEXECDIR)

clean:
	rm -f libruby.a
	rm -f mod_ruby.so
	rm -f $(OBJS)

distclean: clean
	rm -f Makefile
	rm -f libruby.module
	rm -f mod_ruby.imp
	find . -name '*~' | xargs rm -f

tag:
	cvs tag $(TAG)

dist:
	cvs export -r $(TAG) -d mod_ruby-$(VERSION) mod_ruby
	tar zcf ../mod_ruby-$(VERSION).tar.gz mod_ruby-$(VERSION)
	rm -rf mod_ruby-$(VERSION)

libruby.a: $(OBJS)
	$(AR) rcu $@ $(OBJS)
	$(RANLIB) $@

mod_ruby.so: $(OBJS)
	$(LDSHARED) $(DLDFLAGS) $(XLDFLAGS) -o $(TARGET) $(OBJS) \
		$(LIBERUBYARG) $(LIBRUBYARG) $(LIBS)

mod_ruby.@OBJEXT@: mod_ruby.c mod_ruby.h ruby_config.h apachelib.h
ruby_config.@OBJEXT@: ruby_config.c mod_ruby.h ruby_config.h
apachelib.@OBJEXT@: apachelib.c apachelib.h
array_header.@OBJEXT@: array_header.c apachelib.h
table.@OBJEXT@: table.c apachelib.h
connection.@OBJEXT@: connection.c apachelib.h
server.@OBJEXT@: server.c apachelib.h
request.@OBJEXT@: request.c apachelib.h
