Debian Codegraph @

cmake/configure.cmake

raw
1 # dynamips - configure options
2 # - DYNAMIPS_ARCH
3 # - DYNAMIPS_CODE
4 # - BUILD_NVRAM_EXPORT
5 # - BUILD_UDP_SEND (default OFF)
6 # - BUILD_UDP_RECV (default OFF)
7 # - ENABLE_LARGEFILE
8 # - ENABLE_LINUX_ETH
9 # - ENABLE_GEN_ETH
10 # - ENABLE_IPV6
11 # accumulators:
12 # - DYNAMIPS_FLAGS
13 # - DYNAMIPS_DEFINITIONS
14 # - DYNAMIPS_INCLUDES
15 # - DYNAMIPS_LIBRARIES
16 # XXX assumes utils.cmake and dependencies.cmake were included
17
18 message ( STATUS "configure - BEGIN" )
19
20 # DYNAMIPS_VERSION
21 set ( DYNAMIPS_VERSION "\"${DYNAMIPS_VERSION_TRAIN}${DYNAMIPS_VERSION_SUB}\"" )
22 list ( APPEND DYNAMIPS_DEFINITIONS "-DDYNAMIPS_VERSION=${DYNAMIPS_VERSION}" )
23 message ( STATUS "DYNAMIPS_VERSION=${DYNAMIPS_VERSION}" )
24
25 # Target architecture: (set in dependencies file)
26 # - Use "x86" to build for x86 (32-bit)
27 # - Use "amd64" to build for x86_64 (64-bit)
28 # - Use "nojit" to build for other architectures (no recompilation)
29 set ( JIT_ARCH "\"${DYNAMIPS_ARCH}\"" )
30 set ( JIT_CPU "CPU_${DYNAMIPS_ARCH}" )
31 set ( MIPS64_ARCH_INC_FILE "\"mips64_${DYNAMIPS_ARCH}_trans.h\"" )
32 set ( PPC32_ARCH_INC_FILE "\"ppc32_${DYNAMIPS_ARCH}_trans.h\"" )
33 list ( APPEND DYNAMIPS_DEFINITIONS "-DJIT_ARCH=${JIT_ARCH}" "-DJIT_CPU=${JIT_CPU}"
34 "-DMIPS64_ARCH_INC_FILE=${MIPS64_ARCH_INC_FILE}"
35 "-DPPC32_ARCH_INC_FILE=${PPC32_ARCH_INC_FILE}" )
36 print_variables ( DYNAMIPS_ARCH )
37
38 # Target code:
39 # - "stable"
40 # - "unstable"
41 # - "both" (stable + unstable)
42 # - "none"
43 if ( APPLE )
44 set ( _default "unstable" )
45 else ()
46 set ( _default "stable" )
47 endif ()
48 set ( DYNAMIPS_CODE "${_default}" CACHE STRING "Target code (stable;unstable;both;none)" )
49 set_property ( CACHE DYNAMIPS_ARCH PROPERTY STRINGS "stable" "unstable" "both" "none" )
50 if ( NOT DYNAMIPS_CODE )
51 set ( DYNAMIPS_CODE "${_default}" )
52 endif ()
53 if ( "stable" STREQUAL DYNAMIPS_CODE )
54 set ( BUILD_DYNAMIPS_STABLE ON )
55 set ( BUILD_DYNAMIPS_UNSTABLE OFF )
56 elseif ( "unstable" STREQUAL DYNAMIPS_CODE )
57 set ( BUILD_DYNAMIPS_STABLE OFF )
58 set ( BUILD_DYNAMIPS_UNSTABLE ON )
59 elseif ( "both" STREQUAL DYNAMIPS_CODE )
60 set ( BUILD_DYNAMIPS_STABLE ON )
61 set ( BUILD_DYNAMIPS_UNSTABLE ON )
62 elseif ( "none" STREQUAL DYNAMIPS_CODE )
63 set ( BUILD_DYNAMIPS_STABLE OFF )
64 set ( BUILD_DYNAMIPS_UNSTABLE OFF )
65 else ()
66 message ( FATAL_ERROR "unknown target code DYNAMIPS_CODE=${DYNAMIPS_CODE} (stable;unstable;both;none)" )
67 endif ()
68 print_variables ( DYNAMIPS_CODE BUILD_DYNAMIPS_STABLE BUILD_DYNAMIPS_UNSTABLE )
69
70 # Rename target (auto;stable;unstable;<empty>)
71 # XXX should auto or not renaming be the default?
72 set ( DYNAMIPS_RENAME "auto" CACHE STRING "which executable is renamed to dynamips (auto;stable;unstable;<empty>)" )
73 set_property ( CACHE DYNAMIPS_RENAME PROPERTY STRINGS "auto" "stable" "unstable" )
74 set ( DYNAMIPS_RENAME_TARGET )
75 if ( "auto" STREQUAL DYNAMIPS_RENAME )
76 foreach ( _target "${DYNAMIPS_CODE}" "stable" "unstable" )
77 string ( TOUPPER "BUILD_DYNAMIPS_${_target}" _var )
78 if ( ${_var} )
79 set ( DYNAMIPS_RENAME_TARGET "dynamips_${DYNAMIPS_ARCH}_${_target}" )
80 break ()
81 endif ()
82 endforeach ()
83 elseif ( "stable" STREQUAL DYNAMIPS_RENAME OR "unstable" STREQUAL DYNAMIPS_RENAME )
84 set ( DYNAMIPS_RENAME_TARGET "dynamips_${DYNAMIPS_ARCH}_${DYNAMIPS_RENAME}" )
85 elseif ( DYNAMIPS_RENAME )
86 message ( FATAL_ERROR "unknown rename target DYNAMIPS_RENAME=${DYNAMIPS_RENAME} (auto;stable;unstable;<empty>)" )
87 endif ()
88 print_variables ( DYNAMIPS_RENAME DYNAMIPS_RENAME_TARGET )
89
90 # other executables
91 option ( BUILD_NVRAM_EXPORT "build the nvram_export executable" ON )
92 option ( BUILD_UDP_SEND "build the udp_send executable" OFF )
93 option ( BUILD_UDP_RECV "build the udp_recv executable" OFF )
94 print_variables ( BUILD_NVRAM_EXPORT BUILD_UDP_SEND BUILD_UDP_RECV )
95
96 # ENABLE_LARGEFILE
97 if ( LIBELF_LARGEFILE )
98 option ( ENABLE_LARGEFILE "compile with large file support" ON )
99 endif ()
100 if ( ENABLE_LARGEFILE )
101 list ( APPEND DYNAMIPS_DEFINITIONS "-D_FILE_OFFSET_BITS=64"
102 "-D_LARGEFILE_SOURCE" "-D_LARGEFILE64_SOURCE" )
103 endif ( ENABLE_LARGEFILE )
104
105 # ENABLE_LINUX_ETH
106 if ( "Linux" STREQUAL "${CMAKE_SYSTEM_NAME}" )
107 option ( ENABLE_LINUX_ETH "Linux ethernet support with RAW sockets (linux_eth)" ON )
108 print_variables ( ENABLE_LINUX_ETH )
109 endif ()
110 if ( ENABLE_LINUX_ETH )
111 list ( APPEND DYNAMIPS_DEFINITIONS "-DLINUX_ETH" )
112 endif ()
113
114 # ENABLE_GEN_ETH
115 if ( HAVE_PCAP )
116 option ( ENABLE_GEN_ETH "Generic Ethernet support with libpcap/winpcap (gen_eth)" ON )
117 print_variables ( ENABLE_GEN_ETH )
118 endif ()
119 if ( ENABLE_GEN_ETH )
120 list ( APPEND DYNAMIPS_DEFINITIONS "-DGEN_ETH" )
121 list ( APPEND DYNAMIPS_LIBRARIES ${PCAP_LIBRARIES} )
122 endif ()
123
124 # ENABLE_IPV6
125 if ( HAVE_IPV6 )
126 option ( ENABLE_IPV6 "IPv6 support (RFC 2553)" ON )
127 print_variables ( ENABLE_IPV6 )
128 endif ()
129 if ( ENABLE_IPV6 )
130 list ( APPEND DYNAMIPS_DEFINITIONS "-DHAS_RFC2553=1" )
131 else ()
132 list ( APPEND DYNAMIPS_DEFINITIONS "-DHAS_RFC2553=0" )
133 endif ()
134
135 # target system
136 if ( "SunOS" STREQUAL "${CMAKE_SYSTEM_NAME}" )
137 list ( APPEND DYNAMIPS_DEFINITIONS "-DSUNOS" "-DINADDR_NONE=0xFFFFFFFF" )
138 endif ()
139 if ( CYGWIN )
140 list ( APPEND DYNAMIPS_DEFINITIONS "-DCYGWIN" )
141 endif ()
142 if ( "CYGWIN" STREQUAL "${CMAKE_SYSTEM_NAME}" )
143 # XXX maybe keep it as CYGWIN?
144 set ( OSNAME "Windows" )
145 elseif ( CMAKE_SYSTEM_NAME )
146 set ( OSNAME "${CMAKE_SYSTEM_NAME}" )
147 else ()
148 print_variables ( CMAKE_SYSTEM CMAKE_SYSTEM_NAME CMAKE_SYSTEM_PROCESSOR
149 CMAKE_SYSTEM_VERSION )
150 message ( WARNING "missing system name" )
151 set ( OSNAME "unknown" )
152 endif ()
153 list ( APPEND DYNAMIPS_DEFINITIONS "-DOSNAME=${OSNAME}" )
154
155 # final setup
156 include ( GNUInstallDirs )
157 set ( CMAKE_C_FLAGS )
158 foreach ( _flag ${DYNAMIPS_FLAGS} )
159 set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" )
160 endforeach ()
161 string ( STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS )
162 add_definitions ( ${DYNAMIPS_DEFINITIONS} )
163 include_directories ( ${DYNAMIPS_INCLUDES} )
164 print_variables ( DYNAMIPS_FLAGS DYNAMIPS_DEFINITIONS DYNAMIPS_INCLUDES DYNAMIPS_LIBRARIES )
165
166 # summary
167 macro ( print_summary )
168 message ( "Summary:" )
169 message ( " CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}" )
170 message ( " DYNAMIPS_ARCH : ${DYNAMIPS_ARCH}" )
171 message ( " DYNAMIPS_CODE : ${DYNAMIPS_CODE}" )
172 if ( DYNAMIPS_RENAME_TARGET )
173 set ( _rename "${DYNAMIPS_RENAME_TARGET} -> dynamips" )
174 else ()
175 set ( _rename "don't rename" )
176 endif ()
177 message ( " DYNAMIPS_RENAME : ${_rename} (${DYNAMIPS_RENAME})" )
178 message ( " BUILD_NVRAM_EXPORT : ${BUILD_NVRAM_EXPORT}" )
179 message ( " BUILD_UDP_SEND : ${BUILD_UDP_SEND}" )
180 message ( " BUILD_UDP_RECV : ${BUILD_UDP_RECV}" )
181 if ( DEFINED ENABLE_LARGEFILE )
182 set ( _largefile "ENABLE_LARGEFILE=${ENABLE_LARGEFILE}" )
183 else ()
184 set ( _largefile "libelf is incompatible" )
185 endif ()
186 message ( " Large File support : ${_largefile}" )
187 if ( DEFINED ENABLE_LINUX_ETH )
188 set ( _linux_eth "ENABLE_LINUX_ETH=${ENABLE_LINUX_ETH}" )
189 else ()
190 set ( _linux_eth "no, not Linux" )
191 endif ()
192 message ( " Linux Ethernet (RAW sockets) : ${_linux_eth} (linux_eth)" )
193 if ( DEFINED ENABLE_GEN_ETH )
194 set ( _gen_eth "ENABLE_GEN_ETH=${ENABLE_GEN_ETH}" )
195 else ()
196 set ( _gen_eth "libpcap/winpcap not found" )
197 endif ()
198 message ( " Generic Ethernet (libpcap/WinPcap) : ${_gen_eth} (gen_eth)" )
199 if ( DEFINED ENABLE_IPV6 )
200 set ( _ipv6 "ENABLE_IPV6=${ENABLE_IPV6}" )
201 else ()
202 set ( _ipv6 "no, missing headers or functions" )
203 endif ()
204 message ( " IPv6 support (RFC 2553) : ${_ipv6}" )
205 endmacro ( print_summary )
206
207 message ( STATUS "configure - END" )