You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2013/08/28 22:38:14 UTC

svn commit: r1518376 - in /httpd/httpd/trunk: CMakeLists.txt build/cpR_noreplace.pl

Author: trawick
Date: Wed Aug 28 20:38:14 2013
New Revision: 1518376

URL: http://svn.apache.org/r1518376
Log:
Generate and install .conf files
  (with heavy lifting from tdonovan!).

Install sample docroot (if the top directory doesn't exist).

Change installation of error and icons directories to match
Unix -- only if the top directory doesn't exist.

Provide a simple Perl script to help with non-standard copy
semantics used by the install.

THIS ADDS PERL AS A BUILD PREREQ.  (The VisualStudio-specific
Windows build system required it too.)


Added:
    httpd/httpd/trunk/build/cpR_noreplace.pl   (with props)
Modified:
    httpd/httpd/trunk/CMakeLists.txt

Modified: httpd/httpd/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CMakeLists.txt?rev=1518376&r1=1518375&r2=1518376&view=diff
==============================================================================
--- httpd/httpd/trunk/CMakeLists.txt (original)
+++ httpd/httpd/trunk/CMakeLists.txt Wed Aug 28 20:38:14 2013
@@ -7,7 +7,9 @@ PROJECT(HTTPD C)
 #    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 \
@@ -44,11 +46,15 @@ PROJECT(HTTPD C)
 #                  -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:
@@ -60,9 +66,8 @@ PROJECT(HTTPD C)
 # . 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
@@ -464,9 +469,9 @@ FOREACH (mod ${MODULE_SRCS})
   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()
@@ -551,6 +556,34 @@ ADD_EXECUTABLE(rotatelogs support/rotate
 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
@@ -562,14 +595,29 @@ INSTALL(TARGETS ${install_modules}
 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}}")

Added: httpd/httpd/trunk/build/cpR_noreplace.pl
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/build/cpR_noreplace.pl?rev=1518376&view=auto
==============================================================================
--- httpd/httpd/trunk/build/cpR_noreplace.pl (added)
+++ httpd/httpd/trunk/build/cpR_noreplace.pl Wed Aug 28 20:38:14 2013
@@ -0,0 +1,69 @@
+#!/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));

Propchange: httpd/httpd/trunk/build/cpR_noreplace.pl
------------------------------------------------------------------------------
    svn:eol-style = native