GNUmakefile.in 5.29 KB
Newer Older
1
#
2
# Copyright (c) 2002-2017 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
22 23
#
#
24 25 26 27 28 29
# For installation only.
#
SRCDIR		= @srcdir@
TESTBED_SRCDIR	= @top_srcdir@
OBJDIR		= ..
SUBDIR		= apache
30
PGENISUPPORT    = @PROTOGENI_SUPPORT@
31

32 33 34 35 36 37 38 39 40
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

41 42
include $(OBJDIR)/Makeconf

43 44
OPS_FILES       = httpd.conf-ops php.ini
CONFIG_FILES	= httpd.conf $(OPS_FILES)
45 46 47 48
ifeq ($(PGENISUPPORT),1)
CONFIG_GENI     = httpd-geni.conf
CONFIG_FILES   += $(CONFIG_GENI)
endif
49

50 51 52 53 54
ifeq ($(APACHE_VERSION),24)
# For VPATH.
MOSTLY_SRCDIRS = ${SRCDIR}/v24
SCRIPT_HACK     = 0
else
55
ifeq ($(APACHE_VERSION),22)
56 57
# For VPATH.
MOSTLY_SRCDIRS = ${SRCDIR}/v2
58 59
SCRIPT_HACK     = 0
else
60
MOSTLY_SRCDIRS = ${SRCDIR}/v1
61
endif
62
endif
63
INSTALL_PHP_CONFIG = /usr/local/etc
64

65 66 67 68 69 70
#
# Force dependencies to make sure configure regenerates if the .in file
# is changed.
# 
all: $(CONFIG_FILES)

71 72
control-build: $(OPS_FILES)

73 74
include $(TESTBED_SRCDIR)/GNUmakerules

75 76 77 78 79 80 81 82 83
#
# 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

84 85 86
# Like the INSTALL_ETCDIR target
$(INSTALL_APACHE_CONFIG)/%: %
	@echo "Installing $<"
87
	-mkdir -p $(INSTALL_APACHE_CONFIG)
88 89 90
	$(INSTALL_DATA) $< $@


91 92 93 94 95
#
# 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.
#
96 97
# XXX ugh, do the same thing to detect php5...
#
98
# Note that this is not needed for apache22.
99
#
100 101
httpd.conf.fixed: httpd.conf
	-@cp httpd.conf httpd.conf.fixed
102 103
	@if [ -x /usr/local/libexec/apache/mod_auth_mysql.so ]; then \
            sed -i "" -e '/^LoadModule auth_mysql/s/libauth/mod_auth/' httpd.conf.fixed; \
104 105 106 107 108 109 110 111 112 113 114 115
	    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"; \
116 117
	fi

118 119 120
install-dirs:
	-mkdir -p $(INSTALL_TOPDIR)/www

121 122 123 124 125 126
#
# 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)
127 128 129 130 131 132 133 134
#
# 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.
#
135 136 137 138
# Note that we install apache-emulab as apache.sh to be consistant with
# with what {boss,ops}-install expect.
#
install-scripts: apache-emulab
139 140 141 142
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
143
	$(INSTALL) -m 755 $(SRCDIR)/apache-emulab /usr/local/etc/rc.d/apache.sh
Mike Hibler's avatar
Mike Hibler committed
144
endif
145

Mike Hibler's avatar
Mike Hibler committed
146 147 148 149 150 151 152
ifeq ($(APACHE_VERSION),1.3)
install: install-dirs install-scripts httpd.conf.fixed
	$(INSTALL_DATA) httpd.conf.fixed $(INSTALL_APACHE_CONFIG)/httpd.conf

control-install: install-dirs install-scripts httpd.conf-ops.fixed
	$(INSTALL_DATA) httpd.conf-ops.fixed $(INSTALL_APACHE_CONFIG)/httpd.conf
else
153
install: install-dirs install-scripts httpd.conf pgeni-install
154 155 156 157 158
	$(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

159 160 161 162 163
pgeni-install: $(CONFIG_GENI)
ifeq ($(PGENISUPPORT),1)
	$(INSTALL_DATA) httpd-geni.conf $(INSTALL_APACHE_CONFIG)/httpd-geni.conf
endif

164 165
utah: httpd.conf.utah httpd.conf-ops.utah
endif
166 167 168

install-php-ini: php.ini
	$(INSTALL_DATA) php.ini $(INSTALL_PHP_CONFIG)/php.ini
169 170 171 172
else
install-scripts install control-install:
	@echo "Cannot install Apache config in dev tree"
endif
173

174
clean:
175
	rm -f $(CONFIG_FILES) *.fixed php.ini