GNUmakefile.in 4.25 KB
Newer Older
1
#
2
# EMULAB-COPYRIGHT
3
# Copyright (c) 2002-2012 University of Utah and the Flux Group.
4 5 6
# All rights reserved.
#
#
7 8 9 10 11 12 13
# For installation only.
#
SRCDIR		= @srcdir@
TESTBED_SRCDIR	= @top_srcdir@
OBJDIR		= ..
SUBDIR		= apache

14 15 16 17 18 19 20 21 22
SYSTEM	       := $(shell uname -s)
ifeq ($(SYSTEM),FreeBSD)
FBSDREL	:= $(shell uname -r | sed -e 's/\([^-][^-]*\)-.*/\1/')
FBSDMAJ := $(basename $(FBSDREL))
ifeq ($(FBSDMAJ),7)
SCRIPT_HACK	= 1
endif
endif

23 24
include $(OBJDIR)/Makeconf

25 26
OPS_FILES       = httpd.conf-ops php.ini
CONFIG_FILES	= httpd.conf $(OPS_FILES)
27 28 29 30 31

#
# Move to Apache 22 ...
#
ifeq ($(APACHE_VERSION),22)
32 33
# For VPATH.
MOSTLY_SRCDIRS = ${SRCDIR}/v2
34 35
SCRIPT_HACK     = 0
else
36
MOSTLY_SRCDIRS = ${SRCDIR}/v1
37 38
endif
INSTALL_PHP_CONFIG = /usr/local/etc
39

40 41 42 43 44 45
#
# Force dependencies to make sure configure regenerates if the .in file
# is changed.
# 
all: $(CONFIG_FILES)

46 47
control-build: $(OPS_FILES)

48 49
include $(TESTBED_SRCDIR)/GNUmakerules

50 51 52 53 54 55 56 57 58
#
# Override version from GNUmakerules since the source is kept in a
# different place, and the config script is a pain to work with.
# Maybe we can just make this the default in GNUmakerules. 
#
%: %.in $(OBJDIR)/config.status
	@echo "Regenerating $@ from $(subst $(TESTBED_SRCDIR)/,,$<)"
	cd $(OBJDIR) && CONFIG_FILES=$(SUBDIR)/$@:$(subst $(TESTBED_SRCDIR)/,,$<) ./config.status

59 60 61
# Like the INSTALL_ETCDIR target
$(INSTALL_APACHE_CONFIG)/%: %
	@echo "Installing $<"
62
	-mkdir -p $(INSTALL_APACHE_CONFIG)
63 64 65
	$(INSTALL_DATA) $< $@


66 67 68 69 70
#
# XXX hack, hack: need to fix the path to the auth_mysql_module
# This could (should?) be done with configure, but apache port might
# not be installed when we configure our software.
#
71 72
# XXX ugh, do the same thing to detect php5...
#
73
# Note that this is not needed for apache22.
74
#
75 76
httpd.conf.fixed: httpd.conf
	-@cp httpd.conf httpd.conf.fixed
77 78
	@if [ -x /usr/local/libexec/apache/mod_auth_mysql.so ]; then \
            sed -i "" -e '/^LoadModule auth_mysql/s/libauth/mod_auth/' httpd.conf.fixed; \
79 80 81 82 83 84 85 86 87 88 89 90
	    echo "Updated httpd.conf for auth_mysql"; \
	fi
	@if [ -x /usr/local/libexec/apache/libphp5.so ]; then \
            sed -i "" -e 's/php4/php5/g' httpd.conf.fixed; \
	    echo "Updated httpd.conf for php5"; \
	fi

httpd.conf-ops.fixed: httpd.conf-ops
	-@cp httpd.conf-ops httpd.conf-ops.fixed
	@if [ true -o -x /usr/local/libexec/apache/libphp5.so ]; then \
            sed -i "" -e 's/php4/php5/g' httpd.conf-ops.fixed; \
	    echo "Updated httpd.conf-ops for php5"; \
91 92
	fi

93 94 95
install-dirs:
	-mkdir -p $(INSTALL_TOPDIR)/www

96 97 98 99 100 101
#
# Well, this is awkward.  Make sure we don't try to install anything from
# a dev tree both because it doesn't make any sense and because it would
# clobber the "real" version.
#
ifeq ($(TBROOT),/usr/testbed)
102 103 104 105 106 107 108 109
#
# XXX another woeful hack.  There appears to be a well-documented problem
# with Apache and PHP4, where loading PHP with certain extensions will cause
# Apache to crash immediately.  However, if you start it without PHP and then
# use apachectl to restart it *with* PHP, all is well.  Go figure...
# We install this script which accomodates that...ahem, "behavior."
# Since we have only seen this on FBSD7, we only do it there.
#
110 111 112 113
# Note that we install apache-emulab as apache.sh to be consistant with
# with what {boss,ops}-install expect.
#
install-scripts: apache-emulab
114 115 116 117
ifeq ($(SCRIPT_HACK),1)
	@if [ -f /usr/local/etc/rc.d/apache -a ! -f /usr/local/etc/rc.d/.apache.real ]; then \
	    mv /usr/local/etc/rc.d/apache /usr/local/etc/rc.d/.apache.real; \
	fi
118
	$(INSTALL) -m 755 $(SRCDIR)/apache-emulab /usr/local/etc/rc.d/apache.sh
Mike Hibler's avatar
Mike Hibler committed
119
endif
120

121
ifeq ($(APACHE_VERSION),22)
122 123 124 125 126 127 128
install: install-dirs install-scripts httpd.conf
	$(INSTALL_DATA) httpd.conf $(INSTALL_APACHE_CONFIG)/httpd.conf

control-install: install-dirs install-scripts httpd.conf-ops
	$(INSTALL_DATA) httpd.conf-ops $(INSTALL_APACHE_CONFIG)/httpd.conf

utah: httpd.conf.utah httpd.conf-ops.utah
129
else
130
install: install-dirs install-scripts httpd.conf.fixed
131
	$(INSTALL_DATA) httpd.conf.fixed $(INSTALL_APACHE_CONFIG)/httpd.conf
132

133 134
control-install: install-dirs install-scripts httpd.conf-ops.fixed
	$(INSTALL_DATA) httpd.conf-ops.fixed $(INSTALL_APACHE_CONFIG)/httpd.conf
135
endif
136 137 138

install-php-ini: php.ini
	$(INSTALL_DATA) php.ini $(INSTALL_PHP_CONFIG)/php.ini
139 140 141 142
else
install-scripts install control-install:
	@echo "Cannot install Apache config in dev tree"
endif
143

144
clean:
145
	rm -f $(CONFIG_FILES) *.fixed php.ini