Skip to content

Commit 55c5d07

Browse files
author
Ivan Zhakov
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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1919413 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1520350 commit 55c5d07

File tree

3 files changed

+96
-21
lines changed

3 files changed

+96
-21
lines changed

CMakeLists.txt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ PROJECT(HTTPD C)
2323

2424
INCLUDE(CheckSymbolExists)
2525
INCLUDE(CheckCSourceCompiles)
26+
INCLUDE("build/build-modules-c.cmake")
2627

2728
FIND_PACKAGE(LibXml2)
2829
FIND_PACKAGE(Lua51)
@@ -656,26 +657,20 @@ SET(install_targets)
656657
SET(install_bin_pdb)
657658
SET(install_modules) # special handling vs. other installed targets
658659
SET(install_modules_pdb)
659-
SET(builtin_module_shortnames "win32 mpm_winnt http so") # core added automatically
660+
SET(builtin_module_shortnames)
661+
LIST(APPEND builtin_module_shortnames "win32" "mpm_winnt" "http" "so") # core added automatically
660662
SET(extra_builtin_modules) # the ones specified with -DWITH_MODULES=
661663

662-
IF(WITH_MODULES) # modules statically linked with the server
663-
STRING(REPLACE "," ";" WITH_MODULE_LIST ${WITH_MODULES})
664-
FOREACH(static_mod ${WITH_MODULE_LIST})
665-
STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${static_mod})
666-
STRING(REGEX REPLACE "^mod_(.*)\\.c" "\\1" mod_module_name ${mod_basename})
667-
SET(builtin_module_shortnames "${builtin_module_shortnames} ${mod_module_name}")
668-
CONFIGURE_FILE(${static_mod} ${PROJECT_BINARY_DIR}/ COPYONLY)
669-
SET(extra_builtin_modules ${extra_builtin_modules} ${PROJECT_BINARY_DIR}/${mod_basename})
670-
ENDFOREACH()
671-
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)
672-
IF(rv)
673-
MESSAGE(FATAL_ERROR "build-modules-c.awk failed (${rv})")
674-
ENDIF()
675-
ELSE()
676-
# no extra built-in modules; use the default modules.c to avoid the awk prereq
677-
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/os/win32/modules.c ${PROJECT_BINARY_DIR}/ COPYONLY)
678-
ENDIF()
664+
STRING(REPLACE "," ";" WITH_MODULE_LIST "${WITH_MODULES}")
665+
FOREACH(static_mod ${WITH_MODULE_LIST})
666+
STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${static_mod})
667+
STRING(REGEX REPLACE "^mod_(.*)\\.c" "\\1" mod_module_name ${mod_basename})
668+
LIST(APPEND builtin_module_shortnames "${mod_module_name}")
669+
CONFIGURE_FILE(${static_mod} ${PROJECT_BINARY_DIR}/ COPYONLY)
670+
SET(extra_builtin_modules ${extra_builtin_modules} ${PROJECT_BINARY_DIR}/${mod_basename})
671+
ENDFOREACH()
672+
673+
generate_builtin_modules_c("${PROJECT_BINARY_DIR}/modules.c" "${builtin_module_shortnames}")
679674

680675
# for easy reference from .dll/.so builds
681676
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: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
set(content "")
20+
21+
string(APPEND content "/*\n")
22+
string(APPEND content " * modules.c --- automatically generated by Apache\n")
23+
string(APPEND content " * configuration script. DO NOT HAND EDIT!!!!!\n")
24+
string(APPEND content " */\n")
25+
string(APPEND content "\n")
26+
string(APPEND content "#include \"ap_config.h\"\n")
27+
string(APPEND content "#include \"httpd.h\"\n")
28+
string(APPEND content "#include \"http_config.h\"\n")
29+
string(APPEND content "\n")
30+
31+
foreach(module ${module_list})
32+
string(APPEND content "extern module ${module}_module\;\n")
33+
endforeach()
34+
35+
string(APPEND content "\n")
36+
string(APPEND content "/*\n")
37+
string(APPEND content " * Modules which implicitly form the\n")
38+
string(APPEND content " * list of activated modules on startup,\n")
39+
string(APPEND content " * i.e. these are the modules which are\n")
40+
string(APPEND content " * initially linked into the Apache processing\n")
41+
string(APPEND content " * [extendable under run-time via AddModule]\n")
42+
string(APPEND content " */\n")
43+
44+
string(APPEND content "AP_DECLARE_DATA module *ap_prelinked_modules[] = {\n")
45+
foreach(module ${module_list})
46+
string(APPEND content " &${module}_module,\n")
47+
endforeach()
48+
string(APPEND content " NULL\n")
49+
string(APPEND content "}\;\n")
50+
51+
string(APPEND content "\n")
52+
string(APPEND content "/*\n")
53+
string(APPEND content " * We need the symbols as strings for <IfModule> containers\n")
54+
string(APPEND content " */\n")
55+
string(APPEND content "\n")
56+
string(APPEND content "ap_module_symbol_t ap_prelinked_module_symbols[] = {\n")
57+
58+
foreach(module ${module_list})
59+
string(APPEND content " {\"${module}_module\", &${module}_module},\n")
60+
endforeach()
61+
62+
string(APPEND content " {NULL, NULL}\n")
63+
string(APPEND content "}\;\n")
64+
string(APPEND content "\n")
65+
string(APPEND content "/*\n")
66+
string(APPEND content " * Modules which initially form the\n")
67+
string(APPEND content " * list of available modules on startup,\n")
68+
string(APPEND content " * i.e. these are the modules which are\n")
69+
string(APPEND content " * initially loaded into the Apache process\n")
70+
string(APPEND content " * [extendable under run-time via LoadModule]\n")
71+
string(APPEND content " */\n")
72+
string(APPEND content "module *ap_preloaded_modules[] = {\n")
73+
74+
foreach(module ${module_list})
75+
string(APPEND content " &${module}_module,\n")
76+
endforeach()
77+
78+
string(APPEND content " NULL\n")
79+
string(APPEND content "}\;\n")
80+
string(APPEND content "\n")
81+
82+
file(WRITE ${output_filename} ${content})
83+
endfunction()

0 commit comments

Comments
 (0)