Skip to content

Commit 0467577

Browse files
committed
Remove awk dependency when building using CMake. Before this awk was required
for -DWITH_MODULES option. * build/build-modules-c.cmake: (generate_builtin_modules_c): Function to generate modules.c. * CMakeLists.txt (): Use generate_builtin_modules_c() instead of `awk -f build/build-modules-c.awk` to generate modules.c file. * README.cmake: (Prerequisites, How to build): Do not mention awk as prerequisite. Follow-up to r1919413: CMake: Use configure_file() instead of file(write) to generate modules.c file because configure_file() doesn't change timestamp of file if contents is the the same. Follow-up to r1919587: CMake: Fix type in variable name (MODULES_SYNMBOLS -> MODULES_SYMBOLS) Merges r1919413, r1919587, r1919602 from trunk Submitted by: ivan Reviewed by: CTR git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1926319 13f79535-47bb-0310-9956-ffa450edef68
1 parent ebc1f2b commit 0467577

File tree

4 files changed

+81
-21
lines changed

4 files changed

+81
-21
lines changed

CMakeLists.txt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
2121

2222
INCLUDE(CheckSymbolExists)
2323
INCLUDE(CheckCSourceCompiles)
24+
INCLUDE("build/build-modules-c.cmake")
2425

2526
FIND_PACKAGE(LibXml2)
2627
FIND_PACKAGE(Lua51)
@@ -607,26 +608,20 @@ SET(install_targets)
607608
SET(install_bin_pdb)
608609
SET(install_modules) # special handling vs. other installed targets
609610
SET(install_modules_pdb)
610-
SET(builtin_module_shortnames "win32 mpm_winnt http so") # core added automatically
611+
SET(builtin_module_shortnames)
612+
LIST(APPEND builtin_module_shortnames "win32" "mpm_winnt" "http" "so") # core added automatically
611613
SET(extra_builtin_modules) # the ones specified with -DWITH_MODULES=
612614

613-
IF(WITH_MODULES) # modules statically linked with the server
614-
STRING(REPLACE "," ";" WITH_MODULE_LIST ${WITH_MODULES})
615-
FOREACH(static_mod ${WITH_MODULE_LIST})
616-
STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${static_mod})
617-
STRING(REGEX REPLACE "^mod_(.*)\\.c" "\\1" mod_module_name ${mod_basename})
618-
SET(builtin_module_shortnames "${builtin_module_shortnames} ${mod_module_name}")
619-
CONFIGURE_FILE(${static_mod} ${PROJECT_BINARY_DIR}/ COPYONLY)
620-
SET(extra_builtin_modules ${extra_builtin_modules} ${PROJECT_BINARY_DIR}/${mod_basename})
621-
ENDFOREACH()
622-
EXECUTE_PROCESS(COMMAND cmd /c "echo ${builtin_module_shortnames}| awk -f ${CMAKE_CURRENT_SOURCE_DIR}/build/build-modules-c.awk > ${PROJECT_BINARY_DIR}/modules.c" RESULT_VARIABLE rv)
623-
IF(rv)
624-
MESSAGE(FATAL_ERROR "build-modules-c.awk failed (${rv})")
625-
ENDIF()
626-
ELSE()
627-
# no extra built-in modules; use the default modules.c to avoid the awk prereq
628-
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/os/win32/modules.c ${PROJECT_BINARY_DIR}/ COPYONLY)
629-
ENDIF()
615+
STRING(REPLACE "," ";" WITH_MODULE_LIST "${WITH_MODULES}")
616+
FOREACH(static_mod ${WITH_MODULE_LIST})
617+
STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${static_mod})
618+
STRING(REGEX REPLACE "^mod_(.*)\\.c" "\\1" mod_module_name ${mod_basename})
619+
LIST(APPEND builtin_module_shortnames "${mod_module_name}")
620+
CONFIGURE_FILE(${static_mod} ${PROJECT_BINARY_DIR}/ COPYONLY)
621+
SET(extra_builtin_modules ${extra_builtin_modules} ${PROJECT_BINARY_DIR}/${mod_basename})
622+
ENDFOREACH()
623+
624+
generate_builtin_modules_c("${PROJECT_BINARY_DIR}/modules.c" "${builtin_module_shortnames}")
630625

631626
# for easy reference from .dll/.so builds
632627
CONFIGURE_FILE(os/win32/BaseAddr.ref ${PROJECT_BINARY_DIR}/ COPYONLY)

README.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ The following tools must be in PATH:
3434
cmake version 3.1.3 or later is required to work with current OpenSSL
3535
releases. (OpenSSL is an optional prerequisite of httpd.)
3636
* Perl
37-
* If the WITH_MODULES feature is used: awk
3837
* If using a command-line compiler: compiler and linker and related tools
3938
(Refer to the cmake documentation for more information.)
4039

@@ -100,8 +99,6 @@ How to build
10099

101100
2. Make sure cmake and Perl are in PATH. Additionally, some backends
102101
require compile tools in PATH. (Hint: "Visual Studio Command Prompt")
103-
In the unlikely event that you use -DWITH_MODULES, described below, make
104-
sure awk is in PATH.
105102

106103
3. cmake -G "some backend, like 'NMake Makefiles'"
107104
-DCMAKE_INSTALL_PREFIX=d:/path/to/httpdinst

build/build-modules-c.cmake

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
function(generate_builtin_modules_c output_filename module_list)
17+
list(PREPEND module_list "core")
18+
19+
foreach(module ${module_list})
20+
string(APPEND MODULES_EXTERN "extern module ${module}_module;\n")
21+
string(APPEND MODULES_PRELINK " &${module}_module,\n")
22+
string(APPEND MODULES_SYMBOLS " {\"${module}_module\", &${module}_module},\n")
23+
string(APPEND MODULES_PRELOAD " &${module}_module,\n")
24+
endforeach()
25+
26+
configure_file("build/modules.c.in" ${output_filename})
27+
endfunction()

build/modules.c.in

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* modules.c --- automatically generated by Apache
3+
* configuration script. DO NOT HAND EDIT!!!!!
4+
*/
5+
6+
#include "ap_config.h"
7+
#include "httpd.h"
8+
#include "http_config.h"
9+
10+
@MODULES_EXTERN@
11+
/*
12+
* Modules which implicitly form the
13+
* list of activated modules on startup,
14+
* i.e. these are the modules which are
15+
* initially linked into the Apache processing
16+
* [extendable under run-time via AddModule]
17+
*/
18+
AP_DECLARE_DATA module *ap_prelinked_modules[] = {
19+
@MODULES_PRELINK@
20+
NULL
21+
};
22+
23+
/*
24+
* We need the symbols as strings for <IfModule> containers
25+
*/
26+
ap_module_symbol_t ap_prelinked_module_symbols[] = {
27+
@MODULES_SYMBOLS@
28+
{NULL, NULL}
29+
};
30+
31+
/*
32+
* Modules which initially form the
33+
* list of available modules on startup,
34+
* i.e. these are the modules which are
35+
* initially loaded into the Apache process
36+
* [extendable under run-time via LoadModule]
37+
*/
38+
module *ap_preloaded_modules[] = {
39+
@MODULES_PRELOAD@
40+
NULL
41+
};

0 commit comments

Comments
 (0)