# purposes.
# 1. cd to a clean directory for building (i.e., don't build in your
# source tree)
-# 2. cmake -G "some backend, like 'NMake Makefiles'" \
+# 2. Make sure perl is in your PATH. Additionally, some backends may want
+# your compile tools in PATH. (Hint: "Visual Studio Command Prompt")
+# 3. cmake -G "some backend, like 'NMake Makefiles'" \
# -DCMAKE_INSTALL_PREFIX=d:/path/to/httpdinst \
# -DPCRE_INCLUDE_DIR=d:/path/to/pcreinst/include \
# -DPCRE_LIBRARIES=d:/path/to/pcreinst/lib/pcre[d].lib \
# -DENABLE_MOD_PROXY_HTML="i" (If the prereqs are found, build it but
# don't activate it in the default .conf.)
#
-# 3. build using chosen backend (e.g., "nmake install")
+# Port and SSLPort: port numbers for substitution into default .conf files
+# Defaults are 80 and 443.
+#
+# 4. build using chosen backend (e.g., "nmake install")
#
# Todos for Windows build:
# . Support APR 1.x in addition to APR trunk
-# . Handling of module prerequisites
+# . Support for APR/APU optional features as module prerequisites
+# (e.g., APU_HAVE_CRYPTO requirement of mod_session_crypto)
# . Find support libraries:
# + LUA, distcache
# . Modules not yet supported:
# . Build buildmark.c when httpd.exe is regenerated
# . ab + HAVE_OPENSSL isn't working at all, even for plain
# . ApacheMonitor has a build error
-# . install/customize .conf files
-# . install docroot and CGI examples
-# . install .h fils that are in odd places
+# . install CGI examples
+# . install .h files that are in odd places
# . Sync module enablement defaults with autoconf-based build
# . Generally: go through the existing Windows build and see what is missing, whether a
# feature or some build nuance
ELSE()
# Handle whether or not the LoadModule is commented out.
IF(${enable_mod_val} STREQUAL "A")
- SET(LoadModules ${LoadModules} "LoadModule ${mod_module_name} modules/${mod_name}.so\n")
+ SET(LoadModules "${LoadModules}LoadModule ${mod_module_name} modules/${mod_name}.so\n")
ELSEIF(${enable_mod_val} STREQUAL "I")
- SET(LoadModules ${LoadModules} "# LoadModule ${mod_module_name} modules/${mod_name}.so\n")
+ SET(LoadModules "${LoadModules}# LoadModule ${mod_module_name} modules/${mod_name}.so\n")
ELSE()
MESSAGE(FATAL_ERROR "${enable_mod} must be set to \"A\", \"I\", or \"O\" instead of \"${enable_mod_val}\"")
ENDIF()
SET(install_targets ${install_targets} rotatelogs)
TARGET_LINK_LIBRARIES(rotatelogs ${APR_LIBRARIES})
+########### CONFIGURATION FILES ###########
+# Set up variables used in the .conf file templates
+SET(LoadModule "${LoadModules}")
+SET(Port "80" CACHE STRING "http port to listen on")
+SET(SSLPort "443" CACHE STRING "https port to listen on")
+SET(ServerRoot "${CMAKE_INSTALL_PREFIX}")
+SET(exp_cgidir "${CMAKE_INSTALL_PREFIX}/cgi-bin")
+SET(exp_htdocsdir "${CMAKE_INSTALL_PREFIX}/htdocs")
+SET(exp_iconsdir "${CMAKE_INSTALL_PREFIX}/icons")
+SET(exp_errordir "${CMAKE_INSTALL_PREFIX}/error")
+SET(exp_manualdir "${CMAKE_INSTALL_PREFIX}/manual")
+SET(rel_logfiledir "logs")
+SET(rel_runtimedir "logs")
+SET(rel_sysconfdir "conf")
+FILE(GLOB_RECURSE conffiles RELATIVE ${CMAKE_SOURCE_DIR}/docs/conf "docs/conf/*")
+FOREACH(template ${conffiles})
+ STRING(REPLACE ".conf.in" ".conf" conf ${template})
+ FILE(READ "docs/conf/${template}" template_text)
+ IF(template MATCHES ".conf.in$")
+ # substitute @var@/@@var@@ in .conf.in
+ STRING(REPLACE "@@" "@" template_text ${template_text})
+ STRING(CONFIGURE "${template_text}" template_text @ONLY)
+ ENDIF()
+ FILE(WRITE ${CMAKE_BINARY_DIR}/conf/original/${conf} "${template_text}")
+ FILE(WRITE ${CMAKE_BINARY_DIR}/conf/${conf} "${template_text}")
+ENDFOREACH()
+
+########### INSTALLATION ###########
INSTALL(TARGETS ${install_targets}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
INSTALL(DIRECTORY include/ DESTINATION include
FILES_MATCHING PATTERN "*.h"
)
-INSTALL(DIRECTORY docs/icons/ DESTINATION icons)
-INSTALL(DIRECTORY docs/error/ DESTINATION error)
INSTALL(DIRECTORY docs/manual/ DESTINATION manual
FILES_MATCHING PATTERN "BUILDING" EXCLUDE
)
INSTALL(DIRECTORY DESTINATION logs)
INSTALL(DIRECTORY DESTINATION cgi-bin)
+INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl ${CMAKE_CURRENT_SOURCE_DIR}/error ${CMAKE_INSTALL_PREFIX}/error ifdestmissing)")
+
+INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl ${CMAKE_CURRENT_SOURCE_DIR}/docs/docroot ${CMAKE_INSTALL_PREFIX}/htdocs ifdestmissing)")
+
+INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl ${CMAKE_CURRENT_SOURCE_DIR}/icons ${CMAKE_INSTALL_PREFIX}/icons ifdestmissing)")
+
+# Copy generated .conf files from the build directory to the install,
+# without overwriting stuff already there.
+INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl ${CMAKE_BINARY_DIR}/conf ${CMAKE_INSTALL_PREFIX}/conf)")
+# But conf/original is supposed to be overwritten.
+# Note: FILE(TO_NATIVE_PATH ...) leaves the backslashes unescaped, which
+# generates warnings. Just do it manually since this build only supports
+# Windows anyway.
+STRING(REPLACE "/" "\\\\" native_src ${CMAKE_BINARY_DIR}/conf/original)
+STRING(REPLACE "/" "\\\\" native_dest ${CMAKE_INSTALL_PREFIX}/conf/original)
+INSTALL(CODE "EXECUTE_PROCESS(COMMAND xcopy ${native_src} ${native_dest} /Q /S /Y)")
+
MESSAGE(STATUS "Module selections:")
FOREACH(modsel ${moduleselections})
MESSAGE(STATUS " ${modsel} ${${modsel}}")
--- /dev/null
+#!/usr/bin/perl -w
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use File::Basename;
+use File::Copy;
+use File::Find;
+use File::Path qw(make_path);
+
+my $srcdir;
+my $destdir;
+
+sub process_file {
+ return if $_ =~ /^\./;
+
+ my $rel_to_srcdir = substr($File::Find::name, length($srcdir));
+ my $destfile = "$destdir$rel_to_srcdir";
+
+ if (-d $File::Find::name) {
+ # If the directory is empty, it won't get created.
+ # Otherwise it will get created when copying a file.
+ }
+ else {
+ if (-f $destfile) {
+ # Preserve it.
+ }
+ else {
+ # Create it.
+ my $dir = dirname($destfile);
+ if (! -e $dir) {
+ make_path($dir) or die "Failed to create directory $dir: $!";
+ }
+ copy($File::Find::name, $destfile) or die "Copy $File::Find::name->$destfile failed: $!";
+ }
+ }
+}
+
+$srcdir = shift;
+$destdir = shift;
+if (scalar(@ARGV) > 0) {
+ my $mode = shift;
+ if ($mode eq "ifdestmissing") {
+ # Normally the check for possible overwrite is performed on a
+ # file-by-file basis. If "ifdestmissing" is specified and the
+ # destination directory exists, bail out.
+ if (-d $destdir) {
+ print "[PRESERVING EXISTING SUBDIR $destdir]\n";
+ exit(0);
+ }
+ }
+ else {
+ die "bad mode $mode";
+ }
+}
+find(\&process_file, ($srcdir));