├── .gitignore ├── LICENSE ├── README.md ├── TODO ├── bindifflib.py ├── bindifflib_exporter.py ├── cmake ├── bzip2 │ └── all.cmake ├── iconv │ └── all.cmake ├── libjpeg │ └── all.cmake ├── libpcap │ ├── libpcap-1.8.0.cmake │ └── libpcap-1.8.X.cmake ├── libtiff │ └── all.cmake ├── libxml2 │ └── all.cmake ├── pcre │ └── pcre-8.40.cmake ├── pcre2 │ └── pcre2-10.22.cmake ├── tinyxml │ └── all.cmake ├── xz │ └── all.cmake └── zlib │ ├── zlib-1.2.5.cmake │ └── zlib-1.2.6.cmake ├── compilers.yml ├── ida_plugin.py ├── libs.yml ├── modules ├── __init__.py ├── buildwrapper.py ├── dependency.py ├── downloader.py ├── extractors.py ├── handler.py └── ida.py ├── requirements.txt └── settings.yml /.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | **/__pycache__/* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 G Data Advanced Analytics GmbH 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Disclaimer 2 | ========== 3 | This repository contains code that is rather a solid POC than an professionally developed piece of software. The author does not take any responsibilities if using this code damages your system. 4 | 5 | The author intends to re-write the whole code but he probably won't do this until he feels pressured enough to start doing it. Thus, the code is just made public so that it does not get lost over time and maybe someone finds this useful and uses it. 6 | 7 | 8 | bindifflib 9 | ========== 10 | In general, the whole code is more or less a wrapper around CMake which allows to compile a list of libraries (defined in libs.yml) with a set of different compilers (currently only Visual Studio compilers on a Windows host system). Nevertheless, one can also specify build scripts which are executed as batch files. 11 | 12 | After compiling, this framework also takes all DLLs which have a corresponding PDB along and puts them into IDA Pro to generate IDB files for which (mostly) all functions have their names correctly set in the database (based on the PDB files generated by Visual Studio). 13 | 14 | 15 | libs.yml 16 | ============= 17 | The `libs.yml` contains the configuration for all the libraries that shoulb be built using _bindifflib_. For an example on how to use the file, please refer to the preconfigured `libs.yml` shipped with _bindifflib_. 18 | Basically, the file contains a list of libraries which can have several settings. Libraries are configured like this: 19 | ```yml 20 | libs: 21 | : 22 | 23 | : 24 | 25 | ``` 26 | The possible configuration values can be: 27 | - **name**: (short) name of library, can be used to group several different libraries under one single name; does not have to be unique 28 | - **url**: url template for the package download which must have `{version}` at least one time somewhere inside, e.g. `https://ftp.pcre.org/pub/pcre/pcre2-{version}.tar.gz` (single occurrence) or `http://www.bzip.org/{version}/bzip2-{version}.tar.gz` (multiple occurrences). **Cannot be used together with `urls`!** The following protocols can be handled: 29 | - http(s) 30 | - ftp 31 | - **urls**: a list of urls that point to source archives for the library. `bindifflib` tries to get the library version from the url using the regex `/\/[-_](.*)\.$/`. **Cannot be used together with `url`!** 32 | - **versions**: a list of versions of the given library to be downloaded and built, the values from here will be put into the URL template as `version`. 33 | - **filetype**: type of downloaded file, can be one of: 34 | * tar.gz 35 | * zip 36 | - **cmakeflags**: list of custom cmake flags to change the default behaviour of the CMakeLists.txt of the library; e.g.: 37 | 38 | ```yml 39 | cmakeflags: 40 | - PCRE2_BUILD_TESTS=OFF 41 | - BUILD_SHARED_LIBS=ON 42 | ``` 43 | - **extracts_to_subfolder**: specifies whether the archive of the library unpacks plain files or unpacks into a subfolder; can be `true` or `false` 44 | - **dependencies**: list of dependencies of the library - caution: **the dependencies need to be part of the list of libraries!** this is just something like a "reference" within the list 45 | - *all*: dependencies for all versions 46 | - *\*: one may want to specify a certain version of a dependency for a certain version of the library (e.g. because of API changes etc) or just add an additional dependency. This can be done using something like the following - the values from `all` are overwritten if the name of the library matches: 47 | 48 | ```yml 49 | dependencies: 50 | all: 51 | bzip2: "1.0.6" 52 | zlib: "1.2.11" 53 | : 54 | bzip2: "1.0.4" 55 | ``` 56 | 57 | - **customcmake**: allows to specify a custom CMake file to build the library; may be of use if the one of the library has a bug or if the library does not provide one at all. The custom CMake file has to be placed in the `cmake` subfolder and the config value is the full path within the directory. The `customcmake` allows for providing different CMake files for different targets. Works similar to the targets of `dependencies`. The file will be copied over to `source_dir/CMakeLists.txt` and will overwrite any existing CMakeLists.txt without asking or warning. 58 | 59 | ```yml 60 | customcmake: 61 | "10.22": pcre2/pcre2-10.22.cmake 62 | ``` 63 | 64 | - **custombuild**: a list of commands that need to be used to compile the library; the commands will be put into a temporary batch file in the exact same order as they are written in the config file 65 | - **64bit**: can be `true` or `false`; allows for disabling the 64bit build of the library 66 | 67 | 68 | 69 | compilers.yml 70 | ============= 71 | 72 | ```yml 73 | : 74 | generator: 75 | short: 76 | vcvarsall: 303 | # as well, just in case some platform is really weird. 304 | # 305 | check_include_file( ifaddrs.h HAVE_IFADDRS_H ) 306 | if( ${HAVE_IFADDRS_H} ) 307 | # 308 | # We have the header, so we use "getifaddrs()" to 309 | # get the list of interfaces. 310 | # 311 | set( FINDALLDEVS_TYPE getad ) 312 | else() 313 | # 314 | # We don't have the header - give up. 315 | # XXX - we could also fall back on some other 316 | # mechanism, but, for now, this'll catch this 317 | # problem so that we can at least try to figure 318 | # out something to do on systems with "getifaddrs()" 319 | # but without "ifaddrs.h", if there is something 320 | # we can do on those systems. 321 | # 322 | message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable ." ) 323 | endif() 324 | else() 325 | # 326 | # Well, we don't have "getifaddrs()", so we have to use 327 | # some other mechanism; determine what that mechanism is. 328 | # 329 | # The first thing we use is the type of capture mechanism, 330 | # which is somewhat of a proxy for the OS we're using. 331 | # 332 | if( ${PCAP_TYPE} STREQUAL "dlpi" OR ${PCAP_TYPE} STREQUAL "libdlpi" ) 333 | # 334 | # This might be Solaris 8 or later, with 335 | # SIOCGLIFCONF, or it might be some other OS 336 | # or some older version of Solaris, with 337 | # just SIOCGIFCONF. 338 | # 339 | try_compile( HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/config/have_siocglifconf.c" ) 340 | message( STATUS "HAVE_SIOCGLIFCONF = ${HAVE_SIOCGLIFCONF}" ) 341 | if( HAVE_SIOCGLIFCONF ) 342 | set( FINDALLDEVS_TYPE glifc ) 343 | else() 344 | set( FINDALLDEVS_TYPE gifc ) 345 | endif() 346 | else() 347 | # 348 | # Assume we just have SIOCGIFCONF. 349 | # (XXX - on at least later Linux kernels, there's 350 | # another mechanism, and we should be using that 351 | # instead.) 352 | # 353 | set( FINDALLDEVS_TYPE gifc ) 354 | endif() 355 | endif() 356 | endif() 357 | message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}") 358 | set( PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c ) 359 | endif() 360 | 361 | file(GLOB PROJECT_SOURCE_LIST_CORE_H 362 | *.h 363 | pcap/*.h 364 | ) 365 | set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_CORE_H} ) 366 | 367 | if( WIN32 ) 368 | file(GLOB PROJECT_SOURCE_LIST_WIN32_H 369 | Win32/Include/*.h 370 | ) 371 | set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_WIN32_H} ) 372 | endif( WIN32 ) 373 | 374 | # 375 | # {Flex} and YACC/Berkeley YACC/Bison. 376 | # From a mail message to the CMake mailing list by Andy Cedilnik of 377 | # Kitware. 378 | # 379 | 380 | # 381 | # Try to find Flex, a Windows version of Flex, or Lex. 382 | # 383 | find_program(LEX_EXECUTABLE NAMES flex win_flex lex) 384 | if( ${LEX_EXECUTABLE} STREQUAL "LEX_EXECUTABLE-NOTFOUND" ) 385 | message(FATAL_ERROR "Neither flex nor win_flex nor lex was found." ) 386 | endif() 387 | message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}") 388 | 389 | add_custom_command( 390 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h 391 | SOURCE ${pcap_SOURCE_DIR}/scanner.l 392 | COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=scanner.h --nounput -o${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${pcap_SOURCE_DIR}/scanner.l 393 | DEPENDS ${pcap_SOURCE_DIR}/scanner.l 394 | ) 395 | 396 | # 397 | # Since scanner.c does not exist yet when cmake is run, mark 398 | # it as generated. 399 | # 400 | # Since scanner.c includes grammar.h, mark that as a dependency. 401 | # 402 | set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES 403 | GENERATED TRUE 404 | OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h 405 | ) 406 | 407 | # 408 | # Add scanner.c to the list of sources. 409 | # 410 | #set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/scanner.c) 411 | 412 | # 413 | # Try to find YACC or Bison. 414 | # 415 | find_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc) 416 | if( ${YACC_EXECUTABLE} STREQUAL "YACC_EXECUTABLE-NOTFOUND" ) 417 | message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found." ) 418 | endif() 419 | message(STATUS "Parser generator: ${YACC_EXECUTABLE}") 420 | 421 | # 422 | # Create custom command for the scanner. 423 | # Find out whether it's Bison or notby looking at the last component 424 | # of the path (without a .exe extension, if this is Windows). 425 | # 426 | get_filename_component(YACC_NAME ${YACC_EXECUTABLE} NAME_WE) 427 | if( "${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison" ) 428 | set( YACC_COMPATIBILITY_FLAG "-y" ) 429 | endif() 430 | add_custom_command( 431 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h 432 | SOURCE ${pcap_SOURCE_DIR}/grammar.y 433 | COMMAND ${YACC_EXECUTABLE} ${YACC_COMPATIBILITY_FLAG} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_SOURCE_DIR}/grammar.y 434 | DEPENDS ${pcap_SOURCE_DIR}/grammar.y 435 | ) 436 | 437 | # 438 | # Since grammar.c does not exists yet when cmake is run, mark 439 | # it as generated. 440 | # 441 | set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES 442 | GENERATED TRUE 443 | ) 444 | 445 | # 446 | # Add grammar.c to the list of sources. 447 | # 448 | #set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c) 449 | 450 | source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C}) 451 | source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H}) 452 | 453 | ###################################### 454 | # Register targets 455 | ###################################### 456 | 457 | add_library(${LIBRARY_NAME} 458 | ${PROJECT_SOURCE_LIST_C} 459 | ${CMAKE_CURRENT_BINARY_DIR}/grammar.c 460 | ${CMAKE_CURRENT_BINARY_DIR}/scanner.c 461 | ${PROJECT_SOURCE_LIST_H} 462 | ) 463 | 464 | if( WIN32 ) 465 | target_link_libraries ( ${LIBRARY_NAME} 466 | packet 467 | ws2_32 468 | ) 469 | endif( WIN32 ) 470 | 471 | ###################################### 472 | # Write out the config.h file 473 | ###################################### 474 | 475 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 476 | 477 | install(TARGETS ${LIBRARY_NAME} 478 | RUNTIME DESTINATION bin 479 | LIBRARY DESTINATION lib) -------------------------------------------------------------------------------- /cmake/libpcap/libpcap-1.8.X.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 2.8.8 ) 2 | 3 | project( pcap ) 4 | 5 | if (MSVC_VERSION LESS 1700) 6 | message("visual studio 10 or older not supported") 7 | return () 8 | endif() 9 | 10 | # 11 | # Call the library "wpcap" on Windows, for backwards compatibility. 12 | # 13 | if( WIN32 ) 14 | set( LIBRARY_NAME wpcap ) 15 | else() 16 | set( LIBRARY_NAME pcap ) 17 | endif() 18 | 19 | ################################################################### 20 | # Parameters 21 | ################################################################### 22 | 23 | option (INET6 "Enable IPv6" ON) 24 | if( MSVC ) 25 | option (USE_STATIC_RT "Use static Runtime" ON) 26 | endif( MSVC ) 27 | option (BUILD_SHARED_LIBS "Build shared libraries" ON) 28 | if( WIN32 ) 29 | set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll") 30 | endif( WIN32 ) 31 | 32 | # 33 | # XXX - this should be an option, defaulting to "yes" for Windows and to 34 | # "no", for now, on UN*X. 35 | # 36 | # if( WIN32 ) 37 | # set( HAVE_REMOTE 1 ) 38 | # endif( WIN32 ) 39 | 40 | # 41 | # XXX - these should be settable as options for WinPcap vs. Npcap. 42 | # 43 | if( WIN32 ) 44 | add_definitions( -DWINPCAP_VER_STRING=\"4.0\" ) 45 | add_definitions( -DWINPCAP_PRODUCT_NAME=\"WinPcap\" ) 46 | endif( WIN32 ) 47 | 48 | ###################################### 49 | # Project setings 50 | ###################################### 51 | 52 | add_definitions( -DHAVE_CONFIG_H ) 53 | 54 | include_directories( 55 | ${CMAKE_CURRENT_BINARY_DIR} 56 | ${pcap_SOURCE_DIR} 57 | ) 58 | 59 | if( WIN32 ) 60 | if( NOT "${PACKET_DLL_DIR}" STREQUAL "" ) 61 | include_directories("${PACKET_DLL_DIR}/Include") 62 | if( CMAKE_CL_64 ) 63 | link_directories("${PACKET_DLL_DIR}/Lib/x64") 64 | else( CMAKE_CL_64 ) 65 | link_directories("${PACKET_DLL_DIR}/Lib") 66 | endif( CMAKE_CL_64 ) 67 | endif() 68 | include_directories( 69 | ../Common/ 70 | Win32/Include 71 | ) 72 | endif( WIN32) 73 | 74 | add_definitions( -DBUILDING_PCAP ) 75 | 76 | if( MSVC ) 77 | add_definitions( -D__STDC__ ) 78 | add_definitions( -D_CRT_SECURE_NO_WARNINGS ) 79 | add_definitions( "-D_U_=" ) 80 | elseif( CMAKE_COMPILER_IS_GNUCXX ) 81 | add_definitions( "-D_U_=__attribute__((unused))" ) 82 | else(MSVC) 83 | add_definitions( "-D_U_=" ) 84 | endif( MSVC ) 85 | 86 | if( MSVC ) 87 | if (USE_STATIC_RT) 88 | MESSAGE( STATUS "Use STATIC runtime" ) 89 | set(NAME_RT MT) 90 | set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT") 91 | set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT") 92 | set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") 93 | set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") 94 | 95 | set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT") 96 | set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT") 97 | set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") 98 | set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") 99 | else (USE_STATIC_RT) 100 | MESSAGE( STATUS "Use DYNAMIC runtime" ) 101 | set(NAME_RT MD) 102 | set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD") 103 | set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD") 104 | set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") 105 | set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") 106 | 107 | set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD") 108 | set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD") 109 | set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD") 110 | set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd") 111 | endif (USE_STATIC_RT) 112 | endif( MSVC ) 113 | 114 | ################################################################### 115 | # Detect available platform features 116 | ################################################################### 117 | 118 | include(CheckIncludeFile) 119 | include(CheckFunctionExists) 120 | include(CheckStructHasMember) 121 | include(CheckTypeSize) 122 | 123 | # 124 | # Header files. 125 | # 126 | check_include_file( inttypes.h HAVE_INTTYPES_H ) 127 | check_include_file( stdint.h HAVE_STDINT_H ) 128 | check_include_file( unistd.h HAVE_UNISTD_H ) 129 | if( NOT HAVE_UNISTD_H ) 130 | add_definitions( -DYY_NO_UNISTD_H ) 131 | endif( NOT HAVE_UNISTD_H ) 132 | check_include_file( bitypes.h HAVE_SYS_BITYPES_H ) 133 | check_include_file( limits.h HAVE_LIMITS_H ) 134 | 135 | # 136 | # Functions. 137 | # 138 | check_function_exists( strerror HAVE_STRERROR ) 139 | check_function_exists( strlcpy HAVE_STRLCPY ) 140 | check_function_exists( snprintf HAVE_SNPRINTF ) 141 | check_function_exists( vsnprintf HAVE_VSNPRINTF ) 142 | 143 | if (WIN32) 144 | # 145 | # Check for Windows-only functions, such as packet.dll functions. 146 | # 147 | check_function_exists( PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER ) 148 | endif() 149 | 150 | # 151 | # Data types. 152 | # 153 | # XXX - there's no check_struct() macro that's like check_struct_has_member() 154 | # except that it only checks for the existence of the structure type, 155 | # so we use check_struct_has_member() and look for ss_family. 156 | # 157 | check_struct_has_member("struct sockaddr_storage" ss_family sys/socket.h HAVE_SOCKADDR_STORAGE) 158 | set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h) 159 | check_type_size("socklen_t" SOCKLEN_T) 160 | set(CMAKE_EXTRA_INCLUDE_FILES unistd.h) 161 | 162 | # 163 | # Structure fields. 164 | # 165 | check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_SOCKADDR_SA_LEN ) 166 | 167 | if( INET6 ) 168 | MESSAGE( STATUS "Use IPv6" ) 169 | endif( INET6 ) 170 | 171 | if( WIN32 ) 172 | add_definitions( -DHAVE_ADDRINFO ) 173 | endif( WIN32 ) 174 | 175 | ###################################### 176 | # External dependencies 177 | ###################################### 178 | 179 | ###################################### 180 | # Input files 181 | ###################################### 182 | 183 | set(PROJECT_SOURCE_LIST_C 184 | bpf_dump.c 185 | bpf_image.c 186 | etherent.c 187 | fad-helpers.c 188 | gencode.c 189 | inet.c 190 | nametoaddr.c 191 | optimize.c 192 | pcap-common.c 193 | pcap.c 194 | savefile.c 195 | sf-pcap-ng.c 196 | sf-pcap.c 197 | bpf/net/bpf_filter.c 198 | ) 199 | 200 | if( WIN32 ) 201 | set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/win_snprintf.c ) 202 | else() 203 | if( NOT HAVE_SNPRINTF ) 204 | set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c ) 205 | endif( NOT HAVE_SNPRINTF ) 206 | endif( WIN32 ) 207 | 208 | if( HAVE_REMOTE ) 209 | set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} 210 | pcap-new.c pcap-remote.c sockutils.c) 211 | endif( HAVE_REMOTE ) 212 | 213 | # 214 | # Determine the main pcap-XXX.c file to use. 215 | # 216 | if( WIN32 ) 217 | # 218 | # WinPcap. 219 | # 220 | set( PCAP_TYPE win32 ) 221 | else() 222 | # 223 | # UN*X - figure out what type of packet capture mechanism we 224 | # have. 225 | # 226 | if( EXISTS /dev/bpf ) 227 | # 228 | # Cloning BPF device. 229 | # 230 | set( PCAP_TYPE bpf ) 231 | AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device]) 232 | elseif( EXISTS /dev/bpf0 ) 233 | set( PCAP_TYPE bpf ) 234 | 235 | # 236 | # XXX - many more BPF checks. 237 | # 238 | elseif( EXISTS /usr/include/net/pfilt.h ) 239 | # 240 | # DEC OSF/1, Digital UNIX, Tru64 UNIX 241 | # 242 | set( PCAP_TYPE pf ) 243 | elseif( EXISTS /dev/enet ) 244 | set( PCAP_TYPE enet ) 245 | elseif( EXISTS /dev/nit ) 246 | set( PCAP_TYPE snit ) 247 | elseif( EXISTS /usr/include/sys/net/nit.h ) 248 | set( PCAP_TYPE nit ) 249 | elseif( EXISTS /usr/include/linux/socket.h ) 250 | set( PCAP_TYPE linux ) 251 | 252 | # 253 | # Do we have the wireless extensions? 254 | # 255 | check_include_file( linux/wireless.h HAVE_LINUX_WIRELESS_H ) 256 | 257 | # 258 | # XXX - many more Linux checks. 259 | # 260 | elseif( EXISTS /usr/include/net/raw.h ) 261 | set( PCAP_TYPE snoop ) 262 | elseif( EXISTS /usr/include/odmi.h ) 263 | # 264 | # On AIX, the BPF devices might not yet be present - they're 265 | # created the first time libpcap runs after booting. 266 | # We check for odmi.h instead. 267 | # 268 | set( PCAP_TYPE bpf ) 269 | elseif( /usr/include/sys/dlpi.h ) 270 | set( PCAP_TYPE dlpi ) 271 | 272 | # 273 | # XXX - many more DLPI checks. 274 | # 275 | else() 276 | set( PCAP_TYPE null ) 277 | endif() 278 | endif( WIN32 ) 279 | message(STATUS "Packet capture mechanism type: ${PCAP_TYPE}") 280 | set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-${PCAP_TYPE}.c) 281 | 282 | # 283 | # Now figure out how we get a list of interfaces and addresses, 284 | # if we support capturing. Don't bother if we don't support 285 | # capturing. 286 | # 287 | if( NOT WIN32 ) 288 | # 289 | # UN*X - figure out what type of interface list mechanism we 290 | # have. 291 | # 292 | if( ${PCAP_TYPE} STREQUAL "null" ) 293 | # 294 | # We can't capture, so we can't open any capture 295 | # devices, so we won't return any interfaces. 296 | # 297 | set( FINDALLDEVS_TYPE null ) 298 | else() 299 | check_function_exists( getifaddrs HAVE_GETIFADDRS ) 300 | if( ${HAVE_GETIFADDRS} ) 301 | # 302 | # We have "getifaddrs()"; make sure we have 303 | # as well, just in case some platform is really weird. 304 | # 305 | check_include_file( ifaddrs.h HAVE_IFADDRS_H ) 306 | if( ${HAVE_IFADDRS_H} ) 307 | # 308 | # We have the header, so we use "getifaddrs()" to 309 | # get the list of interfaces. 310 | # 311 | set( FINDALLDEVS_TYPE getad ) 312 | else() 313 | # 314 | # We don't have the header - give up. 315 | # XXX - we could also fall back on some other 316 | # mechanism, but, for now, this'll catch this 317 | # problem so that we can at least try to figure 318 | # out something to do on systems with "getifaddrs()" 319 | # but without "ifaddrs.h", if there is something 320 | # we can do on those systems. 321 | # 322 | message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable ." ) 323 | endif() 324 | else() 325 | # 326 | # Well, we don't have "getifaddrs()", so we have to use 327 | # some other mechanism; determine what that mechanism is. 328 | # 329 | # The first thing we use is the type of capture mechanism, 330 | # which is somewhat of a proxy for the OS we're using. 331 | # 332 | if( ${PCAP_TYPE} STREQUAL "dlpi" OR ${PCAP_TYPE} STREQUAL "libdlpi" ) 333 | # 334 | # This might be Solaris 8 or later, with 335 | # SIOCGLIFCONF, or it might be some other OS 336 | # or some older version of Solaris, with 337 | # just SIOCGIFCONF. 338 | # 339 | try_compile( HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/config/have_siocglifconf.c" ) 340 | message( STATUS "HAVE_SIOCGLIFCONF = ${HAVE_SIOCGLIFCONF}" ) 341 | if( HAVE_SIOCGLIFCONF ) 342 | set( FINDALLDEVS_TYPE glifc ) 343 | else() 344 | set( FINDALLDEVS_TYPE gifc ) 345 | endif() 346 | else() 347 | # 348 | # Assume we just have SIOCGIFCONF. 349 | # (XXX - on at least later Linux kernels, there's 350 | # another mechanism, and we should be using that 351 | # instead.) 352 | # 353 | set( FINDALLDEVS_TYPE gifc ) 354 | endif() 355 | endif() 356 | endif() 357 | message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}") 358 | set( PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c ) 359 | endif() 360 | 361 | file(GLOB PROJECT_SOURCE_LIST_CORE_H 362 | *.h 363 | pcap/*.h 364 | ) 365 | set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_CORE_H} ) 366 | 367 | if( WIN32 ) 368 | file(GLOB PROJECT_SOURCE_LIST_WIN32_H 369 | Win32/Include/*.h 370 | ) 371 | set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_WIN32_H} ) 372 | endif( WIN32 ) 373 | 374 | # 375 | # {Flex} and YACC/Berkeley YACC/Bison. 376 | # From a mail message to the CMake mailing list by Andy Cedilnik of 377 | # Kitware. 378 | # 379 | 380 | # 381 | # Try to find Flex, a Windows version of Flex, or Lex. 382 | # 383 | find_program(LEX_EXECUTABLE NAMES flex win_flex lex) 384 | if( ${LEX_EXECUTABLE} STREQUAL "LEX_EXECUTABLE-NOTFOUND" ) 385 | message(FATAL_ERROR "Neither flex nor win_flex nor lex was found." ) 386 | endif() 387 | message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}") 388 | 389 | add_custom_command( 390 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h 391 | SOURCE ${pcap_SOURCE_DIR}/scanner.l 392 | COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=scanner.h --nounput -o${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${pcap_SOURCE_DIR}/scanner.l 393 | DEPENDS ${pcap_SOURCE_DIR}/scanner.l 394 | ) 395 | 396 | # 397 | # Since scanner.c does not exist yet when cmake is run, mark 398 | # it as generated. 399 | # 400 | # Since scanner.c includes grammar.h, mark that as a dependency. 401 | # 402 | set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES 403 | GENERATED TRUE 404 | OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h 405 | ) 406 | 407 | # 408 | # Add scanner.c to the list of sources. 409 | # 410 | #set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/scanner.c) 411 | 412 | # 413 | # Try to find YACC or Bison. 414 | # 415 | find_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc) 416 | if( ${YACC_EXECUTABLE} STREQUAL "YACC_EXECUTABLE-NOTFOUND" ) 417 | message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found." ) 418 | endif() 419 | message(STATUS "Parser generator: ${YACC_EXECUTABLE}") 420 | 421 | # 422 | # Create custom command for the scanner. 423 | # Find out whether it's Bison or notby looking at the last component 424 | # of the path (without a .exe extension, if this is Windows). 425 | # 426 | get_filename_component(YACC_NAME ${YACC_EXECUTABLE} NAME_WE) 427 | if( "${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison" ) 428 | set( YACC_COMPATIBILITY_FLAG "-y" ) 429 | endif() 430 | add_custom_command( 431 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h 432 | SOURCE ${pcap_SOURCE_DIR}/grammar.y 433 | COMMAND ${YACC_EXECUTABLE} ${YACC_COMPATIBILITY_FLAG} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_SOURCE_DIR}/grammar.y 434 | DEPENDS ${pcap_SOURCE_DIR}/grammar.y 435 | ) 436 | 437 | # 438 | # Since grammar.c does not exists yet when cmake is run, mark 439 | # it as generated. 440 | # 441 | set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES 442 | GENERATED TRUE 443 | ) 444 | 445 | # 446 | # Add grammar.c to the list of sources. 447 | # 448 | #set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c) 449 | 450 | source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C}) 451 | source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H}) 452 | 453 | ###################################### 454 | # Register targets 455 | ###################################### 456 | 457 | add_library(${LIBRARY_NAME} 458 | ${PROJECT_SOURCE_LIST_C} 459 | ${CMAKE_CURRENT_BINARY_DIR}/grammar.c 460 | ${CMAKE_CURRENT_BINARY_DIR}/scanner.c 461 | ${PROJECT_SOURCE_LIST_H} 462 | ) 463 | 464 | if( WIN32 ) 465 | target_link_libraries ( ${LIBRARY_NAME} 466 | packet 467 | ws2_32 468 | ) 469 | endif( WIN32 ) 470 | 471 | ###################################### 472 | # Write out the config.h file 473 | ###################################### 474 | 475 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 476 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcap_version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/pcap_version.h) 477 | 478 | install(TARGETS ${LIBRARY_NAME} 479 | RUNTIME DESTINATION bin 480 | LIBRARY DESTINATION lib) -------------------------------------------------------------------------------- /cmake/libtiff/all.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.7) 2 | 3 | project(libtiff) 4 | 5 | Find_Package(zlib) 6 | Find_Package(jpeg) 7 | 8 | set (SOURCES port/strcasecmp.c port/getopt.c 9 | libtiff/tif_aux.c libtiff/tif_close.c libtiff/tif_codec.c 10 | libtiff/tif_color.c libtiff/tif_compress.c libtiff/tif_dir.c 11 | libtiff/tif_dirinfo.c libtiff/tif_dirread.c libtiff/tif_dirwrite.c 12 | libtiff/tif_dumpmode.c libtiff/tif_error.c libtiff/tif_extension.c 13 | libtiff/tif_fax3.c libtiff/tif_fax3sm.c libtiff/tif_getimage.c 14 | libtiff/tif_jpeg.c libtiff/tif_ojpeg.c libtiff/tif_flush.c 15 | libtiff/tif_luv.c libtiff/tif_lzw.c libtiff/tif_next.c 16 | libtiff/tif_open.c libtiff/tif_packbits.c libtiff/tif_pixarlog.c 17 | libtiff/tif_predict.c libtiff/tif_print.c libtiff/tif_read.c 18 | libtiff/tif_stream.cxx libtiff/tif_swab.c libtiff/tif_strip.c 19 | libtiff/tif_thunder.c libtiff/tif_tile.c libtiff/tif_version.c 20 | libtiff/tif_warning.c libtiff/tif_write.c libtiff/tif_zip.c libtiff/tif_win32.c) 21 | 22 | if (NOT (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libtiff/tif_config.h)) 23 | file(RENAME libtiff/tif_config.h.vc libtiff/tif_config.h) 24 | endif() 25 | if (NOT (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libtiff/tiffconf.h)) 26 | file(RENAME libtiff/tiffconf.h.vc libtiff/tiffconf.h) 27 | endif() 28 | 29 | file(GLOB HEADERS port/*.h libtiff/*.h) 30 | 31 | add_library(libtiff SHARED ${SOURCES} ${HEADERS}) 32 | 33 | add_definitions(-DUSE_WIN32_FILEIO) 34 | 35 | set_target_properties(libtiff PROPERTIES OUTPUT_NAME "libtiff") 36 | set_target_properties(libtiff PROPERTIES LINK_FLAGS "/def:\"${CMAKE_CURRENT_SOURCE_DIR}/libtiff/libtiff.def\"") 37 | 38 | include_directories(libtiff ${JPEG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) 39 | target_link_libraries(libtiff ${JPEG_LIBRARY} ${ZLIB_LIBRARIES}) 40 | 41 | install(TARGETS libtiff 42 | LIBRARY DESTINATION lib 43 | RUNTIME DESTINATION bin) 44 | 45 | install(FILES ${HEADERS} DESTINATION include) -------------------------------------------------------------------------------- /cmake/libxml2/all.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.7) 2 | 3 | project(libxml2 C) 4 | 5 | # set (SOURCES buf.c c14n.c catalog.c chvalid.c debugXML.c dict.c encoding.c 6 | # entities.c error.c globals.c hash.c HTMLparser.c HTMLtree.c 7 | # legacy.c list.c nanoftp.c nanohttp.c parserInternals.c 8 | # parser.c pattern.c relaxng.c SAX2.c SAX.c schematron.c 9 | # testdso.c threads.c tree.c uri.c valid.c xinclude.c xlink.c 10 | # xmlIO.c xmlmemory.c xmlmodule.c xmlreader.c xmlregexp.c 11 | # xmlsave.c xmlschemas.c xmlschemastypes.c xmlstring.c 12 | # xmlunicode.c xmlwriter.c xpath.c xpointer.c xzlib.c) 13 | 14 | FILE (GLOB SOURCES LIST_DIRECTORIES false *.c) 15 | FILE (GLOB HEADERS_local LIST_DIRECTORIES false *.h) 16 | FILE (GLOB_RECURSE HEADERS_include LIST_DIRECTORIES false include/*.h) 17 | SET (HEADERS ${HEADERS_local} ${HEADERS_include}) 18 | 19 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} include/) 20 | 21 | add_library(xml2 SHARED ${SOURCES}) 22 | set_target_properties(xml2 PROPERTIES OUTPUT_NAME "xml2") 23 | 24 | install(TARGETS xml2 25 | LIBRARY DESTINATION lib 26 | RUNTIME DESTINATION bin) 27 | 28 | install(FILES HEADERS_include DESTINATION include) -------------------------------------------------------------------------------- /cmake/pcre/pcre-8.40.cmake: -------------------------------------------------------------------------------- 1 | # CMakeLists.txt 2 | # 3 | # 4 | # This file allows building PCRE with the CMake configuration and build 5 | # tool. Download CMake in source or binary form from http://www.cmake.org/ 6 | # 7 | # Original listfile by Christian Ehrlicher 8 | # Refined and expanded by Daniel Richard G. 9 | # 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered 10 | # 2007-09-19 Adjusted by PH to retain previous default settings 11 | # 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre 12 | # (b) Ensure pcretest and pcregrep link with the local library, 13 | # not a previously-installed one. 14 | # (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and 15 | # PCRE_SUPPORT_LIBBZ2. 16 | # 2008-01-20 Brought up to date to include several new features by Christian 17 | # Ehrlicher. 18 | # 2008-01-22 Sheri added options for backward compatibility of library names 19 | # when building with minGW: 20 | # if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to 21 | # be built without "lib" as prefix. (The libraries will be named 22 | # pcre.dll, pcreposix.dll and pcrecpp.dll). 23 | # if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to 24 | # be built with suffix of "-0.dll". (The libraries will be named 25 | # libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names 26 | # built by default with Configure and Make. 27 | # 2008-01-23 PH removed the automatic build of pcredemo. 28 | # 2008-04-22 PH modified READLINE support so it finds NCURSES when needed. 29 | # 2008-07-03 PH updated for revised UCP property support (change of files) 30 | # 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name 31 | # CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE 32 | # is included within another project. 33 | # 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to 34 | # add options to stop the building of pcregrep and the tests, and 35 | # to disable the final configuration report. 36 | # 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that 37 | # are set by specifying a release type. 38 | # 2010-01-02 PH added test for stdint.h 39 | # 2010-03-02 PH added test for inttypes.h 40 | # 2011-08-01 PH added PCREGREP_BUFSIZE 41 | # 2011-08-22 PH added PCRE_SUPPORT_JIT 42 | # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov 43 | # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT 44 | # 2011-10-04 Sheri added support for including coff data in windows shared libraries 45 | # compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in 46 | # the source dir by the user prior to building 47 | # 2011-10-04 Sheri changed various add_test's to use exes' location built instead 48 | # of DEBUG location only (likely only matters in MSVC) 49 | # 2011-10-04 Sheri added scripts to provide needed variables to RunTest and 50 | # RunGrepTest (used for UNIX and Msys) 51 | # 2011-10-04 Sheri added scripts to provide needed variables and to execute 52 | # RunTest.bat in Win32 (for effortless testing with "make test") 53 | # 2011-10-04 Sheri Increased minimum required cmake version 54 | # 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c 55 | # 2012-01-10 Zoltan Herczeg added libpcre16 support 56 | # 2012-01-13 Stephen Kelly added out of source build support 57 | # 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out 58 | # of the configure.ac file 59 | # 2012-02-26 PH added support for libedit 60 | # 2012-09-06 PH added support for PCRE_EBCDIC_NL25 61 | # 2012-09-08 ChPe added PCRE32 support 62 | # 2012-10-23 PH added support for VALGRIND and GCOV 63 | # 2012-12-08 PH added patch from Daniel Richard G to quash some MSVC warnings 64 | # 2013-07-01 PH realized that the "support" for GCOV was a total nonsense and 65 | # so it has been removed. 66 | # 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".") 67 | # 2013-11-05 PH added support for PARENS_NEST_LIMIT 68 | # 2016-03-01 PH applied Chris Wilson's patch for MSVC static build 69 | # 2016-06-24 PH applied Chris Wilson's revised patch (adds a separate option) 70 | 71 | PROJECT(PCRE C CXX) 72 | 73 | # Increased minimum to 2.8.0 to support newer add_test features. Set policy 74 | # CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY. 75 | 76 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) 77 | CMAKE_POLICY(SET CMP0026 OLD) 78 | 79 | SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake 80 | 81 | # external packages 82 | FIND_PACKAGE( BZip2 ) 83 | FIND_PACKAGE( ZLIB ) 84 | FIND_PACKAGE( Readline ) 85 | FIND_PACKAGE( Editline ) 86 | 87 | # Configuration checks 88 | 89 | INCLUDE(CheckIncludeFile) 90 | INCLUDE(CheckIncludeFileCXX) 91 | INCLUDE(CheckFunctionExists) 92 | INCLUDE(CheckTypeSize) 93 | 94 | CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) 95 | CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) 96 | CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) 97 | CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) 98 | CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) 99 | CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) 100 | CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H) 101 | 102 | CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H) 103 | CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H) 104 | 105 | CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY) 106 | CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE) 107 | CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR) 108 | CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL) 109 | CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ) 110 | CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64) 111 | 112 | CHECK_TYPE_SIZE("long long" LONG_LONG) 113 | CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG) 114 | 115 | # User-configurable options 116 | # 117 | # (Note: CMakeSetup displays these in alphabetical order, regardless of 118 | # the order we use here) 119 | 120 | SET(BUILD_SHARED_LIBS OFF CACHE BOOL 121 | "Build shared libraries instead of static ones.") 122 | 123 | OPTION(PCRE_BUILD_PCRE8 "Build 8 bit PCRE library" ON) 124 | 125 | OPTION(PCRE_BUILD_PCRE16 "Build 16 bit PCRE library" OFF) 126 | 127 | OPTION(PCRE_BUILD_PCRE32 "Build 32 bit PCRE library" OFF) 128 | 129 | OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON) 130 | 131 | SET(PCRE_EBCDIC OFF CACHE BOOL 132 | "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)") 133 | 134 | SET(PCRE_EBCDIC_NL25 OFF CACHE BOOL 135 | "Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.") 136 | 137 | SET(PCRE_LINK_SIZE "2" CACHE STRING 138 | "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.") 139 | 140 | SET(PCRE_PARENS_NEST_LIMIT "250" CACHE STRING 141 | "Default nested parentheses limit. See PARENS_NEST_LIMIT in config.h.in for details.") 142 | 143 | SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING 144 | "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.") 145 | 146 | SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING 147 | "Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.") 148 | 149 | SET(PCREGREP_BUFSIZE "20480" CACHE STRING 150 | "Buffer size parameter for pcregrep. See PCREGREP_BUFSIZE in config.h.in for details.") 151 | 152 | SET(PCRE_NEWLINE "LF" CACHE STRING 153 | "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).") 154 | 155 | SET(PCRE_NO_RECURSE OFF CACHE BOOL 156 | "If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.") 157 | 158 | SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING 159 | "Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.") 160 | 161 | SET(PCRE_SUPPORT_JIT OFF CACHE BOOL 162 | "Enable support for Just-in-time compiling.") 163 | 164 | SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL 165 | "Enable use of Just-in-time compiling in pcregrep.") 166 | 167 | SET(PCRE_SUPPORT_UTF OFF CACHE BOOL 168 | "Enable support for Unicode Transformation Format (UTF-8/UTF-16/UTF-32) encoding.") 169 | 170 | SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL 171 | "Enable support for Unicode properties (if set, UTF support will be enabled as well).") 172 | 173 | SET(PCRE_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL 174 | "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks") 175 | 176 | SET(PCRE_SUPPORT_VALGRIND OFF CACHE BOOL 177 | "Enable Valgrind support.") 178 | 179 | OPTION(PCRE_SHOW_REPORT "Show the final configuration report" ON) 180 | OPTION(PCRE_BUILD_PCREGREP "Build pcregrep" ON) 181 | OPTION(PCRE_BUILD_TESTS "Build the tests" ON) 182 | 183 | IF (MINGW) 184 | OPTION(NON_STANDARD_LIB_PREFIX 185 | "ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc." 186 | OFF) 187 | 188 | OPTION(NON_STANDARD_LIB_SUFFIX 189 | "ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc." 190 | OFF) 191 | ENDIF(MINGW) 192 | 193 | IF(MSVC) 194 | OPTION(PCRE_STATIC_RUNTIME 195 | "ON=Compile against the static runtime (/MT)." 196 | OFF) 197 | OPTION(INSTALL_MSVC_PDB 198 | "ON=Install .pdb files built by MSVC, if generated" 199 | OFF) 200 | ENDIF(MSVC) 201 | 202 | # bzip2 lib 203 | IF(BZIP2_FOUND) 204 | OPTION (PCRE_SUPPORT_LIBBZ2 "Enable support for linking pcregrep with libbz2." ON) 205 | ENDIF(BZIP2_FOUND) 206 | IF(PCRE_SUPPORT_LIBBZ2) 207 | INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR}) 208 | ENDIF(PCRE_SUPPORT_LIBBZ2) 209 | 210 | # zlib 211 | IF(ZLIB_FOUND) 212 | OPTION (PCRE_SUPPORT_LIBZ "Enable support for linking pcregrep with libz." ON) 213 | ENDIF(ZLIB_FOUND) 214 | IF(PCRE_SUPPORT_LIBZ) 215 | INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 216 | ENDIF(PCRE_SUPPORT_LIBZ) 217 | 218 | # editline lib 219 | IF(EDITLINE_FOUND) 220 | OPTION (PCRE_SUPPORT_LIBEDIT "Enable support for linking pcretest with libedit." OFF) 221 | ENDIF(EDITLINE_FOUND) 222 | IF(PCRE_SUPPORT_LIBEDIT) 223 | INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR}) 224 | ENDIF(PCRE_SUPPORT_LIBEDIT) 225 | 226 | # readline lib 227 | IF(READLINE_FOUND) 228 | OPTION (PCRE_SUPPORT_LIBREADLINE "Enable support for linking pcretest with libreadline." ON) 229 | ENDIF(READLINE_FOUND) 230 | IF(PCRE_SUPPORT_LIBREADLINE) 231 | INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR}) 232 | ENDIF(PCRE_SUPPORT_LIBREADLINE) 233 | 234 | # Prepare build configuration 235 | 236 | SET(pcre_have_type_traits 0) 237 | SET(pcre_have_bits_type_traits 0) 238 | 239 | IF(HAVE_TYPE_TRAITS_H) 240 | SET(pcre_have_type_traits 1) 241 | ENDIF(HAVE_TYPE_TRAITS_H) 242 | 243 | IF(HAVE_BITS_TYPE_TRAITS_H) 244 | SET(pcre_have_bits_type_traits 1) 245 | ENDIF(HAVE_BITS_TYPE_TRAITS_H) 246 | 247 | SET(pcre_have_long_long 0) 248 | SET(pcre_have_ulong_long 0) 249 | 250 | IF(HAVE_LONG_LONG) 251 | SET(pcre_have_long_long 1) 252 | ENDIF(HAVE_LONG_LONG) 253 | 254 | IF(HAVE_UNSIGNED_LONG_LONG) 255 | SET(pcre_have_ulong_long 1) 256 | ENDIF(HAVE_UNSIGNED_LONG_LONG) 257 | 258 | IF(NOT BUILD_SHARED_LIBS) 259 | SET(PCRE_STATIC 1) 260 | ENDIF(NOT BUILD_SHARED_LIBS) 261 | 262 | IF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16 AND NOT PCRE_BUILD_PCRE32) 263 | MESSAGE(FATAL_ERROR "At least one of PCRE_BUILD_PCRE8, PCRE_BUILD_PCRE16 or PCRE_BUILD_PCRE32 must be enabled") 264 | ENDIF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16 AND NOT PCRE_BUILD_PCRE32) 265 | 266 | IF(PCRE_BUILD_PCRE8) 267 | SET(SUPPORT_PCRE8 1) 268 | ENDIF(PCRE_BUILD_PCRE8) 269 | 270 | IF(PCRE_BUILD_PCRE16) 271 | SET(SUPPORT_PCRE16 1) 272 | ENDIF(PCRE_BUILD_PCRE16) 273 | 274 | IF(PCRE_BUILD_PCRE32) 275 | SET(SUPPORT_PCRE32 1) 276 | ENDIF(PCRE_BUILD_PCRE32) 277 | 278 | IF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8) 279 | MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the C++ library support") 280 | SET(PCRE_BUILD_PCRECPP OFF) 281 | ENDIF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8) 282 | 283 | IF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8) 284 | MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the pcregrep program") 285 | SET(PCRE_BUILD_PCREGREP OFF) 286 | ENDIF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8) 287 | 288 | IF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT) 289 | MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified") 290 | ENDIF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT) 291 | 292 | IF(PCRE_SUPPORT_BSR_ANYCRLF) 293 | SET(BSR_ANYCRLF 1) 294 | ENDIF(PCRE_SUPPORT_BSR_ANYCRLF) 295 | 296 | IF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES) 297 | SET(SUPPORT_UTF 1) 298 | SET(PCRE_SUPPORT_UTF ON) 299 | ENDIF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES) 300 | 301 | IF(PCRE_SUPPORT_UNICODE_PROPERTIES) 302 | SET(SUPPORT_UCP 1) 303 | ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES) 304 | 305 | IF(PCRE_SUPPORT_JIT) 306 | SET(SUPPORT_JIT 1) 307 | ENDIF(PCRE_SUPPORT_JIT) 308 | 309 | IF(PCRE_SUPPORT_PCREGREP_JIT) 310 | SET(SUPPORT_PCREGREP_JIT 1) 311 | ENDIF(PCRE_SUPPORT_PCREGREP_JIT) 312 | 313 | IF(PCRE_SUPPORT_VALGRIND) 314 | SET(SUPPORT_VALGRIND 1) 315 | ENDIF(PCRE_SUPPORT_VALGRIND) 316 | 317 | # This next one used to contain 318 | # SET(PCRETEST_LIBS ${READLINE_LIBRARY}) 319 | # but I was advised to add the NCURSES test as well, along with 320 | # some modifications to cmake/FindReadline.cmake which should 321 | # make it possible to override the default if necessary. PH 322 | 323 | IF(PCRE_SUPPORT_LIBREADLINE) 324 | SET(SUPPORT_LIBREADLINE 1) 325 | SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY}) 326 | ENDIF(PCRE_SUPPORT_LIBREADLINE) 327 | 328 | # libedit is a plug-compatible alternative to libreadline 329 | 330 | IF(PCRE_SUPPORT_LIBEDIT) 331 | SET(SUPPORT_LIBEDIT 1) 332 | SET(PCRETEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY}) 333 | ENDIF(PCRE_SUPPORT_LIBEDIT) 334 | 335 | IF(PCRE_SUPPORT_LIBZ) 336 | SET(SUPPORT_LIBZ 1) 337 | SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES}) 338 | ENDIF(PCRE_SUPPORT_LIBZ) 339 | 340 | IF(PCRE_SUPPORT_LIBBZ2) 341 | SET(SUPPORT_LIBBZ2 1) 342 | SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${BZIP2_LIBRARIES}) 343 | ENDIF(PCRE_SUPPORT_LIBBZ2) 344 | 345 | SET(NEWLINE "") 346 | 347 | IF(PCRE_NEWLINE STREQUAL "LF") 348 | SET(NEWLINE "10") 349 | ENDIF(PCRE_NEWLINE STREQUAL "LF") 350 | IF(PCRE_NEWLINE STREQUAL "CR") 351 | SET(NEWLINE "13") 352 | ENDIF(PCRE_NEWLINE STREQUAL "CR") 353 | IF(PCRE_NEWLINE STREQUAL "CRLF") 354 | SET(NEWLINE "3338") 355 | ENDIF(PCRE_NEWLINE STREQUAL "CRLF") 356 | IF(PCRE_NEWLINE STREQUAL "ANY") 357 | SET(NEWLINE "-1") 358 | ENDIF(PCRE_NEWLINE STREQUAL "ANY") 359 | IF(PCRE_NEWLINE STREQUAL "ANYCRLF") 360 | SET(NEWLINE "-2") 361 | ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF") 362 | 363 | IF(NEWLINE STREQUAL "") 364 | MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".") 365 | ENDIF(NEWLINE STREQUAL "") 366 | 367 | IF(PCRE_EBCDIC) 368 | SET(EBCDIC 1) 369 | IF(PCRE_NEWLINE STREQUAL "LF") 370 | SET(NEWLINE "21") 371 | ENDIF(PCRE_NEWLINE STREQUAL "LF") 372 | IF(PCRE_NEWLINE STREQUAL "CRLF") 373 | SET(NEWLINE "3349") 374 | ENDIF(PCRE_NEWLINE STREQUAL "CRLF") 375 | ENDIF(PCRE_EBCDIC) 376 | 377 | IF(PCRE_EBCDIC_NL25) 378 | SET(EBCDIC 1) 379 | SET(EBCDIC_NL25 1) 380 | IF(PCRE_NEWLINE STREQUAL "LF") 381 | SET(NEWLINE "37") 382 | ENDIF(PCRE_NEWLINE STREQUAL "LF") 383 | IF(PCRE_NEWLINE STREQUAL "CRLF") 384 | SET(NEWLINE "3365") 385 | ENDIF(PCRE_NEWLINE STREQUAL "CRLF") 386 | ENDIF(PCRE_EBCDIC_NL25) 387 | 388 | IF(PCRE_NO_RECURSE) 389 | SET(NO_RECURSE 1) 390 | ENDIF(PCRE_NO_RECURSE) 391 | 392 | # Output files 393 | CONFIGURE_FILE(config-cmake.h.in 394 | ${PROJECT_BINARY_DIR}/config.h 395 | @ONLY) 396 | 397 | # Parse version numbers and date out of configure.ac 398 | 399 | file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac 400 | configure_lines 401 | LIMIT_COUNT 50 # Read only the first 50 lines of the file 402 | ) 403 | 404 | set(SEARCHED_VARIABLES "pcre_major" "pcre_minor" "pcre_prerelease" "pcre_date") 405 | foreach(configure_line ${configure_lines}) 406 | foreach(_substitution_variable ${SEARCHED_VARIABLES}) 407 | string(TOUPPER ${_substitution_variable} _substitution_variable_upper) 408 | if (NOT ${_substitution_variable_upper}) 409 | string(REGEX MATCH "m4_define\\(${_substitution_variable}, \\[(.*)\\]" MACTHED_STRING ${configure_line}) 410 | if (CMAKE_MATCH_1) 411 | set(${_substitution_variable_upper} ${CMAKE_MATCH_1}) 412 | endif() 413 | endif() 414 | endforeach() 415 | endforeach() 416 | 417 | CONFIGURE_FILE(pcre.h.in 418 | ${PROJECT_BINARY_DIR}/pcre.h 419 | @ONLY) 420 | 421 | # What about pcre-config and libpcre.pc? 422 | 423 | IF(PCRE_BUILD_PCRECPP) 424 | CONFIGURE_FILE(pcre_stringpiece.h.in 425 | ${PROJECT_BINARY_DIR}/pcre_stringpiece.h 426 | @ONLY) 427 | 428 | CONFIGURE_FILE(pcrecpparg.h.in 429 | ${PROJECT_BINARY_DIR}/pcrecpparg.h 430 | @ONLY) 431 | ENDIF(PCRE_BUILD_PCRECPP) 432 | 433 | # Character table generation 434 | 435 | OPTION(PCRE_REBUILD_CHARTABLES "Rebuild char tables" OFF) 436 | IF(PCRE_REBUILD_CHARTABLES) 437 | ADD_EXECUTABLE(dftables dftables.c) 438 | 439 | GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION) 440 | 441 | ADD_CUSTOM_COMMAND( 442 | COMMENT "Generating character tables (pcre_chartables.c) for current locale" 443 | DEPENDS dftables 444 | COMMAND ${DFTABLES_EXE} 445 | ARGS ${PROJECT_BINARY_DIR}/pcre_chartables.c 446 | OUTPUT ${PROJECT_BINARY_DIR}/pcre_chartables.c 447 | ) 448 | ELSE(PCRE_REBUILD_CHARTABLES) 449 | CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pcre_chartables.c.dist 450 | ${PROJECT_BINARY_DIR}/pcre_chartables.c 451 | COPYONLY) 452 | ENDIF(PCRE_REBUILD_CHARTABLES) 453 | 454 | # Source code 455 | 456 | SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h) 457 | 458 | IF(PCRE_BUILD_PCRE8) 459 | SET(PCRE_SOURCES 460 | pcre_byte_order.c 461 | pcre_chartables.c 462 | pcre_compile.c 463 | pcre_config.c 464 | pcre_dfa_exec.c 465 | pcre_exec.c 466 | pcre_fullinfo.c 467 | pcre_get.c 468 | pcre_globals.c 469 | pcre_jit_compile.c 470 | pcre_maketables.c 471 | pcre_newline.c 472 | pcre_ord2utf8.c 473 | pcre_refcount.c 474 | pcre_string_utils.c 475 | pcre_study.c 476 | pcre_tables.c 477 | pcre_ucd.c 478 | pcre_valid_utf8.c 479 | pcre_version.c 480 | pcre_xclass.c 481 | ) 482 | 483 | SET(PCREPOSIX_HEADERS pcreposix.h) 484 | 485 | SET(PCREPOSIX_SOURCES pcreposix.c) 486 | 487 | ENDIF(PCRE_BUILD_PCRE8) 488 | 489 | IF(PCRE_BUILD_PCRE16) 490 | SET(PCRE16_SOURCES 491 | pcre16_byte_order.c 492 | pcre16_chartables.c 493 | pcre16_compile.c 494 | pcre16_config.c 495 | pcre16_dfa_exec.c 496 | pcre16_exec.c 497 | pcre16_fullinfo.c 498 | pcre16_get.c 499 | pcre16_globals.c 500 | pcre16_jit_compile.c 501 | pcre16_maketables.c 502 | pcre16_newline.c 503 | pcre16_ord2utf16.c 504 | pcre16_refcount.c 505 | pcre16_string_utils.c 506 | pcre16_study.c 507 | pcre16_tables.c 508 | pcre16_ucd.c 509 | pcre16_utf16_utils.c 510 | pcre16_valid_utf16.c 511 | pcre16_version.c 512 | pcre16_xclass.c 513 | ) 514 | ENDIF(PCRE_BUILD_PCRE16) 515 | 516 | IF(PCRE_BUILD_PCRE32) 517 | SET(PCRE32_SOURCES 518 | pcre32_byte_order.c 519 | pcre32_chartables.c 520 | pcre32_compile.c 521 | pcre32_config.c 522 | pcre32_dfa_exec.c 523 | pcre32_exec.c 524 | pcre32_fullinfo.c 525 | pcre32_get.c 526 | pcre32_globals.c 527 | pcre32_jit_compile.c 528 | pcre32_maketables.c 529 | pcre32_newline.c 530 | pcre32_ord2utf32.c 531 | pcre32_refcount.c 532 | pcre32_string_utils.c 533 | pcre32_study.c 534 | pcre32_tables.c 535 | pcre32_ucd.c 536 | pcre32_utf32_utils.c 537 | pcre32_valid_utf32.c 538 | pcre32_version.c 539 | pcre32_xclass.c 540 | ) 541 | ENDIF(PCRE_BUILD_PCRE32) 542 | 543 | IF(MINGW AND NOT PCRE_STATIC) 544 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc) 545 | ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o 546 | PRE-LINK 547 | COMMAND windres ARGS pcre.rc pcre.o 548 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 549 | COMMENT Using pcre coff info in mingw build) 550 | SET(PCRE_SOURCES 551 | ${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o 552 | ) 553 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc) 554 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc) 555 | ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o 556 | PRE-LINK 557 | COMMAND windres ARGS pcreposix.rc pcreposix.o 558 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 559 | COMMENT Using pcreposix coff info in mingw build) 560 | SET(PCREPOSIX_SOURCES 561 | ${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o 562 | ) 563 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc) 564 | ENDIF(MINGW AND NOT PCRE_STATIC) 565 | 566 | IF(MSVC AND NOT PCRE_STATIC) 567 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc) 568 | SET(PCRE_SOURCES 569 | ${PCRE_SOURCES} pcre.rc) 570 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc) 571 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc) 572 | SET(PCREPOSIX_SOURCES 573 | ${PCREPOSIX_SOURCES} pcreposix.rc) 574 | ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc) 575 | ENDIF(MSVC AND NOT PCRE_STATIC) 576 | 577 | # Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681 578 | # This code was taken from the CMake wiki, not from WebM. 579 | 580 | IF(MSVC AND PCRE_STATIC_RUNTIME) 581 | MESSAGE(STATUS "** MSVC and PCRE_STATIC_RUNTIME: modifying compiler flags to use static runtime library") 582 | foreach(flag_var 583 | CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE 584 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO 585 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE 586 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) 587 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") 588 | endforeach() 589 | ENDIF(MSVC AND PCRE_STATIC_RUNTIME) 590 | 591 | SET(PCRECPP_HEADERS 592 | pcrecpp.h 593 | pcre_scanner.h 594 | ${PROJECT_BINARY_DIR}/pcrecpparg.h 595 | ${PROJECT_BINARY_DIR}/pcre_stringpiece.h 596 | ) 597 | 598 | SET(PCRECPP_SOURCES 599 | pcrecpp.cc 600 | pcre_scanner.cc 601 | pcre_stringpiece.cc 602 | ) 603 | 604 | # Build setup 605 | 606 | ADD_DEFINITIONS(-DHAVE_CONFIG_H) 607 | 608 | IF(MSVC) 609 | ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS) 610 | ENDIF(MSVC) 611 | 612 | SET(CMAKE_INCLUDE_CURRENT_DIR 1) 613 | # needed to make sure to not link debug libs 614 | # against release libs and vice versa 615 | IF(WIN32) 616 | SET(CMAKE_DEBUG_POSTFIX "d") 617 | ENDIF(WIN32) 618 | 619 | SET(targets) 620 | 621 | # Libraries 622 | # pcre 623 | IF(PCRE_BUILD_PCRE8) 624 | ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES} ${PROJECT_BINARY_DIR}/config.h) 625 | SET(targets ${targets} pcre) 626 | ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES}) 627 | SET(targets ${targets} pcreposix) 628 | TARGET_LINK_LIBRARIES(pcreposix pcre) 629 | 630 | IF(MINGW AND NOT PCRE_STATIC) 631 | IF(NON_STANDARD_LIB_PREFIX) 632 | SET_TARGET_PROPERTIES(pcre pcreposix 633 | PROPERTIES PREFIX "" 634 | ) 635 | ENDIF(NON_STANDARD_LIB_PREFIX) 636 | 637 | IF(NON_STANDARD_LIB_SUFFIX) 638 | SET_TARGET_PROPERTIES(pcre pcreposix 639 | PROPERTIES SUFFIX "-0.dll" 640 | ) 641 | ENDIF(NON_STANDARD_LIB_SUFFIX) 642 | ENDIF(MINGW AND NOT PCRE_STATIC) 643 | 644 | ENDIF(PCRE_BUILD_PCRE8) 645 | 646 | IF(PCRE_BUILD_PCRE16) 647 | ADD_LIBRARY(pcre16 ${PCRE_HEADERS} ${PCRE16_SOURCES} ${PROJECT_BINARY_DIR}/config.h) 648 | SET(targets ${targets} pcre16) 649 | 650 | IF(MINGW AND NOT PCRE_STATIC) 651 | IF(NON_STANDARD_LIB_PREFIX) 652 | SET_TARGET_PROPERTIES(pcre16 653 | PROPERTIES PREFIX "" 654 | ) 655 | ENDIF(NON_STANDARD_LIB_PREFIX) 656 | 657 | IF(NON_STANDARD_LIB_SUFFIX) 658 | SET_TARGET_PROPERTIES(pcre16 659 | PROPERTIES SUFFIX "-0.dll" 660 | ) 661 | ENDIF(NON_STANDARD_LIB_SUFFIX) 662 | ENDIF(MINGW AND NOT PCRE_STATIC) 663 | 664 | ENDIF(PCRE_BUILD_PCRE16) 665 | 666 | IF(PCRE_BUILD_PCRE32) 667 | ADD_LIBRARY(pcre32 ${PCRE_HEADERS} ${PCRE32_SOURCES} ${PROJECT_BINARY_DIR}/config.h) 668 | SET(targets ${targets} pcre32) 669 | 670 | IF(MINGW AND NOT PCRE_STATIC) 671 | IF(NON_STANDARD_LIB_PREFIX) 672 | SET_TARGET_PROPERTIES(pcre32 673 | PROPERTIES PREFIX "" 674 | ) 675 | ENDIF(NON_STANDARD_LIB_PREFIX) 676 | 677 | IF(NON_STANDARD_LIB_SUFFIX) 678 | SET_TARGET_PROPERTIES(pcre32 679 | PROPERTIES SUFFIX "-0.dll" 680 | ) 681 | ENDIF(NON_STANDARD_LIB_SUFFIX) 682 | ENDIF(MINGW AND NOT PCRE_STATIC) 683 | 684 | ENDIF(PCRE_BUILD_PCRE32) 685 | 686 | # pcrecpp 687 | IF(PCRE_BUILD_PCRECPP) 688 | ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES}) 689 | SET(targets ${targets} pcrecpp) 690 | TARGET_LINK_LIBRARIES(pcrecpp pcre) 691 | 692 | IF(MINGW AND NOT PCRE_STATIC) 693 | IF(NON_STANDARD_LIB_PREFIX) 694 | SET_TARGET_PROPERTIES(pcrecpp 695 | PROPERTIES PREFIX "" 696 | ) 697 | ENDIF(NON_STANDARD_LIB_PREFIX) 698 | 699 | IF(NON_STANDARD_LIB_SUFFIX) 700 | SET_TARGET_PROPERTIES(pcrecpp 701 | PROPERTIES SUFFIX "-0.dll" 702 | ) 703 | ENDIF(NON_STANDARD_LIB_SUFFIX) 704 | ENDIF(MINGW AND NOT PCRE_STATIC) 705 | ENDIF(PCRE_BUILD_PCRECPP) 706 | 707 | 708 | # Executables 709 | 710 | # Removed by PH (2008-01-23) because pcredemo shouldn't really be built 711 | # automatically, and it gave trouble in some environments anyway. 712 | # ADD_EXECUTABLE(pcredemo pcredemo.c) 713 | # TARGET_LINK_LIBRARIES(pcredemo pcreposix) 714 | # IF(NOT BUILD_SHARED_LIBS) 715 | # # make sure to not use declspec(dllimport) in static mode on windows 716 | # SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC") 717 | # ENDIF(NOT BUILD_SHARED_LIBS) 718 | 719 | IF(PCRE_BUILD_PCREGREP) 720 | ADD_EXECUTABLE(pcregrep pcregrep.c) 721 | SET(targets ${targets} pcregrep) 722 | TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS}) 723 | ENDIF(PCRE_BUILD_PCREGREP) 724 | 725 | # Testing 726 | IF(PCRE_BUILD_TESTS) 727 | ENABLE_TESTING() 728 | 729 | SET(PCRETEST_SOURCES pcretest.c) 730 | IF(PCRE_BUILD_PCRE8) 731 | LIST(APPEND PCRETEST_SOURCES pcre_printint.c) 732 | ENDIF(PCRE_BUILD_PCRE8) 733 | IF(PCRE_BUILD_PCRE16) 734 | LIST(APPEND PCRETEST_SOURCES pcre16_printint.c) 735 | ENDIF(PCRE_BUILD_PCRE16) 736 | IF(PCRE_BUILD_PCRE32) 737 | LIST(APPEND PCRETEST_SOURCES pcre32_printint.c) 738 | ENDIF(PCRE_BUILD_PCRE32) 739 | 740 | ADD_EXECUTABLE(pcretest ${PCRETEST_SOURCES}) 741 | SET(targets ${targets} pcretest) 742 | IF(PCRE_BUILD_PCRE8) 743 | LIST(APPEND PCRETEST_LIBS pcreposix pcre) 744 | ENDIF(PCRE_BUILD_PCRE8) 745 | IF(PCRE_BUILD_PCRE16) 746 | LIST(APPEND PCRETEST_LIBS pcre16) 747 | ENDIF(PCRE_BUILD_PCRE16) 748 | IF(PCRE_BUILD_PCRE32) 749 | LIST(APPEND PCRETEST_LIBS pcre32) 750 | ENDIF(PCRE_BUILD_PCRE32) 751 | TARGET_LINK_LIBRARIES(pcretest ${PCRETEST_LIBS}) 752 | 753 | IF(PCRE_SUPPORT_JIT) 754 | ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c) 755 | SET(targets ${targets} pcre_jit_test) 756 | SET(PCRE_JIT_TEST_LIBS ) 757 | IF(PCRE_BUILD_PCRE8) 758 | LIST(APPEND PCRE_JIT_TEST_LIBS pcre) 759 | ENDIF(PCRE_BUILD_PCRE8) 760 | IF(PCRE_BUILD_PCRE16) 761 | LIST(APPEND PCRE_JIT_TEST_LIBS pcre16) 762 | ENDIF(PCRE_BUILD_PCRE16) 763 | IF(PCRE_BUILD_PCRE32) 764 | LIST(APPEND PCRE_JIT_TEST_LIBS pcre32) 765 | ENDIF(PCRE_BUILD_PCRE32) 766 | TARGET_LINK_LIBRARIES(pcre_jit_test ${PCRE_JIT_TEST_LIBS}) 767 | ENDIF(PCRE_SUPPORT_JIT) 768 | 769 | IF(PCRE_BUILD_PCRECPP) 770 | ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc) 771 | SET(targets ${targets} pcrecpp_unittest) 772 | TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp) 773 | IF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC) 774 | SET_TARGET_PROPERTIES(pcrecpp 775 | PROPERTIES PREFIX "" 776 | ) 777 | ENDIF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC) 778 | 779 | ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc) 780 | SET(targets ${targets} pcre_scanner_unittest) 781 | TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp) 782 | 783 | ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc) 784 | SET(targets ${targets} pcre_stringpiece_unittest) 785 | TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp) 786 | ENDIF(PCRE_BUILD_PCRECPP) 787 | 788 | # exes in Debug location tested by the RunTest shell script 789 | # via "make test" 790 | IF(PCRE_BUILD_PCREGREP) 791 | GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION) 792 | ENDIF(PCRE_BUILD_PCREGREP) 793 | 794 | GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION) 795 | 796 | # ================================================= 797 | # Write out a CTest configuration file 798 | # 799 | FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest 800 | "# This is a generated file. 801 | MESSAGE(\"When testing is complete, review test output in the 802 | \\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\") 803 | MESSAGE(\" \") 804 | ") 805 | 806 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh 807 | "#! /bin/sh 808 | # This is a generated file. 809 | srcdir=${PROJECT_SOURCE_DIR} 810 | pcretest=${PCRETEST_EXE} 811 | . ${PROJECT_SOURCE_DIR}/RunTest 812 | if test \"$?\" != \"0\"; then exit 1; fi 813 | # End 814 | ") 815 | 816 | IF(UNIX) 817 | ADD_TEST(pcre_test sh ${PROJECT_BINARY_DIR}/pcre_test.sh) 818 | ENDIF(UNIX) 819 | 820 | IF(PCRE_BUILD_PCREGREP) 821 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh 822 | "#! /bin/sh 823 | # This is a generated file. 824 | srcdir=${PROJECT_SOURCE_DIR} 825 | pcregrep=${PCREGREP_EXE} 826 | pcretest=${PCRETEST_EXE} 827 | . ${PROJECT_SOURCE_DIR}/RunGrepTest 828 | if test \"$?\" != \"0\"; then exit 1; fi 829 | # End 830 | ") 831 | 832 | IF(UNIX) 833 | ADD_TEST(pcre_grep_test sh ${PROJECT_BINARY_DIR}/pcre_grep_test.sh) 834 | ENDIF(UNIX) 835 | ENDIF(PCRE_BUILD_PCREGREP) 836 | 837 | IF(WIN32) 838 | # Provide environment for executing the bat file version of RunTest 839 | FILE(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc) 840 | FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin) 841 | FILE(TO_NATIVE_PATH ${PCRETEST_EXE} winexe) 842 | 843 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.bat 844 | "\@REM This is a generated file. 845 | \@echo off 846 | setlocal 847 | SET srcdir=\"${winsrc}\" 848 | SET pcretest=\"${winexe}\" 849 | if not [%CMAKE_CONFIG_TYPE%]==[] SET pcretest=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcretest.exe\" 850 | call %srcdir%\\RunTest.Bat 851 | if errorlevel 1 exit /b 1 852 | echo RunTest.bat tests successfully completed 853 | ") 854 | 855 | ADD_TEST(NAME pcre_test_bat 856 | COMMAND pcre_test.bat) 857 | SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES 858 | PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed") 859 | 860 | IF("$ENV{OSTYPE}" STREQUAL "msys") 861 | # Both the sh and bat file versions of RunTest are run if make test is used 862 | # in msys 863 | ADD_TEST(pcre_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh) 864 | IF(PCRE_BUILD_PCREGREP) 865 | ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh) 866 | ENDIF(PCRE_BUILD_PCREGREP) 867 | ENDIF("$ENV{OSTYPE}" STREQUAL "msys") 868 | 869 | ENDIF(WIN32) 870 | 871 | # Changed to accommodate testing whichever location was just built 872 | 873 | IF(PCRE_SUPPORT_JIT) 874 | ADD_TEST(pcre_jit_test pcre_jit_test) 875 | ENDIF(PCRE_SUPPORT_JIT) 876 | 877 | IF(PCRE_BUILD_PCRECPP) 878 | ADD_TEST(pcrecpp_test pcrecpp_unittest) 879 | ADD_TEST(pcre_scanner_test pcre_scanner_unittest) 880 | ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest) 881 | ENDIF(PCRE_BUILD_PCRECPP) 882 | 883 | ENDIF(PCRE_BUILD_TESTS) 884 | 885 | # Installation 886 | SET(CMAKE_INSTALL_ALWAYS 1) 887 | 888 | INSTALL(TARGETS ${targets} 889 | RUNTIME DESTINATION bin 890 | LIBRARY DESTINATION lib 891 | ARCHIVE DESTINATION lib) 892 | 893 | INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include) 894 | 895 | FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html) 896 | FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1) 897 | FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3) 898 | 899 | IF(PCRE_BUILD_PCRECPP) 900 | INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include) 901 | ELSE(PCRE_BUILD_PCRECPP) 902 | # Remove pcrecpp.3 903 | FOREACH(man ${man3}) 904 | GET_FILENAME_COMPONENT(man_tmp ${man} NAME) 905 | IF(NOT man_tmp STREQUAL "pcrecpp.3") 906 | SET(man3_new ${man3} ${man}) 907 | ENDIF(NOT man_tmp STREQUAL "pcrecpp.3") 908 | ENDFOREACH(man ${man3}) 909 | SET(man3 ${man3_new}) 910 | ENDIF(PCRE_BUILD_PCRECPP) 911 | 912 | INSTALL(FILES ${man1} DESTINATION man/man1) 913 | INSTALL(FILES ${man3} DESTINATION man/man3) 914 | INSTALL(FILES ${html} DESTINATION share/doc/pcre/html) 915 | 916 | IF(MSVC AND INSTALL_MSVC_PDB) 917 | INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre.pdb 918 | ${PROJECT_BINARY_DIR}/pcreposix.pdb 919 | DESTINATION bin 920 | CONFIGURATIONS RelWithDebInfo) 921 | INSTALL(FILES ${PROJECT_BINARY_DIR}/pcred.pdb 922 | ${PROJECT_BINARY_DIR}/pcreposixd.pdb 923 | DESTINATION bin 924 | CONFIGURATIONS Debug) 925 | ENDIF(MSVC AND INSTALL_MSVC_PDB) 926 | 927 | # help, only for nice output 928 | IF(BUILD_SHARED_LIBS) 929 | SET(BUILD_STATIC_LIBS OFF) 930 | ELSE(BUILD_SHARED_LIBS) 931 | SET(BUILD_STATIC_LIBS ON) 932 | ENDIF(BUILD_SHARED_LIBS) 933 | 934 | IF(PCRE_SHOW_REPORT) 935 | STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype) 936 | IF (CMAKE_C_FLAGS) 937 | SET(cfsp " ") 938 | ENDIF(CMAKE_C_FLAGS) 939 | IF (CMAKE_CXX_FLAGS) 940 | SET(cxxfsp " ") 941 | ENDIF(CMAKE_CXX_FLAGS) 942 | MESSAGE(STATUS "") 943 | MESSAGE(STATUS "") 944 | MESSAGE(STATUS "PCRE configuration summary:") 945 | MESSAGE(STATUS "") 946 | MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}") 947 | MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}") 948 | MESSAGE(STATUS " C++ compiler .................... : ${CMAKE_CXX_COMPILER}") 949 | MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}") 950 | MESSAGE(STATUS " C++ compiler flags .............. : ${CMAKE_CXX_FLAGS}${cxxfsp}${CMAKE_CXX_FLAGS_${buildtype}}") 951 | MESSAGE(STATUS "") 952 | MESSAGE(STATUS " Build 8 bit PCRE library ........ : ${PCRE_BUILD_PCRE8}") 953 | MESSAGE(STATUS " Build 16 bit PCRE library ....... : ${PCRE_BUILD_PCRE16}") 954 | MESSAGE(STATUS " Build 32 bit PCRE library ....... : ${PCRE_BUILD_PCRE32}") 955 | MESSAGE(STATUS " Build C++ library ............... : ${PCRE_BUILD_PCRECPP}") 956 | MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE_SUPPORT_JIT}") 957 | MESSAGE(STATUS " Enable UTF support .............. : ${PCRE_SUPPORT_UTF}") 958 | MESSAGE(STATUS " Unicode properties .............. : ${PCRE_SUPPORT_UNICODE_PROPERTIES}") 959 | MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE_NEWLINE}") 960 | MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE_SUPPORT_BSR_ANYCRLF}") 961 | MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE_EBCDIC}") 962 | MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE_EBCDIC_NL25}") 963 | MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE_REBUILD_CHARTABLES}") 964 | MESSAGE(STATUS " No stack recursion .............. : ${PCRE_NO_RECURSE}") 965 | MESSAGE(STATUS " POSIX mem threshold ............. : ${PCRE_POSIX_MALLOC_THRESHOLD}") 966 | MESSAGE(STATUS " Internal link size .............. : ${PCRE_LINK_SIZE}") 967 | MESSAGE(STATUS " Parentheses nest limit .......... : ${PCRE_PARENS_NEST_LIMIT}") 968 | MESSAGE(STATUS " Match limit ..................... : ${PCRE_MATCH_LIMIT}") 969 | MESSAGE(STATUS " Match limit recursion ........... : ${PCRE_MATCH_LIMIT_RECURSION}") 970 | MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}") 971 | MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}") 972 | MESSAGE(STATUS " Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}") 973 | MESSAGE(STATUS " Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}") 974 | MESSAGE(STATUS " Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}") 975 | MESSAGE(STATUS " Build tests (implies pcretest .. : ${PCRE_BUILD_TESTS}") 976 | MESSAGE(STATUS " and pcregrep)") 977 | IF(ZLIB_FOUND) 978 | MESSAGE(STATUS " Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}") 979 | ELSE(ZLIB_FOUND) 980 | MESSAGE(STATUS " Link pcregrep with libz ......... : Library not found" ) 981 | ENDIF(ZLIB_FOUND) 982 | IF(BZIP2_FOUND) 983 | MESSAGE(STATUS " Link pcregrep with libbz2 ....... : ${PCRE_SUPPORT_LIBBZ2}") 984 | ELSE(BZIP2_FOUND) 985 | MESSAGE(STATUS " Link pcregrep with libbz2 ....... : Library not found" ) 986 | ENDIF(BZIP2_FOUND) 987 | IF(EDITLINE_FOUND) 988 | MESSAGE(STATUS " Link pcretest with libeditline .. : ${PCRE_SUPPORT_LIBEDIT}") 989 | ELSE(EDITLINE_FOUND) 990 | MESSAGE(STATUS " Link pcretest with libeditline .. : Library not found" ) 991 | ENDIF(EDITLINE_FOUND) 992 | IF(READLINE_FOUND) 993 | MESSAGE(STATUS " Link pcretest with libreadline .. : ${PCRE_SUPPORT_LIBREADLINE}") 994 | ELSE(READLINE_FOUND) 995 | MESSAGE(STATUS " Link pcretest with libreadline .. : Library not found" ) 996 | ENDIF(READLINE_FOUND) 997 | MESSAGE(STATUS " Support Valgrind .................: ${PCRE_SUPPORT_VALGRIND}") 998 | MESSAGE(STATUS " Support coverage .................: ${PCRE_SUPPORT_COVERAGE}") 999 | 1000 | IF(MINGW AND NOT PCRE_STATIC) 1001 | MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}") 1002 | MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}") 1003 | ENDIF(MINGW AND NOT PCRE_STATIC) 1004 | 1005 | IF(MSVC) 1006 | MESSAGE(STATUS " Install MSVC .pdb files ..........: ${INSTALL_MSVC_PDB}") 1007 | ENDIF(MSVC) 1008 | 1009 | MESSAGE(STATUS "") 1010 | ENDIF(PCRE_SHOW_REPORT) 1011 | 1012 | # end CMakeLists.txt 1013 | -------------------------------------------------------------------------------- /cmake/pcre2/pcre2-10.22.cmake: -------------------------------------------------------------------------------- 1 | # CMakeLists.txt 2 | # 3 | # 4 | # This file enables PCRE2 to be built with the CMake configuration and build 5 | # tool. Download CMake in source or binary form from http://www.cmake.org/ 6 | # Converted to support PCRE2 from the original PCRE file, August 2014. 7 | # 8 | # Original listfile by Christian Ehrlicher 9 | # Refined and expanded by Daniel Richard G. 10 | # 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered 11 | # 2007-09-19 Adjusted by PH to retain previous default settings 12 | # 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre 13 | # (b) Ensure pcretest and pcregrep link with the local library, 14 | # not a previously-installed one. 15 | # (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and 16 | # PCRE_SUPPORT_LIBBZ2. 17 | # 2008-01-20 Brought up to date to include several new features by Christian 18 | # Ehrlicher. 19 | # 2008-01-22 Sheri added options for backward compatibility of library names 20 | # when building with minGW: 21 | # if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to 22 | # be built without "lib" as prefix. (The libraries will be named 23 | # pcre.dll, pcreposix.dll and pcrecpp.dll). 24 | # if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to 25 | # be built with suffix of "-0.dll". (The libraries will be named 26 | # libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names 27 | # built by default with Configure and Make. 28 | # 2008-01-23 PH removed the automatic build of pcredemo. 29 | # 2008-04-22 PH modified READLINE support so it finds NCURSES when needed. 30 | # 2008-07-03 PH updated for revised UCP property support (change of files) 31 | # 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name 32 | # CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE 33 | # is included within another project. 34 | # 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to 35 | # add options to stop the building of pcregrep and the tests, and 36 | # to disable the final configuration report. 37 | # 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that 38 | # are set by specifying a release type. 39 | # 2010-01-02 PH added test for stdint.h 40 | # 2010-03-02 PH added test for inttypes.h 41 | # 2011-08-01 PH added PCREGREP_BUFSIZE 42 | # 2011-08-22 PH added PCRE_SUPPORT_JIT 43 | # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov 44 | # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT 45 | # 2011-10-04 Sheri added support for including coff data in windows shared libraries 46 | # compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in 47 | # the source dir by the user prior to building 48 | # 2011-10-04 Sheri changed various add_test's to use exes' location built instead 49 | # of DEBUG location only (likely only matters in MSVC) 50 | # 2011-10-04 Sheri added scripts to provide needed variables to RunTest and 51 | # RunGrepTest (used for UNIX and Msys) 52 | # 2011-10-04 Sheri added scripts to provide needed variables and to execute 53 | # RunTest.bat in Win32 (for effortless testing with "make test") 54 | # 2011-10-04 Sheri Increased minimum required cmake version 55 | # 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c 56 | # 2012-01-10 Zoltan Herczeg added libpcre16 support 57 | # 2012-01-13 Stephen Kelly added out of source build support 58 | # 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out 59 | # of the configure.ac file 60 | # 2012-02-26 PH added support for libedit 61 | # 2012-09-06 PH added support for PCRE_EBCDIC_NL25 62 | # 2012-09-08 ChPe added PCRE32 support 63 | # 2012-10-23 PH added support for VALGRIND and GCOV 64 | # 2012-12-08 PH added patch from Daniel Richard G to quash some MSVC warnings 65 | # 2013-07-01 PH realized that the "support" for GCOV was a total nonsense and 66 | # so it has been removed. 67 | # 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".") 68 | # 2013-11-05 PH added support for PARENS_NEST_LIMIT 69 | # 2014-08-29 PH converted the file for PCRE2 (which has no C++). 70 | # 2015-04-24 PH added support for PCRE2_DEBUG 71 | # 2015-07-16 PH updated for new pcre2_find_bracket source module 72 | # 2015-08-24 PH correct C_FLAGS setting (patch from Roy Ivy III) 73 | # 2015-10=16 PH added support for never-backslash-C 74 | # 2016-03-01 PH applied Chris Wilson's patch for MSVC static 75 | # 2016-06-24 PH applied Chris Wilson's second patch, putting the first under 76 | # a new option instead of being unconditional. 77 | 78 | PROJECT(PCRE2 C) 79 | 80 | # Increased minimum to 2.8.0 to support newer add_test features. Set policy 81 | # CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY. 82 | 83 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) 84 | CMAKE_POLICY(SET CMP0026 OLD) 85 | 86 | SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake 87 | 88 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/src") 89 | 90 | # external packages 91 | FIND_PACKAGE( BZip2 ) 92 | FIND_PACKAGE( ZLIB ) 93 | FIND_PACKAGE( Readline ) 94 | FIND_PACKAGE( Editline ) 95 | 96 | # Configuration checks 97 | 98 | INCLUDE(CheckIncludeFile) 99 | INCLUDE(CheckFunctionExists) 100 | INCLUDE(CheckTypeSize) 101 | 102 | CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) 103 | CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) 104 | CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) 105 | CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) 106 | CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) 107 | CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) 108 | CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H) 109 | 110 | CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY) 111 | CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE) 112 | CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR) 113 | 114 | # User-configurable options 115 | # 116 | # Note: CMakeSetup displays these in alphabetical order, regardless of 117 | # the order we use here. 118 | 119 | SET(BUILD_SHARED_LIBS OFF CACHE BOOL 120 | "Build shared libraries instead of static ones.") 121 | 122 | OPTION(PCRE2_BUILD_PCRE2_8 "Build 8 bit PCRE2 library" ON) 123 | 124 | OPTION(PCRE2_BUILD_PCRE2_16 "Build 16 bit PCRE2 library" OFF) 125 | 126 | OPTION(PCRE2_BUILD_PCRE2_32 "Build 32 bit PCRE2 library" OFF) 127 | 128 | OPTION(PCRE2_DEBUG "Include debugging code" OFF) 129 | 130 | SET(PCRE2_EBCDIC OFF CACHE BOOL 131 | "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)") 132 | 133 | SET(PCRE2_EBCDIC_NL25 OFF CACHE BOOL 134 | "Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.") 135 | 136 | SET(PCRE2_LINK_SIZE "2" CACHE STRING 137 | "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.") 138 | 139 | SET(PCRE2_PARENS_NEST_LIMIT "250" CACHE STRING 140 | "Default nested parentheses limit. See PARENS_NEST_LIMIT in config.h.in for details.") 141 | 142 | SET(PCRE2_MATCH_LIMIT "10000000" CACHE STRING 143 | "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.") 144 | 145 | SET(PCRE2_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING 146 | "Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.") 147 | 148 | SET(PCRE2GREP_BUFSIZE "20480" CACHE STRING 149 | "Buffer size parameter for pcre2grep. See PCRE2GREP_BUFSIZE in config.h.in for details.") 150 | 151 | SET(PCRE2_NEWLINE "LF" CACHE STRING 152 | "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).") 153 | 154 | SET(PCRE2_HEAP_MATCH_RECURSE OFF CACHE BOOL 155 | "If ON, then don't use stack recursion when matching. See HEAP_MATCH_RECURSE in config.h.in for details.") 156 | 157 | SET(PCRE2_SUPPORT_JIT OFF CACHE BOOL 158 | "Enable support for Just-in-time compiling.") 159 | 160 | SET(PCRE2_SUPPORT_PCRE2GREP_JIT ON CACHE BOOL 161 | "Enable use of Just-in-time compiling in pcre2grep.") 162 | 163 | SET(PCRE2_SUPPORT_PCRE2GREP_CALLOUT ON CACHE BOOL 164 | "Enable callout string support in pcre2grep.") 165 | 166 | SET(PCRE2_SUPPORT_UNICODE ON CACHE BOOL 167 | "Enable support for Unicode and UTF-8/UTF-16/UTF-32 encoding.") 168 | 169 | SET(PCRE2_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL 170 | "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks") 171 | 172 | SET(PCRE2_NEVER_BACKSLASH_C OFF CACHE BOOL 173 | "If ON, backslash-C (upper case C) is locked out.") 174 | 175 | SET(PCRE2_SUPPORT_VALGRIND OFF CACHE BOOL 176 | "Enable Valgrind support.") 177 | 178 | OPTION(PCRE2_SHOW_REPORT "Show the final configuration report" ON) 179 | OPTION(PCRE2_BUILD_PCRE2GREP "Build pcre2grep" ON) 180 | OPTION(PCRE2_BUILD_TESTS "Build the tests" ON) 181 | 182 | IF (MINGW) 183 | OPTION(NON_STANDARD_LIB_PREFIX 184 | "ON=Shared libraries built in mingw will be named pcre2.dll, etc., instead of libpcre2.dll, etc." 185 | OFF) 186 | 187 | OPTION(NON_STANDARD_LIB_SUFFIX 188 | "ON=Shared libraries built in mingw will be named libpcre2-0.dll, etc., instead of libpcre2.dll, etc." 189 | OFF) 190 | ENDIF(MINGW) 191 | 192 | IF(MSVC) 193 | OPTION(PCRE_STATIC_RUNTIME 194 | "ON=Compile against the static runtime (/MT)." 195 | OFF) 196 | OPTION(INSTALL_MSVC_PDB 197 | "ON=Install .pdb files built by MSVC, if generated" 198 | OFF) 199 | ENDIF(MSVC) 200 | 201 | # bzip2 lib 202 | IF(BZIP2_FOUND) 203 | OPTION (PCRE2_SUPPORT_LIBBZ2 "Enable support for linking pcre2grep with libbz2." ON) 204 | ENDIF(BZIP2_FOUND) 205 | IF(PCRE2_SUPPORT_LIBBZ2) 206 | INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR}) 207 | ENDIF(PCRE2_SUPPORT_LIBBZ2) 208 | 209 | # zlib 210 | IF(ZLIB_FOUND) 211 | OPTION (PCRE2_SUPPORT_LIBZ "Enable support for linking pcre2grep with libz." ON) 212 | ENDIF(ZLIB_FOUND) 213 | IF(PCRE2_SUPPORT_LIBZ) 214 | INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 215 | ENDIF(PCRE2_SUPPORT_LIBZ) 216 | 217 | # editline lib 218 | IF(EDITLINE_FOUND) 219 | OPTION (PCRE2_SUPPORT_LIBEDIT "Enable support for linking pcre2test with libedit." OFF) 220 | ENDIF(EDITLINE_FOUND) 221 | IF(PCRE2_SUPPORT_LIBEDIT) 222 | INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR}) 223 | ENDIF(PCRE2_SUPPORT_LIBEDIT) 224 | 225 | # readline lib 226 | IF(READLINE_FOUND) 227 | OPTION (PCRE2_SUPPORT_LIBREADLINE "Enable support for linking pcre2test with libreadline." ON) 228 | ENDIF(READLINE_FOUND) 229 | IF(PCRE2_SUPPORT_LIBREADLINE) 230 | INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR}) 231 | ENDIF(PCRE2_SUPPORT_LIBREADLINE) 232 | 233 | # Prepare build configuration 234 | 235 | IF(NOT BUILD_SHARED_LIBS) 236 | SET(PCRE2_STATIC 1) 237 | ENDIF(NOT BUILD_SHARED_LIBS) 238 | 239 | IF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32) 240 | MESSAGE(FATAL_ERROR "At least one of PCRE2_BUILD_PCRE2_8, PCRE2_BUILD_PCRE2_16 or PCRE2_BUILD_PCRE2_32 must be enabled") 241 | ENDIF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32) 242 | 243 | IF(PCRE2_BUILD_PCRE2_8) 244 | SET(SUPPORT_PCRE2_8 1) 245 | ENDIF(PCRE2_BUILD_PCRE2_8) 246 | 247 | IF(PCRE2_BUILD_PCRE2_16) 248 | SET(SUPPORT_PCRE2_16 1) 249 | ENDIF(PCRE2_BUILD_PCRE2_16) 250 | 251 | IF(PCRE2_BUILD_PCRE2_32) 252 | SET(SUPPORT_PCRE2_32 1) 253 | ENDIF(PCRE2_BUILD_PCRE2_32) 254 | 255 | IF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8) 256 | MESSAGE(STATUS "** PCRE2_BUILD_PCRE2_8 must be enabled for the pcre2grep program") 257 | SET(PCRE2_BUILD_PCRE2GREP OFF) 258 | ENDIF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8) 259 | 260 | IF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT) 261 | MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified") 262 | ENDIF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT) 263 | 264 | IF(PCRE2_SUPPORT_BSR_ANYCRLF) 265 | SET(BSR_ANYCRLF 1) 266 | ENDIF(PCRE2_SUPPORT_BSR_ANYCRLF) 267 | 268 | IF(PCRE2_NEVER_BACKSLASH_C) 269 | SET(NEVER_BACKSLASH_C 1) 270 | ENDIF(PCRE2_NEVER_BACKSLASH_C) 271 | 272 | IF(PCRE2_SUPPORT_UNICODE) 273 | SET(SUPPORT_UNICODE 1) 274 | ENDIF(PCRE2_SUPPORT_UNICODE) 275 | 276 | IF(PCRE2_SUPPORT_JIT) 277 | SET(SUPPORT_JIT 1) 278 | ENDIF(PCRE2_SUPPORT_JIT) 279 | 280 | IF(PCRE2_SUPPORT_PCRE2GREP_JIT) 281 | SET(SUPPORT_PCRE2GREP_JIT 1) 282 | ENDIF(PCRE2_SUPPORT_PCRE2GREP_JIT) 283 | 284 | IF(PCRE2_SUPPORT_PCRE2GREP_CALLOUT) 285 | SET(SUPPORT_PCRE2GREP_CALLOUT 1) 286 | ENDIF(PCRE2_SUPPORT_PCRE2GREP_CALLOUT) 287 | 288 | IF(PCRE2_SUPPORT_VALGRIND) 289 | SET(SUPPORT_VALGRIND 1) 290 | ENDIF(PCRE2_SUPPORT_VALGRIND) 291 | 292 | # This next one used to reference ${READLINE_LIBRARY}) 293 | # but I was advised to add the NCURSES test as well, along with 294 | # some modifications to cmake/FindReadline.cmake which should 295 | # make it possible to override the default if necessary. PH 296 | 297 | IF(PCRE2_SUPPORT_LIBREADLINE) 298 | SET(SUPPORT_LIBREADLINE 1) 299 | SET(PCRE2TEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY}) 300 | ENDIF(PCRE2_SUPPORT_LIBREADLINE) 301 | 302 | # libedit is a plug-compatible alternative to libreadline 303 | 304 | IF(PCRE2_SUPPORT_LIBEDIT) 305 | SET(SUPPORT_LIBEDIT 1) 306 | SET(PCRE2TEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY}) 307 | ENDIF(PCRE2_SUPPORT_LIBEDIT) 308 | 309 | IF(PCRE2_SUPPORT_LIBZ) 310 | SET(SUPPORT_LIBZ 1) 311 | SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${ZLIB_LIBRARIES}) 312 | ENDIF(PCRE2_SUPPORT_LIBZ) 313 | 314 | IF(PCRE2_SUPPORT_LIBBZ2) 315 | SET(SUPPORT_LIBBZ2 1) 316 | SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${BZIP2_LIBRARIES}) 317 | ENDIF(PCRE2_SUPPORT_LIBBZ2) 318 | 319 | SET(NEWLINE_DEFAULT "") 320 | 321 | IF(PCRE2_NEWLINE STREQUAL "CR") 322 | SET(NEWLINE_DEFAULT "1") 323 | ENDIF(PCRE2_NEWLINE STREQUAL "CR") 324 | IF(PCRE2_NEWLINE STREQUAL "LF") 325 | SET(NEWLINE_DEFAULT "2") 326 | ENDIF(PCRE2_NEWLINE STREQUAL "LF") 327 | IF(PCRE2_NEWLINE STREQUAL "CRLF") 328 | SET(NEWLINE_DEFAULT "3") 329 | ENDIF(PCRE2_NEWLINE STREQUAL "CRLF") 330 | IF(PCRE2_NEWLINE STREQUAL "ANY") 331 | SET(NEWLINE_DEFAULT "4") 332 | ENDIF(PCRE2_NEWLINE STREQUAL "ANY") 333 | IF(PCRE2_NEWLINE STREQUAL "ANYCRLF") 334 | SET(NEWLINE_DEFAULT "5") 335 | ENDIF(PCRE2_NEWLINE STREQUAL "ANYCRLF") 336 | 337 | IF(NEWLINE_DEFAULT STREQUAL "") 338 | MESSAGE(FATAL_ERROR "The PCRE2_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".") 339 | ENDIF(NEWLINE_DEFAULT STREQUAL "") 340 | 341 | IF(PCRE2_EBCDIC) 342 | SET(EBCDIC 1) 343 | ENDIF(PCRE2_EBCDIC) 344 | 345 | IF(PCRE2_EBCDIC_NL25) 346 | SET(EBCDIC 1) 347 | SET(EBCDIC_NL25 1) 348 | ENDIF(PCRE2_EBCDIC_NL25) 349 | 350 | IF(PCRE2_HEAP_MATCH_RECURSE) 351 | SET(HEAP_MATCH_RECURSE 1) 352 | ENDIF(PCRE2_HEAP_MATCH_RECURSE) 353 | 354 | # Output files 355 | 356 | CONFIGURE_FILE(config-cmake.h.in 357 | ${PROJECT_BINARY_DIR}/config.h 358 | @ONLY) 359 | 360 | # Parse version numbers and date out of configure.ac 361 | 362 | file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac 363 | configure_lines 364 | LIMIT_COUNT 50 # Read only the first 50 lines of the file 365 | ) 366 | 367 | set(SEARCHED_VARIABLES "pcre2_major" "pcre2_minor" "pcre2_prerelease" "pcre2_date") 368 | foreach(configure_line ${configure_lines}) 369 | foreach(_substitution_variable ${SEARCHED_VARIABLES}) 370 | string(TOUPPER ${_substitution_variable} _substitution_variable_upper) 371 | if (NOT ${_substitution_variable_upper}) 372 | string(REGEX MATCH "m4_define\\(${_substitution_variable}, \\[(.*)\\]" MACTHED_STRING ${configure_line}) 373 | if (CMAKE_MATCH_1) 374 | set(${_substitution_variable_upper} ${CMAKE_MATCH_1}) 375 | endif() 376 | endif() 377 | endforeach() 378 | endforeach() 379 | 380 | CONFIGURE_FILE(src/pcre2.h.in 381 | ${PROJECT_BINARY_DIR}/pcre2.h 382 | @ONLY) 383 | 384 | # What about pcre2-config and libpcre2.pc? 385 | 386 | # Character table generation 387 | 388 | OPTION(PCRE2_REBUILD_CHARTABLES "Rebuild char tables" OFF) 389 | IF(PCRE2_REBUILD_CHARTABLES) 390 | ADD_EXECUTABLE(dftables src/dftables.c) 391 | ADD_CUSTOM_COMMAND( 392 | COMMENT "Generating character tables (pcre2_chartables.c) for current locale" 393 | DEPENDS dftables 394 | COMMAND dftables 395 | ARGS ${PROJECT_BINARY_DIR}/pcre2_chartables.c 396 | OUTPUT ${PROJECT_BINARY_DIR}/pcre2_chartables.c 397 | ) 398 | ELSE(PCRE2_REBUILD_CHARTABLES) 399 | CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.dist 400 | ${PROJECT_BINARY_DIR}/pcre2_chartables.c 401 | COPYONLY) 402 | ENDIF(PCRE2_REBUILD_CHARTABLES) 403 | 404 | # Source code 405 | 406 | SET(PCRE2_HEADERS ${PROJECT_BINARY_DIR}/pcre2.h) 407 | 408 | SET(PCRE2_SOURCES 409 | src/pcre2_auto_possess.c 410 | ${PROJECT_BINARY_DIR}/pcre2_chartables.c 411 | src/pcre2_compile.c 412 | src/pcre2_config.c 413 | src/pcre2_context.c 414 | src/pcre2_dfa_match.c 415 | src/pcre2_error.c 416 | src/pcre2_find_bracket.c 417 | src/pcre2_jit_compile.c 418 | src/pcre2_maketables.c 419 | src/pcre2_match.c 420 | src/pcre2_match_data.c 421 | src/pcre2_newline.c 422 | src/pcre2_ord2utf.c 423 | src/pcre2_pattern_info.c 424 | src/pcre2_serialize.c 425 | src/pcre2_string_utils.c 426 | src/pcre2_study.c 427 | src/pcre2_substitute.c 428 | src/pcre2_substring.c 429 | src/pcre2_tables.c 430 | src/pcre2_ucd.c 431 | src/pcre2_valid_utf.c 432 | src/pcre2_xclass.c 433 | ) 434 | 435 | SET(PCRE2POSIX_HEADERS src/pcre2posix.h) 436 | SET(PCRE2POSIX_SOURCES src/pcre2posix.c) 437 | 438 | IF(MINGW AND NOT PCRE2_STATIC) 439 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) 440 | ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2.o 441 | PRE-LINK 442 | COMMAND windres ARGS pcre2.rc pcre2.o 443 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 444 | COMMENT Using pcre2 coff info in mingw build) 445 | SET(PCRE2_SOURCES 446 | ${PCRE2_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2.o 447 | ) 448 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) 449 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) 450 | ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2posix.o 451 | PRE-LINK 452 | COMMAND windres ARGS pcre2posix.rc pcre2posix.o 453 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 454 | COMMENT Using pcre2posix coff info in mingw build) 455 | SET(PCRE2POSIX_SOURCES 456 | ${PCRE2POSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2posix.o 457 | ) 458 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) 459 | ENDIF(MINGW AND NOT PCRE2_STATIC) 460 | 461 | IF(MSVC AND NOT PCRE2_STATIC) 462 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) 463 | SET(PCRE2_SOURCES 464 | ${PCRE2_SOURCES} pcre2.rc) 465 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) 466 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) 467 | SET(PCRE2POSIX_SOURCES 468 | ${PCRE2POSIX_SOURCES} pcre2posix.rc) 469 | ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) 470 | ENDIF(MSVC AND NOT PCRE2_STATIC) 471 | 472 | # Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681 473 | # This code was taken from the CMake wiki, not from WebM. 474 | 475 | IF(MSVC AND PCRE2_STATIC_RUNTIME) 476 | MESSAGE(STATUS "** MSVC and PCRE2_STATIC_RUNTIME: modifying compiler flags to use static runtime library") 477 | foreach(flag_var 478 | CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE 479 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) 480 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") 481 | endforeach() 482 | ENDIF(MSVC AND PCRE2_STATIC_RUNTIME) 483 | 484 | # Build setup 485 | 486 | ADD_DEFINITIONS(-DHAVE_CONFIG_H) 487 | 488 | IF(MSVC) 489 | ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS) 490 | ENDIF(MSVC) 491 | 492 | SET(CMAKE_INCLUDE_CURRENT_DIR 1) 493 | # needed to make sure to not link debug libs 494 | # against release libs and vice versa 495 | IF(WIN32) 496 | SET(CMAKE_DEBUG_POSTFIX "d") 497 | ENDIF(WIN32) 498 | 499 | SET(targets) 500 | 501 | # 8-bit library 502 | 503 | IF(PCRE2_BUILD_PCRE2_8) 504 | ADD_LIBRARY(pcre2-8 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) 505 | SET_PROPERTY(TARGET pcre2-8 506 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8) 507 | SET(targets ${targets} pcre2-8) 508 | ADD_LIBRARY(pcre2posix ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES}) 509 | SET_PROPERTY(TARGET pcre2posix 510 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8) 511 | SET(targets ${targets} pcre2posix) 512 | TARGET_LINK_LIBRARIES(pcre2posix pcre2-8) 513 | 514 | IF(MINGW AND NOT PCRE2_STATIC) 515 | IF(NON_STANDARD_LIB_PREFIX) 516 | SET_TARGET_PROPERTIES(pcre2-8 pcre2posix PROPERTIES PREFIX "") 517 | ENDIF(NON_STANDARD_LIB_PREFIX) 518 | IF(NON_STANDARD_LIB_SUFFIX) 519 | SET_TARGET_PROPERTIES(pcre2-8 pcre2posix PROPERTIES SUFFIX "-0.dll") 520 | ENDIF(NON_STANDARD_LIB_SUFFIX) 521 | ENDIF(MINGW AND NOT PCRE2_STATIC) 522 | ENDIF(PCRE2_BUILD_PCRE2_8) 523 | 524 | # 16-bit library 525 | 526 | IF(PCRE2_BUILD_PCRE2_16) 527 | ADD_LIBRARY(pcre2-16 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) 528 | SET_PROPERTY(TARGET pcre2-16 529 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16) 530 | SET(targets ${targets} pcre2-16) 531 | 532 | IF(MINGW AND NOT PCRE2_STATIC) 533 | IF(NON_STANDARD_LIB_PREFIX) 534 | SET_TARGET_PROPERTIES(pcre2-16 PROPERTIES PREFIX "") 535 | ENDIF(NON_STANDARD_LIB_PREFIX) 536 | IF(NON_STANDARD_LIB_SUFFIX) 537 | SET_TARGET_PROPERTIES(pcre2-16 PROPERTIES SUFFIX "-0.dll") 538 | ENDIF(NON_STANDARD_LIB_SUFFIX) 539 | ENDIF(MINGW AND NOT PCRE2_STATIC) 540 | ENDIF(PCRE2_BUILD_PCRE2_16) 541 | 542 | # 32-bit library 543 | 544 | IF(PCRE2_BUILD_PCRE2_32) 545 | ADD_LIBRARY(pcre2-32 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) 546 | SET_PROPERTY(TARGET pcre2-32 547 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32) 548 | SET(targets ${targets} pcre2-32) 549 | 550 | IF(MINGW AND NOT PCRE2_STATIC) 551 | IF(NON_STANDARD_LIB_PREFIX) 552 | SET_TARGET_PROPERTIES(pcre2-32 PROPERTIES PREFIX "") 553 | ENDIF(NON_STANDARD_LIB_PREFIX) 554 | IF(NON_STANDARD_LIB_SUFFIX) 555 | SET_TARGET_PROPERTIES(pcre2-32 PROPERTIES SUFFIX "-0.dll") 556 | ENDIF(NON_STANDARD_LIB_SUFFIX) 557 | ENDIF(MINGW AND NOT PCRE2_STATIC) 558 | ENDIF(PCRE2_BUILD_PCRE2_32) 559 | 560 | # Executables 561 | 562 | IF(PCRE2_BUILD_PCRE2GREP) 563 | ADD_EXECUTABLE(pcre2grep src/pcre2grep.c) 564 | SET_PROPERTY(TARGET pcre2grep 565 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8) 566 | SET(targets ${targets} pcre2grep) 567 | TARGET_LINK_LIBRARIES(pcre2grep pcre2posix ${PCRE2GREP_LIBS}) 568 | ENDIF(PCRE2_BUILD_PCRE2GREP) 569 | 570 | # Testing 571 | 572 | IF(PCRE2_BUILD_TESTS) 573 | ENABLE_TESTING() 574 | 575 | SET(PCRE2TEST_SOURCES src/pcre2test.c) 576 | 577 | ADD_EXECUTABLE(pcre2test ${PCRE2TEST_SOURCES}) 578 | SET(targets ${targets} pcre2test) 579 | IF(PCRE2_BUILD_PCRE2_8) 580 | LIST(APPEND PCRE2TEST_LIBS pcre2posix pcre2-8) 581 | ENDIF(PCRE2_BUILD_PCRE2_8) 582 | IF(PCRE2_BUILD_PCRE2_16) 583 | LIST(APPEND PCRE2TEST_LIBS pcre2-16) 584 | ENDIF(PCRE2_BUILD_PCRE2_16) 585 | IF(PCRE2_BUILD_PCRE2_32) 586 | LIST(APPEND PCRE2TEST_LIBS pcre2-32) 587 | ENDIF(PCRE2_BUILD_PCRE2_32) 588 | TARGET_LINK_LIBRARIES(pcre2test ${PCRE2TEST_LIBS}) 589 | 590 | IF(PCRE2_SUPPORT_JIT) 591 | ADD_EXECUTABLE(pcre2_jit_test src/pcre2_jit_test.c) 592 | SET(targets ${targets} pcre2_jit_test) 593 | SET(PCRE2_JIT_TEST_LIBS ) 594 | IF(PCRE2_BUILD_PCRE2_8) 595 | LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-8) 596 | ENDIF(PCRE2_BUILD_PCRE2_8) 597 | IF(PCRE2_BUILD_PCRE2_16) 598 | LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-16) 599 | ENDIF(PCRE2_BUILD_PCRE2_16) 600 | IF(PCRE2_BUILD_PCRE2_32) 601 | LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-32) 602 | ENDIF(PCRE2_BUILD_PCRE2_32) 603 | TARGET_LINK_LIBRARIES(pcre2_jit_test ${PCRE2_JIT_TEST_LIBS}) 604 | ENDIF(PCRE2_SUPPORT_JIT) 605 | 606 | # exes in Debug location tested by the RunTest shell script 607 | # via "make test" 608 | 609 | IF(PCRE2_BUILD_PCRE2GREP) 610 | GET_TARGET_PROPERTY(PCRE2GREP_EXE pcre2grep DEBUG_LOCATION) 611 | ENDIF(PCRE2_BUILD_PCRE2GREP) 612 | 613 | GET_TARGET_PROPERTY(PCRE2TEST_EXE pcre2test DEBUG_LOCATION) 614 | 615 | # ================================================= 616 | # Write out a CTest configuration file 617 | # 618 | FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest 619 | "# This is a generated file. 620 | MESSAGE(\"When testing is complete, review test output in the 621 | \\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\") 622 | MESSAGE(\" \") 623 | ") 624 | 625 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.sh 626 | "#! /bin/sh 627 | # This is a generated file. 628 | . ${PROJECT_SOURCE_DIR}/RunTest 629 | if test \"$?\" != \"0\"; then exit 1; fi 630 | # End 631 | ") 632 | 633 | IF(UNIX) 634 | ADD_TEST(pcre2_test sh ${PROJECT_BINARY_DIR}/pcre2_test.sh) 635 | ENDIF(UNIX) 636 | 637 | IF(PCRE2_BUILD_PCRE2GREP) 638 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh 639 | "#! /bin/sh 640 | # This is a generated file. 641 | . ${PROJECT_SOURCE_DIR}/RunGrepTest 642 | if test \"$?\" != \"0\"; then exit 1; fi 643 | # End 644 | ") 645 | 646 | IF(UNIX) 647 | ADD_TEST(pcre2_grep_test sh ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh) 648 | ENDIF(UNIX) 649 | ENDIF(PCRE2_BUILD_PCRE2GREP) 650 | 651 | IF(WIN32) 652 | # Provide environment for executing the bat file version of RunTest 653 | FILE(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc) 654 | FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin) 655 | FILE(TO_NATIVE_PATH ${PCRE2TEST_EXE} winexe) 656 | 657 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.bat 658 | "\@REM This is a generated file. 659 | \@echo off 660 | setlocal 661 | SET srcdir=\"${winsrc}\" 662 | SET pcre2test=\"${winexe}\" 663 | if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2test=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2test.exe\" 664 | call %srcdir%\\RunTest.Bat 665 | if errorlevel 1 exit /b 1 666 | echo RunTest.bat tests successfully completed 667 | ") 668 | 669 | ADD_TEST(NAME pcre2_test_bat 670 | COMMAND pcre2_test.bat) 671 | SET_TESTS_PROPERTIES(pcre2_test_bat PROPERTIES 672 | PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed") 673 | 674 | IF("$ENV{OSTYPE}" STREQUAL "msys") 675 | # Both the sh and bat file versions of RunTest are run if make test is used 676 | # in msys 677 | ADD_TEST(pcre2_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre2_test.sh) 678 | IF(PCRE2_BUILD_PCRE2GREP) 679 | ADD_TEST(pcre2_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh) 680 | ENDIF(PCRE2_BUILD_PCRE2GREP) 681 | ENDIF("$ENV{OSTYPE}" STREQUAL "msys") 682 | ENDIF(WIN32) 683 | 684 | # Changed to accommodate testing whichever location was just built 685 | 686 | IF(PCRE2_SUPPORT_JIT) 687 | ADD_TEST(pcre2_jit_test pcre2_jit_test) 688 | ENDIF(PCRE2_SUPPORT_JIT) 689 | 690 | ENDIF(PCRE2_BUILD_TESTS) 691 | 692 | # Installation 693 | 694 | SET(CMAKE_INSTALL_ALWAYS 1) 695 | 696 | INSTALL(TARGETS ${targets} 697 | RUNTIME DESTINATION bin 698 | LIBRARY DESTINATION lib 699 | ARCHIVE DESTINATION lib) 700 | 701 | INSTALL(FILES ${PCRE2_HEADERS} ${PCRE2POSIX_HEADERS} DESTINATION include) 702 | 703 | FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html) 704 | FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1) 705 | FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3) 706 | 707 | FOREACH(man ${man3}) 708 | GET_FILENAME_COMPONENT(man_tmp ${man} NAME) 709 | SET(man3_new ${man3} ${man}) 710 | ENDFOREACH(man ${man3}) 711 | SET(man3 ${man3_new}) 712 | 713 | INSTALL(FILES ${man1} DESTINATION man/man1) 714 | INSTALL(FILES ${man3} DESTINATION man/man3) 715 | INSTALL(FILES ${html} DESTINATION share/doc/pcre2/html) 716 | 717 | IF(MSVC AND INSTALL_MSVC_PDB) 718 | INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre2.pdb 719 | ${PROJECT_BINARY_DIR}/pcre2posix.pdb 720 | DESTINATION bin 721 | CONFIGURATIONS RelWithDebInfo) 722 | INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre2d.pdb 723 | ${PROJECT_BINARY_DIR}/pcre2posixd.pdb 724 | DESTINATION bin 725 | CONFIGURATIONS Debug) 726 | ENDIF(MSVC AND INSTALL_MSVC_PDB) 727 | 728 | # Help, only for nice output 729 | IF(BUILD_SHARED_LIBS) 730 | SET(BUILD_STATIC_LIBS OFF) 731 | ELSE(BUILD_SHARED_LIBS) 732 | SET(BUILD_STATIC_LIBS ON) 733 | ENDIF(BUILD_SHARED_LIBS) 734 | 735 | IF(PCRE2_SHOW_REPORT) 736 | STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype) 737 | IF (CMAKE_C_FLAGS) 738 | SET(cfsp " ") 739 | ENDIF(CMAKE_C_FLAGS) 740 | MESSAGE(STATUS "") 741 | MESSAGE(STATUS "") 742 | MESSAGE(STATUS "PCRE2 configuration summary:") 743 | MESSAGE(STATUS "") 744 | MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}") 745 | MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}") 746 | MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}") 747 | MESSAGE(STATUS "") 748 | MESSAGE(STATUS " Build 8 bit PCRE2 library ....... : ${PCRE2_BUILD_PCRE2_8}") 749 | MESSAGE(STATUS " Build 16 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_16}") 750 | MESSAGE(STATUS " Build 32 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_32}") 751 | MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE2_SUPPORT_JIT}") 752 | MESSAGE(STATUS " Enable Unicode support .......... : ${PCRE2_SUPPORT_UNICODE}") 753 | MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE2_NEWLINE}") 754 | MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE2_SUPPORT_BSR_ANYCRLF}") 755 | MESSAGE(STATUS " \\C is disabled .................. : ${PCRE2_NEVER_BACKSLASH_C}") 756 | MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE2_EBCDIC}") 757 | MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE2_EBCDIC_NL25}") 758 | MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE2_REBUILD_CHARTABLES}") 759 | MESSAGE(STATUS " Use heap recursion .............. : ${PCRE2_HEAP_MATCH_RECURSE}") 760 | MESSAGE(STATUS " Internal link size .............. : ${PCRE2_LINK_SIZE}") 761 | MESSAGE(STATUS " Parentheses nest limit .......... : ${PCRE2_PARENS_NEST_LIMIT}") 762 | MESSAGE(STATUS " Match limit ..................... : ${PCRE2_MATCH_LIMIT}") 763 | MESSAGE(STATUS " Match limit recursion ........... : ${PCRE2_MATCH_LIMIT_RECURSION}") 764 | MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}") 765 | MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}") 766 | MESSAGE(STATUS " Build pcre2grep ................. : ${PCRE2_BUILD_PCRE2GREP}") 767 | MESSAGE(STATUS " Enable JIT in pcre2grep ......... : ${PCRE2_SUPPORT_PCRE2GREP_JIT}") 768 | MESSAGE(STATUS " Enable callouts in pcre2grep .... : ${PCRE2_SUPPORT_PCRE2GREP_CALLOUT}") 769 | MESSAGE(STATUS " Buffer size for pcre2grep ....... : ${PCRE2GREP_BUFSIZE}") 770 | MESSAGE(STATUS " Build tests (implies pcre2test . : ${PCRE2_BUILD_TESTS}") 771 | MESSAGE(STATUS " and pcre2grep)") 772 | IF(ZLIB_FOUND) 773 | MESSAGE(STATUS " Link pcre2grep with libz ........ : ${PCRE2_SUPPORT_LIBZ}") 774 | ELSE(ZLIB_FOUND) 775 | MESSAGE(STATUS " Link pcre2grep with libz ........ : Library not found" ) 776 | ENDIF(ZLIB_FOUND) 777 | IF(BZIP2_FOUND) 778 | MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : ${PCRE2_SUPPORT_LIBBZ2}") 779 | ELSE(BZIP2_FOUND) 780 | MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : Library not found" ) 781 | ENDIF(BZIP2_FOUND) 782 | IF(EDITLINE_FOUND) 783 | MESSAGE(STATUS " Link pcre2test with libeditline . : ${PCRE2_SUPPORT_LIBEDIT}") 784 | ELSE(EDITLINE_FOUND) 785 | MESSAGE(STATUS " Link pcre2test with libeditline . : Library not found" ) 786 | ENDIF(EDITLINE_FOUND) 787 | IF(READLINE_FOUND) 788 | MESSAGE(STATUS " Link pcre2test with libreadline . : ${PCRE2_SUPPORT_LIBREADLINE}") 789 | ELSE(READLINE_FOUND) 790 | MESSAGE(STATUS " Link pcre2test with libreadline . : Library not found" ) 791 | ENDIF(READLINE_FOUND) 792 | MESSAGE(STATUS " Support Valgrind .................: ${PCRE2_SUPPORT_VALGRIND}") 793 | 794 | IF(MINGW AND NOT PCRE2_STATIC) 795 | MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}") 796 | MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}") 797 | ENDIF(MINGW AND NOT PCRE2_STATIC) 798 | 799 | IF(MSVC) 800 | MESSAGE(STATUS " Install MSVC .pdb files ..........: ${INSTALL_MSVC_PDB}") 801 | ENDIF(MSVC) 802 | 803 | MESSAGE(STATUS "") 804 | ENDIF(PCRE2_SHOW_REPORT) 805 | 806 | # end CMakeLists.txt 807 | -------------------------------------------------------------------------------- /cmake/tinyxml/all.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.7) 2 | 3 | project(tinyxml) 4 | 5 | set (SOURCES tinyxml.cpp tinyxmlparser.cpp xmltest.cpp tinyxmlerror.cpp tinystr.cpp) 6 | set (HEADERS tinystr.h tinyxml.h) 7 | 8 | add_library(tinyxml SHARED ${SOURCES} ${HEADERS}) 9 | 10 | set_target_properties(tinyxml PROPERTIES OUTPUT_NAME "tinyxml") 11 | 12 | install(TARGETS tinyxml 13 | LIBRARY DESTINATION lib 14 | RUNTIME DESTINATION bin) 15 | 16 | install(FILES ${HEADERS} DESTINATION include) -------------------------------------------------------------------------------- /cmake/xz/all.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.7) 2 | 3 | project(xz C) 4 | 5 | if (MSVC_VERSION LESS 1900) 6 | message("only MSVC v14 or later are supported by this CMake file") 7 | set(CMAKE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO}) 8 | return () 9 | ENDIF () 10 | 11 | # general C flags 12 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DHAVE_CONFIG_H /DWIN32 /DDLL_EXPORT /DNDEBUG /D_WINDOWS /D_USRDLL /DLIBLZMADLL_EXPORTS") 13 | 14 | set (SOURCES src/common/tuklib_cpucores.c 15 | src/common/tuklib_physmem.c 16 | src/liblzma/check/check.c 17 | src/liblzma/check/crc32_fast.c 18 | src/liblzma/check/crc32_table.c 19 | src/liblzma/check/crc64_fast.c 20 | src/liblzma/check/crc64_table.c 21 | src/liblzma/check/sha256.c 22 | src/liblzma/common/alone_decoder.c 23 | src/liblzma/common/alone_encoder.c 24 | src/liblzma/common/auto_decoder.c 25 | src/liblzma/common/block_buffer_decoder.c 26 | src/liblzma/common/block_buffer_encoder.c 27 | src/liblzma/common/block_decoder.c 28 | src/liblzma/common/block_encoder.c 29 | src/liblzma/common/block_header_decoder.c 30 | src/liblzma/common/block_header_encoder.c 31 | src/liblzma/common/block_util.c 32 | src/liblzma/common/common.c 33 | src/liblzma/common/easy_buffer_encoder.c 34 | src/liblzma/common/easy_decoder_memusage.c 35 | src/liblzma/common/easy_encoder.c 36 | src/liblzma/common/easy_encoder_memusage.c 37 | src/liblzma/common/easy_preset.c 38 | src/liblzma/common/filter_buffer_decoder.c 39 | src/liblzma/common/filter_buffer_encoder.c 40 | src/liblzma/common/filter_common.c 41 | src/liblzma/common/filter_decoder.c 42 | src/liblzma/common/filter_encoder.c 43 | src/liblzma/common/filter_flags_decoder.c 44 | src/liblzma/common/filter_flags_encoder.c 45 | src/liblzma/common/hardware_cputhreads.c 46 | src/liblzma/common/hardware_physmem.c 47 | src/liblzma/common/index.c 48 | src/liblzma/common/index_decoder.c 49 | src/liblzma/common/index_encoder.c 50 | src/liblzma/common/index_hash.c 51 | src/liblzma/common/outqueue.c 52 | src/liblzma/common/stream_buffer_decoder.c 53 | src/liblzma/common/stream_buffer_encoder.c 54 | src/liblzma/common/stream_decoder.c 55 | src/liblzma/common/stream_encoder.c 56 | src/liblzma/common/stream_encoder_mt.c 57 | src/liblzma/common/stream_flags_common.c 58 | src/liblzma/common/stream_flags_decoder.c 59 | src/liblzma/common/stream_flags_encoder.c 60 | src/liblzma/common/vli_decoder.c 61 | src/liblzma/common/vli_encoder.c 62 | src/liblzma/common/vli_size.c 63 | src/liblzma/delta/delta_common.c 64 | src/liblzma/delta/delta_decoder.c 65 | src/liblzma/delta/delta_encoder.c 66 | src/liblzma/lzma/fastpos_table.c 67 | src/liblzma/lzma/lzma2_decoder.c 68 | src/liblzma/lzma/lzma2_encoder.c 69 | src/liblzma/lzma/lzma_decoder.c 70 | src/liblzma/lzma/lzma_encoder.c 71 | src/liblzma/lzma/lzma_encoder_optimum_fast.c 72 | src/liblzma/lzma/lzma_encoder_optimum_normal.c 73 | src/liblzma/lzma/lzma_encoder_presets.c 74 | src/liblzma/lz/lz_decoder.c 75 | src/liblzma/lz/lz_encoder.c 76 | src/liblzma/lz/lz_encoder_mf.c 77 | src/liblzma/rangecoder/price_table.c 78 | src/liblzma/simple/arm.c 79 | src/liblzma/simple/armthumb.c 80 | src/liblzma/simple/ia64.c 81 | src/liblzma/simple/powerpc.c 82 | src/liblzma/simple/simple_coder.c 83 | src/liblzma/simple/simple_decoder.c 84 | src/liblzma/simple/simple_encoder.c 85 | src/liblzma/simple/sparc.c 86 | src/liblzma/simple/x86.c) 87 | 88 | set (HEADERS src/common/mythread.h 89 | src/common/sysdefs.h 90 | src/common/tuklib_common.h 91 | src/common/tuklib_config.h 92 | src/common/tuklib_cpucores.h 93 | src/common/tuklib_integer.h 94 | src/common/tuklib_physmem.h 95 | src/liblzma/api/lzma.h 96 | src/liblzma/api/lzma/base.h 97 | src/liblzma/api/lzma/bcj.h 98 | src/liblzma/api/lzma/block.h 99 | src/liblzma/api/lzma/check.h 100 | src/liblzma/api/lzma/container.h 101 | src/liblzma/api/lzma/delta.h 102 | src/liblzma/api/lzma/filter.h 103 | src/liblzma/api/lzma/hardware.h 104 | src/liblzma/api/lzma/index.h 105 | src/liblzma/api/lzma/index_hash.h 106 | src/liblzma/api/lzma/lzma12.h 107 | src/liblzma/api/lzma/stream_flags.h 108 | src/liblzma/api/lzma/version.h 109 | src/liblzma/api/lzma/vli.h 110 | src/liblzma/check/check.h 111 | src/liblzma/check/crc32_table_be.h 112 | src/liblzma/check/crc32_table_le.h 113 | src/liblzma/check/crc64_table_be.h 114 | src/liblzma/check/crc64_table_le.h 115 | src/liblzma/check/crc_macros.h 116 | src/liblzma/common/alone_decoder.h 117 | src/liblzma/common/block_buffer_encoder.h 118 | src/liblzma/common/block_decoder.h 119 | src/liblzma/common/block_encoder.h 120 | src/liblzma/common/common.h 121 | src/liblzma/common/easy_preset.h 122 | src/liblzma/common/filter_common.h 123 | src/liblzma/common/filter_decoder.h 124 | src/liblzma/common/filter_encoder.h 125 | src/liblzma/common/index.h 126 | src/liblzma/common/index_encoder.h 127 | src/liblzma/common/memcmplen.h 128 | src/liblzma/common/outqueue.h 129 | src/liblzma/common/stream_decoder.h 130 | src/liblzma/common/stream_flags_common.h 131 | src/liblzma/delta/delta_common.h 132 | src/liblzma/delta/delta_decoder.h 133 | src/liblzma/delta/delta_encoder.h 134 | src/liblzma/delta/delta_private.h 135 | src/liblzma/lzma/fastpos.h 136 | src/liblzma/lzma/lzma2_decoder.h 137 | src/liblzma/lzma/lzma2_encoder.h 138 | src/liblzma/lzma/lzma_common.h 139 | src/liblzma/lzma/lzma_decoder.h 140 | src/liblzma/lzma/lzma_encoder.h 141 | src/liblzma/lzma/lzma_encoder_private.h 142 | src/liblzma/lz/lz_decoder.h 143 | src/liblzma/lz/lz_encoder.h 144 | src/liblzma/lz/lz_encoder_hash.h 145 | src/liblzma/lz/lz_encoder_hash_table.h 146 | src/liblzma/rangecoder/price.h 147 | src/liblzma/rangecoder/range_common.h 148 | src/liblzma/rangecoder/range_decoder.h 149 | src/liblzma/rangecoder/range_encoder.h 150 | src/liblzma/simple/simple_coder.h 151 | src/liblzma/simple/simple_decoder.h 152 | src/liblzma/simple/simple_encoder.h 153 | src/liblzma/simple/simple_private.h) 154 | 155 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/windows 156 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/common 157 | ${CMAKE_CURRENT_SOURCE_DIR}/src/common 158 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/api 159 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/check 160 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/delta 161 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/lz 162 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/lzma 163 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/rangecoder 164 | ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/simple) 165 | 166 | add_library(xz SHARED ${SOURCES} ${HEADERS}) 167 | set_target_properties(xz PROPERTIES OUTPUT_NAME "xz") 168 | 169 | install(TARGETS xz 170 | LIBRARY DESTINATION lib 171 | RUNTIME DESTINATION bin) -------------------------------------------------------------------------------- /cmake/zlib/zlib-1.2.5.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.4.4) 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) 3 | 4 | project(zlib C) 5 | 6 | if(NOT DEFINED BUILD_SHARED_LIBS) 7 | option(BUILD_SHARED_LIBS "Build a shared library form of zlib" ON) 8 | endif() 9 | 10 | include(CheckTypeSize) 11 | include(CheckFunctionExists) 12 | include(CheckIncludeFile) 13 | include(CheckCSourceCompiles) 14 | enable_testing() 15 | 16 | check_include_file(sys/types.h HAVE_SYS_TYPES_H) 17 | check_include_file(stdint.h HAVE_STDINT_H) 18 | check_include_file(stddef.h HAVE_STDDEF_H) 19 | 20 | # 21 | # Check to see if we have large file support 22 | # 23 | set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) 24 | # We add these other definitions here because CheckTypeSize.cmake 25 | # in CMake 2.4.x does not automatically do so and we want 26 | # compatibility with CMake 2.4.x. 27 | if(HAVE_SYS_TYPES_H) 28 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) 29 | endif() 30 | if(HAVE_STDINT_H) 31 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) 32 | endif() 33 | if(HAVE_STDDEF_H) 34 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) 35 | endif() 36 | check_type_size(off64_t OFF64_T) 37 | if(HAVE_OFF64_T) 38 | add_definitions(-D_LARGEFILE64_SOURCE=1) 39 | endif() 40 | set(CMAKE_REQUIRED_DEFINITIONS) # clear variable 41 | 42 | # 43 | # Check for fseeko 44 | # 45 | check_function_exists(fseeko HAVE_FSEEKO) 46 | if(NOT HAVE_FSEEKO) 47 | add_definitions(-DNO_FSEEKO) 48 | endif() 49 | 50 | # 51 | # Check for unistd.h 52 | # 53 | check_include_file(unistd.h Z_HAVE_UNISTD_H) 54 | 55 | if(MSVC) 56 | set(CMAKE_DEBUG_POSTFIX "d") 57 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 58 | add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) 59 | endif() 60 | 61 | if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) 62 | # If we're doing an out of source build and the user has a zconf.h 63 | # in their source tree... 64 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) 65 | message(FATAL_ERROR 66 | "You must remove ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h " 67 | "from the source tree. This file is included with zlib " 68 | "but CMake generates this file for you automatically " 69 | "in the build directory.") 70 | endif() 71 | endif() 72 | 73 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein 74 | ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) 75 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 76 | 77 | 78 | #============================================================================ 79 | # zlib 80 | #============================================================================ 81 | 82 | set(ZLIB_PUBLIC_HDRS 83 | ${CMAKE_CURRENT_BINARY_DIR}/zconf.h 84 | zlib.h 85 | ) 86 | set(ZLIB_PRIVATE_HDRS 87 | crc32.h 88 | deflate.h 89 | gzguts.h 90 | inffast.h 91 | inffixed.h 92 | inflate.h 93 | inftrees.h 94 | trees.h 95 | zutil.h 96 | ) 97 | set(ZLIB_SRCS 98 | adler32.c 99 | compress.c 100 | crc32.c 101 | deflate.c 102 | gzclose.c 103 | gzlib.c 104 | gzread.c 105 | gzwrite.c 106 | inflate.c 107 | infback.c 108 | inftrees.c 109 | inffast.c 110 | trees.c 111 | uncompr.c 112 | zutil.c 113 | win32/zlib1.rc 114 | ) 115 | 116 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION 117 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) 118 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*" 119 | "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) 120 | 121 | if(MINGW) 122 | # This gets us DLL resource information when compiling on MinGW. 123 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj 124 | COMMAND ${CMAKE_RC_COMPILER} 125 | -D GCC_WINDRES 126 | -I ${CMAKE_CURRENT_SOURCE_DIR} 127 | -I ${CMAKE_CURRENT_BINARY_DIR} 128 | -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj 129 | -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) 130 | set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) 131 | endif(MINGW) 132 | 133 | add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 134 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 135 | 136 | set_target_properties(zlib PROPERTIES SOVERSION 1) 137 | 138 | if(NOT CYGWIN) 139 | # This property causes shared libraries on Linux to have the full version 140 | # encoded into their final filename. We disable this on Cygwin because 141 | # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll 142 | # seems to be the default. 143 | # 144 | # This has no effect with MSVC, on that platform the version info for 145 | # the DLL comes from the resource file win32/zlib1.rc 146 | set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) 147 | endif() 148 | 149 | if(UNIX) 150 | # On unix-like platforms the library is almost always called libz 151 | set_target_properties(zlib PROPERTIES OUTPUT_NAME z) 152 | elseif(BUILD_SHARED_LIBS AND WIN32) 153 | # Creates zlib1.dll when building shared library version 154 | set_target_properties(zlib PROPERTIES SUFFIX "1.dll") 155 | set_target_properties(zlib PROPERTIES PDB_NAME "zlib1") 156 | endif() 157 | 158 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) 159 | install(TARGETS zlib 160 | RUNTIME DESTINATION bin 161 | ARCHIVE DESTINATION lib 162 | LIBRARY DESTINATION lib ) 163 | endif() 164 | if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) 165 | install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include) 166 | endif() 167 | if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) 168 | install(FILES zlib.3 DESTINATION share/man/man3) 169 | endif() 170 | -------------------------------------------------------------------------------- /cmake/zlib/zlib-1.2.6.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.4.4) 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) 3 | 4 | project(zlib C) 5 | 6 | if(NOT DEFINED BUILD_SHARED_LIBS) 7 | option(BUILD_SHARED_LIBS "Build a shared library form of zlib" ON) 8 | endif() 9 | 10 | include(CheckTypeSize) 11 | include(CheckFunctionExists) 12 | include(CheckIncludeFile) 13 | include(CheckCSourceCompiles) 14 | enable_testing() 15 | 16 | check_include_file(sys/types.h HAVE_SYS_TYPES_H) 17 | check_include_file(stdint.h HAVE_STDINT_H) 18 | check_include_file(stddef.h HAVE_STDDEF_H) 19 | 20 | # 21 | # Check to see if we have large file support 22 | # 23 | set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) 24 | # We add these other definitions here because CheckTypeSize.cmake 25 | # in CMake 2.4.x does not automatically do so and we want 26 | # compatibility with CMake 2.4.x. 27 | if(HAVE_SYS_TYPES_H) 28 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) 29 | endif() 30 | if(HAVE_STDINT_H) 31 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) 32 | endif() 33 | if(HAVE_STDDEF_H) 34 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) 35 | endif() 36 | check_type_size(off64_t OFF64_T) 37 | if(HAVE_OFF64_T) 38 | add_definitions(-D_LARGEFILE64_SOURCE=1) 39 | endif() 40 | set(CMAKE_REQUIRED_DEFINITIONS) # clear variable 41 | 42 | # 43 | # Check for fseeko 44 | # 45 | check_function_exists(fseeko HAVE_FSEEKO) 46 | if(NOT HAVE_FSEEKO) 47 | add_definitions(-DNO_FSEEKO) 48 | endif() 49 | 50 | # 51 | # Check for unistd.h 52 | # 53 | check_include_file(unistd.h Z_HAVE_UNISTD_H) 54 | 55 | if(MSVC) 56 | set(CMAKE_DEBUG_POSTFIX "d") 57 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 58 | add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) 59 | endif() 60 | 61 | if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) 62 | # If we're doing an out of source build and the user has a zconf.h 63 | # in their source tree... 64 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) 65 | message(FATAL_ERROR 66 | "You must remove ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h " 67 | "from the source tree. This file is included with zlib " 68 | "but CMake generates this file for you automatically " 69 | "in the build directory.") 70 | endif() 71 | endif() 72 | 73 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein 74 | ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) 75 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 76 | 77 | 78 | #============================================================================ 79 | # zlib 80 | #============================================================================ 81 | 82 | set(ZLIB_PUBLIC_HDRS 83 | ${CMAKE_CURRENT_BINARY_DIR}/zconf.h 84 | zlib.h 85 | ) 86 | set(ZLIB_PRIVATE_HDRS 87 | crc32.h 88 | deflate.h 89 | gzguts.h 90 | inffast.h 91 | inffixed.h 92 | inflate.h 93 | inftrees.h 94 | trees.h 95 | zutil.h 96 | ) 97 | set(ZLIB_SRCS 98 | adler32.c 99 | compress.c 100 | crc32.c 101 | deflate.c 102 | gzclose.c 103 | gzlib.c 104 | gzread.c 105 | gzwrite.c 106 | inflate.c 107 | infback.c 108 | inftrees.c 109 | inffast.c 110 | trees.c 111 | uncompr.c 112 | zutil.c 113 | ) 114 | 115 | if(NOT MINGW) 116 | set(ZLIB_SRCS ${ZLIB_SRCS} 117 | win32/zlib1.rc # If present will override custom build rule below. 118 | ) 119 | endif() 120 | 121 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION 122 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) 123 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*" 124 | "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) 125 | 126 | if(MINGW) 127 | # This gets us DLL resource information when compiling on MinGW. 128 | if(NOT CMAKE_RC_COMPILER) 129 | SET(CMAKE_RC_COMPILER windres.exe) 130 | endif() 131 | 132 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj 133 | COMMAND ${CMAKE_RC_COMPILER} 134 | -D GCC_WINDRES 135 | -I ${CMAKE_CURRENT_SOURCE_DIR} 136 | -I ${CMAKE_CURRENT_BINARY_DIR} 137 | -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj 138 | -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) 139 | set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) 140 | endif(MINGW) 141 | 142 | add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 143 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 144 | 145 | set_target_properties(zlib PROPERTIES SOVERSION 1) 146 | 147 | if(NOT CYGWIN) 148 | # This property causes shared libraries on Linux to have the full version 149 | # encoded into their final filename. We disable this on Cygwin because 150 | # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll 151 | # seems to be the default. 152 | # 153 | # This has no effect with MSVC, on that platform the version info for 154 | # the DLL comes from the resource file win32/zlib1.rc 155 | set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) 156 | endif() 157 | 158 | if(UNIX) 159 | # On unix-like platforms the library is almost always called libz 160 | set_target_properties(zlib PROPERTIES OUTPUT_NAME z) 161 | elseif(BUILD_SHARED_LIBS AND WIN32) 162 | # Creates zlib1.dll when building shared library version 163 | set_target_properties(zlib PROPERTIES SUFFIX "1.dll") 164 | set_target_properties(zlib PROPERTIES PDB_NAME "zlib1") 165 | endif() 166 | 167 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) 168 | install(TARGETS zlib 169 | RUNTIME DESTINATION bin 170 | ARCHIVE DESTINATION lib 171 | LIBRARY DESTINATION lib ) 172 | endif() 173 | if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) 174 | install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include) 175 | endif() 176 | if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) 177 | install(FILES zlib.3 DESTINATION share/man/man3) 178 | endif() -------------------------------------------------------------------------------- /compilers.yml: -------------------------------------------------------------------------------- 1 | msvc10: 2 | generator: Visual Studio 10 2010 3 | short: msvc10 4 | version: "10.0" 5 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat 6 | msvc12: 7 | generator: Visual Studio 12 2013 8 | short: msvc12 9 | version: "12.0" 10 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat 11 | msvc14: 12 | generator: Visual Studio 14 2015 13 | short: msvc14 14 | version: "14.0" 15 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat 16 | msvc17: 17 | generator: Visual Studio 15 2017 18 | short: msvc17 19 | version: "15.0" 20 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat 21 | 22 | msvc10-x64: 23 | generator: Visual Studio 10 2010 Win64 24 | short: msvc10-x64 25 | version: "10.0" 26 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat 27 | msvc12-x64: 28 | generator: Visual Studio 12 2013 Win64 29 | short: msvc12-x64 30 | version: "12.0" 31 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat 32 | msvc14-x64: 33 | generator: Visual Studio 14 2015 Win64 34 | short: msvc14-x64 35 | version: "14.0" 36 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat 37 | msvc17-x64: 38 | generator: Visual Studio 15 2017 Win64 39 | short: msvc17-x64 40 | version: "15.0" 41 | vcvarsall: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat -------------------------------------------------------------------------------- /ida_plugin.py: -------------------------------------------------------------------------------- 1 | from idc import RunPlugin, AskStr, Message, Warning 2 | from idaapi import Choose, add_hotkey 3 | import requests 4 | import os 5 | import yaml 6 | import json 7 | import re 8 | 9 | # path settings 10 | homedir = os.path.expanduser("~") 11 | bindifflibhome = os.path.join(homedir, "bindifflib") 12 | 13 | # artfactory settings 14 | artifactoryBase = "https://artifactory.example.com/artifactory/" 15 | repoName = "repo" 16 | repoPath = artifactoryBase + repoName + "/" 17 | auth = ("user", "password") 18 | 19 | # copiler settings path 20 | compiler_file = "C:\\your\\path\\to\\compilers.yml" 21 | 22 | 23 | class VersionChooser(Choose): 24 | """ Displays a choose dialog where the user has to select 25 | a version for the library he wants to download. 26 | """ 27 | def __init__(self, versions): 28 | super(VersionChooser, self).__init__(versions, "Select Version", 1) 29 | self.width = 30 30 | 31 | def enter(self, n): 32 | return 33 | 34 | 35 | class NameChooser(Choose): 36 | """ Presents the user with a dialog to select the library 37 | to be download later. 38 | """ 39 | def __init__(self, names): 40 | super(NameChooser, self).__init__(names, "Select Library", 1) 41 | self.width = 30 42 | 43 | def enter(self, n): 44 | return 45 | 46 | 47 | def queryPackets(): 48 | """ Retrieves the full list of packages from the artifactory and 49 | returns empty list on error. 50 | """ 51 | try: 52 | data = json.loads(requests.post(artifactoryBase + "api/search/aql", 53 | data='items.find({"repo":"{}"}).include("name", "path")'.format(repoName), 54 | verify=False, auth=auth).text) 55 | resultset = [] 56 | for entry in data["results"]: 57 | resultset.append(entry) 58 | return resultset 59 | except: 60 | return [] 61 | 62 | 63 | def filterPackagesByVersion(packets, version): 64 | """ Filters packets by version and emits a generator as the result. """ 65 | for p in packets: 66 | if version in p["path"]: 67 | yield p 68 | 69 | 70 | def getPacketsByName(packets, name): 71 | """ Return a list of packages that match the given name. """ 72 | resultset = [] 73 | for p in packets: 74 | if name in p["path"]: 75 | resultset.append(p) 76 | return resultset 77 | 78 | 79 | def getPacketNames(packets): 80 | """ Return a unified list of names of the libraries from the 81 | list of packages sent by the artifactory server. 82 | """ 83 | resultset = [] 84 | for p in packets: 85 | name = p["path"].split("/")[1] 86 | if name not in resultset: 87 | resultset.append(name) 88 | resultset.sort() 89 | return resultset 90 | 91 | 92 | def getPacketVersions(packets): 93 | """ Return a unified list of version for the given list of packages. """ 94 | resultset = [] 95 | for packet in packets: 96 | v = packet["path"].split("/")[2] 97 | if v not in resultset: 98 | resultset.append(v) 99 | resultset.sort() 100 | return resultset 101 | 102 | 103 | def main(): 104 | # get all packages from server and extracts the names 105 | packets = queryPackets() 106 | names = getPacketNames(packets) 107 | 108 | # ask for the library to download 109 | chooser = NameChooser(names) 110 | choice = chooser.choose() 111 | if not choice: 112 | Warning("You need to select a library") 113 | return 114 | 115 | name = names[choice - 1] 116 | 117 | # filter out all packets that don't match the name 118 | filtered_packets = getPacketsByName(packets, name) 119 | if not filtered_packets: 120 | return 121 | 122 | # get list of available versions and ask the user 123 | # which one to use 124 | versions = getPacketVersions(filtered_packets) 125 | chooser = VersionChooser(versions) 126 | selection = chooser.choose() 127 | if not selection: 128 | Warning("You need to select a version") 129 | return 130 | 131 | version = versions[selection - 1] 132 | 133 | # construct the local path of the library 134 | libpath = os.path.join(bindifflibhome, name, version) 135 | try: 136 | os.makedirs(libpath) 137 | except: 138 | # folder already exists 139 | pass 140 | 141 | # parse list of compilers 142 | compilers = yaml.load(open(compiler_file, "rb").read()) 143 | 144 | # iterate through list of packages (filtered by version) 145 | for p in filterPackagesByVersion(filtered_packets, versions[selection - 1]): 146 | # we only need i64/idb files 147 | if os.path.splitext(p["name"])[1] in [".i64", ".idb"]: 148 | # construct remote path 149 | remote_file = p["path"] + "/" + p["name"] 150 | 151 | # we need to download a library for all given compilers 152 | for _, c in compilers.items(): 153 | if c["short"] not in p["path"]: 154 | # skip if there's no remote library for the compiler 155 | continue 156 | 157 | # construct local paths 158 | path, ext = os.path.splitext(p["name"]) 159 | local_filename = "{}_{}{}".format(path, c["short"], ext) 160 | local_path = os.path.join(libpath, local_filename) 161 | 162 | # skip if library was already downloaded 163 | if (os.path.exists(local_path) and 164 | os.path.getsize(local_path) is not 0): 165 | print("{} already present".format(local_filename)) 166 | continue 167 | 168 | # initiate download from artifactory 169 | print("Downloading {}...".format(local_filename)) 170 | resp = requests.get( 171 | repoPath + "/" + p["path"] + "/" + p["name"], 172 | stream=True, verify=False) 173 | 174 | # handle the response 175 | try: 176 | if resp.status_code is not 200: 177 | Warning("Server did not respond with status 200. Message:\n" + data) 178 | else: 179 | with open(local_path, "wb") as f: 180 | f.write(resp.raw.read()) 181 | except: 182 | Warning("Error!") 183 | 184 | Message("Done. Files saved to folder {}".format(libpath)) 185 | 186 | if __name__ == "__main__": 187 | # we try to setup a hotkey to make re-running the script easier 188 | if add_hotkey("Ctrl-Shift-B", main) is None: 189 | Message("Failed to set hotkey, please re-run this script to download other IDBs") 190 | else: 191 | Message("Hotkey registered, press Ctrl-Shift-B to download another library") 192 | 193 | main() 194 | -------------------------------------------------------------------------------- /libs.yml: -------------------------------------------------------------------------------- 1 | libs: 2 | # openssl110: 3 | # name: openssl 4 | # urls: 5 | # - https://www.openssl.org/source/old/1.1.0/openssl-1.1.0.tar.gz 6 | # - https://www.openssl.org/source/old/1.1.0/openssl-1.1.0a.tar.gz 7 | # - https://www.openssl.org/source/old/1.1.0/openssl-1.1.0b.tar.gz 8 | # - https://www.openssl.org/source/old/1.1.0/openssl-1.1.0c.tar.gz 9 | # - https://www.openssl.org/source/old/1.1.0/openssl-1.1.0d.tar.gz 10 | # filetype: tar.gz 11 | # extracts_to_subfolder: true 12 | # custombuild: 13 | # - call "{vcvarsall}" x86 14 | # - cd "{buildpath}" 15 | # - perl "{extractedpath}/Configure" "--prefix={binpath}" "--openssldir={binpath}" VC-WIN32 16 | # - nmake 17 | # - nmake install 18 | # 64bit: false 19 | 20 | # openssl102: 21 | # name: openssl 22 | # urls: 23 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2.tar.gz 24 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2a.tar.gz 25 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2b.tar.gz 26 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2c.tar.gz 27 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2d.tar.gz 28 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2e.tar.gz 29 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2f.tar.gz 30 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz 31 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2h.tar.gz 32 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2i.tar.gz 33 | # - https://www.openssl.org/source/old/1.0.2/openssl-1.0.2j.tar.gz 34 | # filetype: tar.gz 35 | # extracts_to_subfolder: true 36 | # custombuild: 37 | # - call "{vcvarsall}" x86 38 | # - xcopy "{extractedpath}" "{buildpath}" /E /Y 39 | # - cd "{buildpath}" 40 | # - perl Configure "--prefix={binpath}" "--openssldir={binpath}" debug-VC-WIN32 "-WX-" 41 | # - call ms\do_nasm 42 | # - nmake -f ms\ntdll.mak 43 | # - nmake -f ms\ntdll.mak install 44 | # - xcopy "{buildpath}\out32dll.dbg\ssleay32.pdb" "{binpath}\bin\" /E /Y 45 | # - xcopy "{buildpath}\out32dll.dbg\openssl.pdb" "{binpath}\bin\" /E /Y 46 | # - xcopy "{buildpath}\out32dll.dbg\libeay32.pdb" "{binpath}\bin\" /E /Y 47 | # 64bit: false 48 | 49 | # openssl101: 50 | # name: openssl 51 | # urls: 52 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1.tar.gz 53 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1a.tar.gz 54 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1b.tar.gz 55 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1c.tar.gz 56 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1d.tar.gz 57 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1e.tar.gz 58 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1f.tar.gz 59 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1g.tar.gz 60 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1h.tar.gz 61 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1i.tar.gz 62 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1j.tar.gz 63 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1k.tar.gz 64 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1l.tar.gz 65 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1m.tar.gz 66 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1n.tar.gz 67 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1o.tar.gz 68 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1p.tar.gz 69 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1q.tar.gz 70 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1r.tar.gz 71 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1s.tar.gz 72 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1t.tar.gz 73 | # - https://www.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz 74 | # filetype: tar.gz 75 | # extracts_to_subfolder: true 76 | # custombuild: 77 | # - call "{vcvarsall}" x86 78 | # - xcopy "{extractedpath}" "{buildpath}" /E /Y 79 | # - cd "{buildpath}" 80 | # - perl Configure "--prefix={binpath}" "--openssldir={binpath}" debug-VC-WIN32 "-WX-" "-D_CRT_SECURE_NO_WARNINGS" 81 | # - perl -i.bak -p -e "s/return\(cflags\);/return(CFLAGS);/g" crypto\cversion.c 82 | # - call ms\do_nasm 83 | # - nmake -f ms\ntdll.mak 84 | # - nmake -f ms\ntdll.mak install 85 | # - xcopy "{buildpath}\out32dll.dbg\ssleay32.pdb" "{binpath}\bin\" /E /Y 86 | # - xcopy "{buildpath}\out32dll.dbg\openssl.pdb" "{binpath}\bin\" /E /Y 87 | # - xcopy "{buildpath}\out32dll.dbg\libeay32.pdb" "{binpath}\bin\" /E /Y 88 | # 64bit: false 89 | 90 | # openssl100: 91 | # name: openssl 92 | # urls: 93 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0.tar.gz 94 | # # openssl 1.0.0a cannot be built in the openssl100 chain, it has a bug in its build env 95 | # # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0a.tar.gz 96 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0b.tar.gz 97 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0c.tar.gz 98 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0d.tar.gz 99 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0e.tar.gz 100 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0f.tar.gz 101 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0g.tar.gz 102 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0h.tar.gz 103 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0i.tar.gz 104 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0j.tar.gz 105 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0k.tar.gz 106 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0l.tar.gz 107 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0m.tar.gz 108 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0n.tar.gz 109 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0o.tar.gz 110 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0p.tar.gz 111 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0q.tar.gz 112 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0r.tar.gz 113 | # - https://www.openssl.org/source/old/1.0.0/openssl-1.0.0s.tar.gz 114 | # filetype: tar.gz 115 | # extracts_to_subfolder: true 116 | # custombuild: 117 | # - call "{vcvarsall}" x86 118 | # - xcopy "{extractedpath}" "{buildpath}" /E /Y 119 | # - cd "{buildpath}" 120 | # - perl Configure no-asm "--prefix={binpath}" "--openssldir={binpath}" debug-VC-WIN32 121 | # - call ms\do_ms.bat 122 | # - perl -i.bak -p -e "s/\-WX //g;" ms\ntdll.mak 123 | # - perl -i.bak -p -e "s/return\(cflags\);/return(CFLAGS);/g" crypto\cversion.c 124 | # - nmake -f ms\ntdll.mak 125 | # - nmake -f ms\ntdll.mak install 126 | # - xcopy "{buildpath}\out32dll.dbg\ssleay32.pdb" "{binpath}\bin\" /E /Y 127 | # - xcopy "{buildpath}\out32dll.dbg\openssl.pdb" "{binpath}\bin\" /E /Y 128 | # - xcopy "{buildpath}\out32dll.dbg\libeay32.pdb" "{binpath}\bin\" /E /Y 129 | # 64bit: false 130 | 131 | # openssl098: 132 | # name: openssl 133 | # urls: 134 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8.tar.gz 135 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8a.tar.gz 136 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8b.tar.gz 137 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8c.tar.gz 138 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8d.tar.gz 139 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8e.tar.gz 140 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8f.tar.gz 141 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8g.tar.gz 142 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8h.tar.gz 143 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8i.tar.gz 144 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8j.tar.gz 145 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8k.tar.gz 146 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8l.tar.gz 147 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8m.tar.gz 148 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8n.tar.gz 149 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8o.tar.gz 150 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8p.tar.gz 151 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8q.tar.gz 152 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8r.tar.gz 153 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8s.tar.gz 154 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8t.tar.gz 155 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8u.tar.gz 156 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8v.tar.gz 157 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8w.tar.gz 158 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8x.tar.gz 159 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8y.tar.gz 160 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8za.tar.gz 161 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8zb.tar.gz 162 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8zc.tar.gz 163 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8zd.tar.gz 164 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8ze.tar.gz 165 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8zf.tar.gz 166 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8zg.tar.gz 167 | # - https://www.openssl.org/source/old/0.9.x/openssl-0.9.8zh.tar.gz 168 | # filetype: tar.gz 169 | # extracts_to_subfolder: true 170 | # custombuild: 171 | # - call "{vcvarsall}" x86 172 | # - xcopy "{extractedpath}" "{buildpath}" /E /Y 173 | # - cd "{buildpath}" 174 | # - perl Configure no-asm "--prefix={binpath}" "--openssldir={binpath}" VC-WIN32 175 | # - call ms\do_ms.bat 176 | # - perl -i.bak -p -e "s/\-WX //g;" ms\ntdll.mak 177 | # - perl -i.bak -p -e "s/\/WX //g;" ms\ntdll.mak 178 | # - perl -i.bak -p -e "s/LFLAGS=(.*)$/LFLAGS=$1 \/debug/g;" ms\ntdll.mak 179 | # - nmake -f ms\ntdll.mak 180 | # - xcopy "{buildpath}\out32dll\ssleay32.*" "{binpath}\bin\" /E /Y 181 | # - xcopy "{buildpath}\out32dll\openssl.*" "{binpath}\bin\" /E /Y 182 | # - xcopy "{buildpath}\out32dll\libeay32.*" "{binpath}\bin\" /E /Y 183 | # 64bit: false 184 | # libpng: 185 | # url: ftp://ftp.simplesystems.org/pub/png/src/history/libpng16/libpng-{version}.tar.gz 186 | # versions: 187 | # - "1.6.24" 188 | # - "1.6.25" 189 | # - "1.6.26" 190 | # - "1.6.27" 191 | # - "1.6.28" 192 | # filetype: tar.gz 193 | # extracts_to_subfolder: true 194 | # dependencies: 195 | # all: 196 | # zlib: "1.2.11" 197 | 198 | # zlib12: 199 | # name: zlib 200 | # url: http://zlib.net/fossils/zlib-{version}.tar.gz 201 | # versions: 202 | # - "1.2.7" 203 | # - "1.2.8" 204 | # - "1.2.9" 205 | # - "1.2.10" 206 | # - "1.2.11" 207 | # filetype: tar.gz 208 | # extracts_to_subfolder: true 209 | 210 | # pcre2: 211 | # url: https://ftp.pcre.org/pub/pcre/pcre2-{version}.tar.gz 212 | # versions: 213 | # - "10.00" 214 | # - "10.10" 215 | # - "10.20" 216 | # - "10.21" 217 | # - "10.22" 218 | # - "10.23" 219 | # filetype: tar.gz 220 | # cmakeflags: 221 | # - PCRE2_BUILD_TESTS=OFF 222 | # - BUILD_SHARED_LIBS=ON 223 | # extracts_to_subfolder: true 224 | # dependencies: 225 | # all: 226 | # bzip2: "1.0.6" 227 | # zlib: "1.2.11" 228 | # customcmake: 229 | # "10.22": pcre2/pcre2-10.22.cmake 230 | 231 | # pcre: 232 | # url: https://ftp.pcre.org/pub/pcre/pcre-{version}.tar.gz 233 | # versions: 234 | # - "8.36" 235 | # - "8.37" 236 | # - "8.38" 237 | # - "8.39" 238 | # - "8.40" 239 | # filetype: tar.gz 240 | # cmakeflags: 241 | # - PCRE_BUILD_TESTS=OFF 242 | # - BUILD_SHARED_LIBS=ON 243 | # extracts_to_subfolder: true 244 | # dependencies: 245 | # all: 246 | # bzip2: "1.0.6" 247 | # zlib: "1.2.11" 248 | # customcmake: 249 | # "8.40": pcre/pcre-8.40.cmake 250 | 251 | # bzip2: 252 | # url: http://www.bzip.org/{version}/bzip2-{version}.tar.gz 253 | # versions: 254 | # - "1.0.2" 255 | # - "1.0.3" 256 | # - "1.0.4" 257 | # - "1.0.5" 258 | # - "1.0.6" 259 | # filetype: tar.gz 260 | # extracts_to_subfolder: true 261 | # customcmake: 262 | # all: bzip2/all.cmake 263 | # tinyxml2: 264 | # url: https://github.com/leethomason/tinyxml2/archive/{version}.tar.gz 265 | # versions: 266 | # - "4.0.1" 267 | # - "4.0.0" 268 | # - "3.0.0" 269 | # - "2.2.0" 270 | # - "2.1.0" 271 | # - "2.0.2" 272 | # - "2.0.1" 273 | # filetype: tar.gz 274 | # cmakeflags: 275 | # - BUILD_SHARED_LIBS=ON 276 | # extracts_to_subfolder: true 277 | 278 | # tinyxml: 279 | # urls: 280 | # - http://downloads.sourceforge.net/project/tinyxml/tinyxml/2.6.2/tinyxml_2_6_2.tar.gz 281 | # - http://downloads.sourceforge.net/project/tinyxml/tinyxml/2.6.1/tinyxml_2_6_1.tar.gz 282 | # - http://downloads.sourceforge.net/project/tinyxml/tinyxml/2.6.0/tinyxml_2_6_0.tar.gz 283 | # - http://downloads.sourceforge.net/project/tinyxml/tinyxml/2.5.3/tinyxml_2_5_3.tar.gz 284 | # - http://downloads.sourceforge.net/project/tinyxml/tinyxml/2.5.2/tinyxml_2_5_2.tar.gz 285 | # - http://downloads.sourceforge.net/project/tinyxml/tinyxml/2.5.1/tinyxml_2_5_1.tar.gz 286 | # filetype: tar.gz 287 | # extracts_to_subfolder: true 288 | # subfolder_needs_rename: true 289 | # customcmake: 290 | # all: tinyxml/all.cmake 291 | 292 | # xz: 293 | # url: https://downloads.sourceforge.net/project/lzmautils/xz-{version}.tar.gz 294 | # versions: 295 | # - "5.2.3" 296 | # - "5.2.2" 297 | # - "5.2.1" 298 | # - "5.2.0" 299 | # filetype: tar.gz 300 | # extracts_to_subfolder: true 301 | # customcmake: 302 | # all: xz/all.cmake 303 | -------------------------------------------------------------------------------- /modules/__init__.py: -------------------------------------------------------------------------------- 1 | # package marker 2 | -------------------------------------------------------------------------------- /modules/buildwrapper.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | import shutil 4 | from glob import glob 5 | from tempfile import mkstemp 6 | from .dependency import Internal 7 | 8 | 9 | class BuildWrapper(object): 10 | """ 11 | Encapsulates the build process to provide an easy-to-use 12 | interface for the whole compilation. 13 | """ 14 | 15 | def __init__(self, internals=[], isDependencyWrapper=False, 16 | dependencyList=None, libs=None): 17 | super(BuildWrapper, self).__init__() 18 | self._internals = internals 19 | self._libs_orig = libs 20 | self._isDependencyWrapper = isDependencyWrapper 21 | 22 | if isDependencyWrapper: 23 | tmp = [] 24 | for name, version in dependencyList.items(): 25 | tmp.append( 26 | Internal(lib=libs[name][version], 27 | name=name, version=version)) 28 | self._internals = tmp 29 | 30 | def __enter__(self): 31 | return self 32 | 33 | def __exit__(self, exc_type, exc_val, exc_tb): 34 | pass 35 | 36 | @property 37 | def binPaths(self): 38 | return self._binPaths 39 | 40 | def compileFor(self, compiler, cmake): 41 | self._binPaths = [] 42 | 43 | libs = dict(self._libs_orig) 44 | for item in self._internals: 45 | Task(item, compiler, libs).compile( 46 | cmake=cmake, isDep=self._isDependencyWrapper) 47 | self._binPaths.append(item.lib["binpath"]) 48 | 49 | 50 | class Task(object): 51 | """ Encapsulates the compile process of a single library. """ 52 | 53 | def __init__(self, meta, compiler, libs): 54 | """ 55 | Initializes a compile task. 56 | 57 | :param meta: all meta information of the library, as provided in libs.yml 58 | :param compiler: information about the compiler, as provided in compilers.yml 59 | :param libs: the global dictionary of libraries for the given compiler, 60 | used to determine which library has already been built to skip possible 61 | dependency compilation. 62 | """ 63 | super(Task, self).__init__() 64 | self._meta = meta 65 | self._basepath = os.getcwd() + "/" 66 | self._compiler = compiler 67 | self._libs = libs 68 | 69 | @property 70 | def name(self): 71 | """ Returns the name of the library.""" 72 | return self._meta.name 73 | 74 | @property 75 | def version(self): 76 | """ Returns the version of the library.""" 77 | return self._meta.version 78 | 79 | @property 80 | def compiler(self): 81 | """ Returns the current compiler.""" 82 | return self._compiler 83 | 84 | @property 85 | def lib(self): 86 | """ Returns the metadata of the library.""" 87 | return self._meta.lib 88 | 89 | def _updateLibList(self, buildpath, binpath): 90 | """ Updates the realtive paths in the global library list to 91 | absolute paths so that we are immune against wrong 92 | working directories. 93 | 94 | :param buildpath: path to the directory where the build 95 | process will happen 96 | :param binpath: path to the directory where the binaries 97 | will be stored 98 | """ 99 | self._libs[self.name][self.version]["buildpath"] = buildpath 100 | self._libs[self.name][self.version]["binpath"] = binpath 101 | 102 | def _setSuccessfulBuild(self, success): 103 | """ Set the build status of the current library.""" 104 | self._libs[self.name][self.version]["built"] = success 105 | 106 | def _checkBuildFolderPopulated(self): 107 | """ Checks whether there are already some DLLs present in the 108 | binpath. This allows for skipping the build process if it 109 | already happened before the current instance of the script 110 | was run. 111 | """ 112 | binpath = self._libs[self.name][self.version]["binpath"] 113 | if os.path.exists(binpath): 114 | dlls = glob(binpath + "/bin/*.dll") 115 | if dlls is not None: 116 | return True 117 | else: 118 | return False 119 | 120 | def _formatCommand(self, cmd, binpath, extractedpath, buildpath): 121 | """ Formats a given command so that we can apply 122 | dynamic paths and variables at compile time. 123 | Allowed format specifiers: 124 | - vcvarsall: absolute path of the vcvarsall.bat file 125 | of the current compiler 126 | - compiler: the short name of the current compiler 127 | - name: the name of the current library 128 | - version: the current version of the library 129 | - binpath: the full path to the directory where the 130 | built binaries will be stored 131 | - extractedpath: the full path to the source files 132 | - buldpath: the full path to the build directory 133 | 134 | :param cmd: the command that is to be formatted 135 | :param binpath: the full path to the doirectory where the binaries 136 | will be stored 137 | :param extractedpath: the full path to the source files 138 | :param buildpath: the full path to the build directory 139 | """ 140 | return cmd.format( 141 | vcvarsall=self.compiler["vcvarsall"], 142 | compiler=self.compiler["short"], 143 | compiler_version=self.compiler["version"], 144 | name=self.name, 145 | version=self.version, 146 | binpath=binpath, 147 | extractedpath=extractedpath, 148 | buildpath=buildpath 149 | ) 150 | 151 | def compile(self, cmake="", isDep=False): 152 | """ Launches the actual compilation. Depending on if a custom 153 | build script was put into the libs.yml file it either executes 154 | those steps in a batch file or launches CMake. 155 | Also, if the current library has dependencies, this will be taken 156 | into consideration and the dependencies will be built first. The 157 | dependency resolution is transitive - if a dependency has another 158 | dependency, it we be built first 159 | 160 | :param cmake: the absolute path to the CMake executable. Works around 161 | a possible crash if the CMake executable is not in %PATH%. 162 | :param isDep: (optional) denotes of the current library is a dependency 163 | build of another library. Only used for console output. 164 | Default: False 165 | """ 166 | 167 | # construct abolsute paths for all needed directories 168 | buildpath = (self._basepath + self.lib["buildpath"] + 169 | "_" + self.compiler["short"]) 170 | extractedpath = self._basepath + self.lib["extractedpath"] 171 | binpath = (self._basepath + self.lib["binpath"] + 172 | "_" + self.compiler["short"]) 173 | 174 | # skip if it was marked as already built 175 | if self._libs[self.name][self.version]["built"]: 176 | return 177 | 178 | # skip if we have a 64bit compiler and 64bit builds are not allowed 179 | if self.lib["64bit"] is False and "x64" in self.compiler["short"]: 180 | return 181 | 182 | # apply absolute paths to the global list 183 | self._updateLibList(buildpath, binpath) 184 | 185 | # check, whether the library was built outside or before the execution 186 | # of this instance of the script; if so: skip 187 | if self._checkBuildFolderPopulated() is True: 188 | print("{}-{}_{} already built.".format( 189 | self.name, self.version, self.compiler["short"])) 190 | self._setSuccessfulBuild(success=True) 191 | return 192 | 193 | # check for possible dependencies, they need to be built first 194 | dependencyBinPaths = [] 195 | if self.lib["dependencies"] is not None: 196 | # build all dependencies 197 | with BuildWrapper( 198 | dependencyList=self.lib["dependencies"], 199 | isDependencyWrapper=True, libs=self._libs) as wrapper: 200 | wrapper.compileFor(self.compiler, cmake) 201 | # apply the binary paths of all dependencies so that 202 | # we can set proper include and lib directories 203 | dependencyBinPaths = wrapper.binPaths 204 | 205 | print("Compiling {}{}-{}_{}".format( 206 | "dependency " if isDep else "", self.name, 207 | self.version, self.compiler["short"])) 208 | 209 | # make sure all directories exist 210 | if not os.path.exists(buildpath): 211 | os.mkdir(buildpath) 212 | if not os.path.exists(binpath): 213 | os.mkdir(binpath) 214 | 215 | # create a temporary batch file 216 | _, name = mkstemp(suffix=".bat") 217 | os.close(_) 218 | # open it writable 219 | with open(name, "w") as f: 220 | # check if we have a custom build script in the libs.yml 221 | if self.lib["custombuild"]: 222 | # write all commands to the batch file 223 | for cmd in self.lib["custombuild"]: 224 | f.write(self._formatCommand( 225 | cmd, binpath, extractedpath, buildpath 226 | ) + "\n") 227 | elif "cmakeflags" in self.lib or "customcmake" in self.lib: 228 | # copy over a custom CMake file id there is one present 229 | if self.lib["customcmake"]: 230 | shutil.copyfile(self.lib["customcmake"], 231 | extractedpath + "/CMakeLists.txt") 232 | 233 | # construct the call to CMake; also applies the install prefix 234 | # and specifies the output directory for the PDB file 235 | args = [cmake, 236 | "-G", self.compiler["generator"], 237 | "-DCMAKE_INSTALL_PREFIX={}".format(binpath), 238 | "-DCMAKE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO={}/bin".format( 239 | binpath), 240 | ] 241 | 242 | # append custom CMake flags if provided 243 | if "cmakeflags" in self.lib and self.lib["cmakeflags"] is not None: 244 | for flag in self.lib["cmakeflags"]: 245 | args.append("-D{}".format(flag)) 246 | 247 | # if there are dependencies, we need to hint cmake some paths 248 | # so that the include and lib folder can be found by the 249 | # Find*.cmake files 250 | if dependencyBinPaths: 251 | args.append("-DCMAKE_PREFIX_PATH={}".format( 252 | ';'.join(dependencyBinPaths))) 253 | 254 | # append the source path 255 | args.append(extractedpath) 256 | 257 | # create cmake configuration command 258 | cmake_compile = " ".join( 259 | map(lambda x: "\"" + x + "\"", args) 260 | ) + "\n" 261 | 262 | # create cmake install command 263 | cmake_install = ("\"{}\" --build . --target install " + 264 | "--config RelWithDebInfo\n").format(cmake) 265 | 266 | # write commands to file 267 | f.write(cmake_compile) 268 | f.write(cmake_install) 269 | 270 | # call the batch file so that the compilation can start 271 | subprocess.run(name, cwd=buildpath, stdout=subprocess.DEVNULL) 272 | # remove the temporary batch file 273 | os.unlink(name) 274 | 275 | # if we reached this point, compilation was successful 276 | # so, set the build status to True 277 | self._setSuccessfulBuild(success=True) 278 | -------------------------------------------------------------------------------- /modules/dependency.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Internal(object): 4 | """ Helper class to provide an interface to the underlying 5 | dictionary of meta data.""" 6 | def __init__(self, lib, name, version, dependencies=None): 7 | """ Initializes the class. 8 | 9 | :param lib: the metadata of the library as provided 10 | is libs.yml 11 | :param name: the name of the library 12 | :param version: the current version of the library 13 | :param dependencies: (optional) list of dependecies 14 | """ 15 | self._lib = lib 16 | self._name = name 17 | self._version = version 18 | if not dependencies: 19 | self._dependencies = lib["dependencies"] 20 | else: 21 | self._dependencies = dependencies 22 | 23 | @property 24 | def dependencies(self): 25 | return self._dependencies 26 | 27 | @property 28 | def name(self): 29 | return self._name 30 | 31 | @property 32 | def lib(self): 33 | return self._lib 34 | 35 | @property 36 | def version(self): 37 | return self._version 38 | 39 | def __str__(self): 40 | return "{}-{}".format(self._name, self._version) 41 | 42 | def __repr__(self): 43 | return "".format( 44 | self._name, self._version, self._dependencies) 45 | 46 | 47 | class DependencyHelper(object): 48 | """ Helper class for dependecy "resolution". It ensures that the dependencies 49 | of the library are set in the metadata. 50 | """ 51 | def __init__(self, libs): 52 | """ Initializes an instancen of DependecyHelper. 53 | 54 | :param libs: global list of libraries 55 | """ 56 | self._libs = libs 57 | 58 | def resolve(self): 59 | """ Performs the dependncy resolution and returns a list with the results.""" 60 | ret = [] 61 | 62 | # iterate over all libraries 63 | for name in self._libs: 64 | # consider all version separately 65 | for version, lib in self._libs[name].items(): 66 | libdeps = lib["dependencies"] 67 | dependencies = [] 68 | 69 | # apply dependencies if there are some 70 | if libdeps is not None: 71 | for depname, depversion in libdeps.items(): 72 | dependencies.append( 73 | Internal(lib=self._libs[depname][depversion], 74 | name=depname, version=depversion)) 75 | # append the current library to the resultset 76 | ret.append(Internal(lib=lib, name=name, version=version, 77 | dependencies=dependencies)) 78 | 79 | return ret 80 | -------------------------------------------------------------------------------- /modules/downloader.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from ftplib import FTP 3 | from tempfile import TemporaryFile 4 | 5 | 6 | class Downloader(object): 7 | """ Downloader class that provides an interface for downloading 8 | from different sources. 9 | """ 10 | 11 | def __init__(self, url): 12 | """ Initializes an instance of this class. 13 | 14 | :param url: the url of the file to download 15 | """ 16 | self._url = url 17 | 18 | def getData(self): 19 | """ Parses the protocol which is required to download the file 20 | and returns a binary blob with the contents of the file.""" 21 | if self._url.startswith("http"): 22 | return self._httpGet() 23 | elif self._url.startswith("ftp"): 24 | return self._ftpGet() 25 | else: 26 | print("Unsupported url format: {}".format( 27 | self._url.split("://")[0])) 28 | return None 29 | 30 | def _httpGet(self): 31 | """ Performs a HTTP GET request to get the file. """ 32 | response = requests.get(self._url, stream=True) 33 | if response.status_code is not 200: 34 | return None 35 | else: 36 | return response.raw.read(decode_content=True) 37 | 38 | def _ftpGet(self): 39 | """ Applies FTP commands to get the file. """ 40 | _, path = self._url.split("://") 41 | _split = path.split("/") 42 | 43 | host = _split[0] 44 | path = "/".join(_split[1:-1]) 45 | file = _split[-1] 46 | 47 | try: 48 | ftp = FTP(host, timeout=60) 49 | ftp.login() 50 | ftp.cwd(path) 51 | 52 | tmpfile = TemporaryFile() 53 | ftp.retrbinary("RETR " + file, tmpfile.write) 54 | 55 | tmpfile.seek(0) 56 | data = tmpfile.read() 57 | tmpfile.close() 58 | 59 | return data 60 | 61 | except TimeoutError: 62 | print("Timeout while fetching {}".format(self._url)) 63 | return None 64 | -------------------------------------------------------------------------------- /modules/extractors.py: -------------------------------------------------------------------------------- 1 | import tarfile 2 | from zipfile import ZipFile 3 | import os 4 | 5 | 6 | class Extractor(object): 7 | """ Base class for all extractors. """ 8 | 9 | def __init__(self, fileobj, extractedPrefix): 10 | """ Initializes an instance of the class. 11 | 12 | :param fileobj: an open file handle to the file that 13 | needs to be extracted 14 | :param extractedPrefix: an absolute path prefix to the 15 | directory where the files should be extracted to. 16 | """ 17 | self._extractedPrefix = extractedPrefix 18 | self._fileobj = fileobj 19 | 20 | def extract(self): 21 | pass 22 | 23 | 24 | class TarGzExtractor(Extractor): 25 | """ Extracts a tar.gz file utilizing pythons tarfile module. """ 26 | 27 | def __init__(self, fileobj, extractedPrefix=""): 28 | """ Forwards all parameters to :class:`Extractor`.""" 29 | super(TarGzExtractor, self).__init__(fileobj, extractedPrefix) 30 | 31 | def extract(self): 32 | """ Extracts a tar.gz file. """ 33 | extractedName = "" 34 | if self._fileobj is not None: 35 | instance = tarfile.open(fileobj=self._fileobj) 36 | if instance: 37 | extractedName = instance.getmembers()[0].name 38 | if not os.path.exists( 39 | self._extractedPrefix + "\\" + extractedName): 40 | instance.extractall(self._extractedPrefix) 41 | instance.close() 42 | return extractedName 43 | 44 | 45 | class ZipExtractor(Extractor): 46 | """ Extracts a zip file utilizing pythons zipfile module. """ 47 | 48 | def __init__(self, fileobj, extractedPrefix=""): 49 | """ Forwards all parameters to :class:`Extractor`.""" 50 | super(ZipExtractor, self).__init__(fileobj, extractedPrefix) 51 | 52 | def extract(self): 53 | """ Extracts a zip file. """ 54 | extractedName = "" 55 | if self._fileobj is not None: 56 | instance = ZipFile(self._fileobj.name) 57 | if instance: 58 | instance.extractall(path=self._extractedPrefix) 59 | extractedName = instance.namelist()[0].filename 60 | instance.close() 61 | return extractedName 62 | 63 | 64 | class PlainExtractor(Extractor): 65 | """ Dummy PlainExtractor. Does nothing. """ 66 | def __init__(self, fileobj, extractedPrefix=""): 67 | super(PlainExtractor, self).__init__(fileobj, extractedPrefix) 68 | 69 | """ Declare the list of extractors so that it can be easily imported 70 | into other modules.""" 71 | EXTRACTORS = { 72 | "tar.gz": TarGzExtractor, 73 | "zip": ZipExtractor, 74 | "plain": PlainExtractor, 75 | } 76 | -------------------------------------------------------------------------------- /modules/handler.py: -------------------------------------------------------------------------------- 1 | from .downloader import Downloader 2 | from .extractors import EXTRACTORS 3 | import yaml 4 | import os 5 | import shutil 6 | import re 7 | 8 | 9 | class LibHandler(object): 10 | """ Handles a library from libs.yml. """ 11 | def __init__(self, cachePrefix="", extractedPrefix="", 12 | buildPrefix="", binPrefix="", customCmakePrefix=""): 13 | """ Initializes an instance of the class. 14 | 15 | :param cachePrefix: full path prefix to the cache directory 16 | :param extractedPrefix: full path prefix to the directory 17 | where all library source packages get unpacked into 18 | :param buildPrefix: full path prefix to the build directory 19 | :param binPrefix: full path prefix to the directory where the 20 | binaries will be stored 21 | :param customCmakePrefix: prefix of the directory where the 22 | custom cmake files are stored 23 | """ 24 | self._libs = {} 25 | self._cachePrefix = cachePrefix 26 | self._extractedPrefix = extractedPrefix 27 | self._buildPrefix = buildPrefix 28 | self._binPrefix = binPrefix 29 | self._customCmakePrefix = customCmakePrefix 30 | 31 | def getLibs(self): 32 | """ Returns the global list of libraries. """ 33 | return self._libs 34 | 35 | def addLibrary(self, name, args): 36 | """ Adds a new library the global list of libraries. 37 | 38 | :param name: name of the library 39 | :param args: dictionary of meta data of the library, as 40 | provided in libs.yml 41 | """ 42 | versions = args.get("versions", []) 43 | url = args.get("url", "") 44 | urls = args.get("urls", []) 45 | filetype = args.get("filetype", "") 46 | 47 | # add to internal cache if not yet present at all 48 | if name not in self._libs: 49 | self._libs[name] = {} 50 | 51 | file = None 52 | 53 | # if we have a list of URLs just download and use those; we do not 54 | # need to take care of URL formatting then. 55 | # otherwise, format the URL for every version in the metadata and 56 | # download all files that way 57 | if urls: 58 | regex = re.compile("\/{name}[-_\.](.*)\.{filetype}$".format( 59 | name=name, filetype=filetype)) 60 | regex_github = re.compile( 61 | "\/{name}\/archive\/(.*)\.{filetype}$".format( 62 | name=name, filetype=filetype)) 63 | for _url in urls: 64 | # try to find the name and version of the library from the URL 65 | m = regex.search(_url) 66 | if m: 67 | # download file 68 | fileobj = self._downloadLib(_url) 69 | # get version from regex 70 | version = m.group(1) 71 | 72 | # if the download was successful, store it in the local cache 73 | if fileobj is not None: 74 | self._addToCache(fileobj=fileobj, version=version, 75 | name=name, args=args) 76 | else: 77 | if "github" in _url.lower(): 78 | m = regex_github.search(_url) 79 | if m: 80 | fileobj = self._downloadLib(_url) 81 | version = m.group(1) 82 | if fileobj is not None: 83 | self._addToCache(fileobj=fileobj, version=version, 84 | name=name, args=args) 85 | else: 86 | print("Could not detect version for url {}".format(_url)) 87 | else: 88 | for version in versions: 89 | if version in self._libs[name]: 90 | # skip if already in cache 91 | print("""{}-{} already present in internal cache. 92 | Skipping.""".format(name, version)) 93 | continue 94 | 95 | # download lib 96 | file = self._downloadLib(url.format(version=version)) 97 | 98 | # if download was successful, store the library in the local cache 99 | if file is not None: 100 | self._addToCache(fileobj=file, version=version, 101 | name=name, args=args) 102 | 103 | def _addToCache(self, fileobj, version, name, args): 104 | """ Adds a given library to the local cache. Also ensures, that 105 | archives get unpacked and performs some pre-compilation steps that 106 | fit better in here than somewhere else. 107 | 108 | :param fileobj: an open file object of the downloaded source archive 109 | :param version: the current version of the library 110 | :param name: the name of the library 111 | :param args: a dictionary of the metadata provided in libs.yml 112 | """ 113 | 114 | # get information from metadata 115 | url = args.get("url", "") 116 | urls = args.get("urls", []) 117 | filetype = args.get("filetype", "") 118 | extratcsToSubfolder = args.get("extracts_to_subfolder", False) 119 | subfolderNeedsRename = args.get("subfolder_needs_rename", False) 120 | remove_files_from = args.get("remove_files_from", []) 121 | dependencies = args.get("dependencies", []) 122 | cmakeflags = args.get("cmakeflags", []) 123 | custombuild = args.get("custombuild", []) 124 | build_64bit = args.get("64bit", True) 125 | 126 | # the file handle should not be closed at that point, 127 | # but we check it anyway to get sure 128 | if fileobj is not None: 129 | extractedName = "" 130 | # if the file was already extracted in a previous run, we can 131 | # skip the extraction for obvious reasons 132 | if not self._alreadyExtracted( 133 | name, version): 134 | extractor = None 135 | # if the library source has no root folder in the package, 136 | # we need to create it manually to avoid pollution of the 137 | # extractedPath directory 138 | if (extratcsToSubfolder is not True): 139 | extractor = EXTRACTORS[filetype]( 140 | fileobj, self._extractedPrefix + "/" + 141 | name + "-" + version) 142 | else: 143 | extractor = EXTRACTORS[filetype]( 144 | fileobj, self._extractedPrefix) 145 | 146 | # extrac the files and close the handle to the source package 147 | extractedName = extractor.extract() 148 | fileobj.close() 149 | 150 | # if we need to rename the root directory of the source, 151 | # we do it now by moving it to another name; also, change 152 | # the internal name of the directory accordingly 153 | if subfolderNeedsRename: 154 | new_name = "{}-{}".format(name, version) 155 | shutil.move(self._extractedPrefix + extractedName, 156 | self._extractedPrefix + new_name) 157 | extractedName = new_name 158 | else: 159 | extractedName = "{}-{}".format(name, version) 160 | 161 | else: 162 | extractedName = "{}-{}".format(name, version) 163 | 164 | # remove file that have to be removed from the source tree 165 | if remove_files_from and ("source" in remove_files_from): 166 | for f in remove_files_from["source"]: 167 | path = "{}/{}/{}".format(self._extractedPrefix, extractedName, f) 168 | try: # try to remove file 169 | os.remove(path) 170 | except OSError: 171 | try: # try to remove directory 172 | os.removedirs(path) 173 | except OSError: 174 | print("Cannot remove path \"{}\"".format(path)) 175 | 176 | 177 | deps = None 178 | # parse the dependencies from the metadata 179 | if dependencies is not None: 180 | # dependencies that are flagged as "all" have to be 181 | # applied to all versions of the current library 182 | if "all" in dependencies: 183 | deps = dependencies["all"] 184 | # if we have special dependencies for a specific version, 185 | # take care of that now; if there was a different version 186 | # of the dependency in "all", it will be overwritten 187 | if version in dependencies: 188 | for n, v in dependencies[version].items(): 189 | deps[n] = dependencies[version][n] 190 | 191 | customcmake = "" 192 | # check if there is a custom cmake file present 193 | if "customcmake" in args and args["customcmake"] is not None: 194 | # custom cmake files that are flagged as "all" have to be 195 | # applied to all versions of the current library 196 | if "all" in args["customcmake"]: 197 | customcmake = (self._customCmakePrefix + 198 | args["customcmake"]["all"]) 199 | # if we have special cmake files for a specific version, 200 | # take care of that now; if there was a different version 201 | # of the cmake file in "all", it will be overwritten 202 | if version in args["customcmake"]: 203 | customcmake = (self._customCmakePrefix + 204 | args["customcmake"][version]) 205 | 206 | # insert a dictionary with all necessary information into 207 | # the internal cache 208 | self._libs[name][version] = { 209 | 'extractedpath': 210 | self._extractedPrefix + extractedName, 211 | 'buildpath': self._buildPrefix + extractedName, 212 | 'binpath': self._binPrefix + extractedName, 213 | 'dependencies': deps, 214 | 'built': False, 215 | 'cmakeflags': cmakeflags, 216 | 'customcmake': customcmake, 217 | 'custombuild': custombuild, 218 | '64bit': build_64bit, 219 | } 220 | 221 | def addFile(self, name): 222 | """ Parses a new yml and adds all libraries from there to the cache.""" 223 | if name is not None and name is not "": 224 | print("Parsing file {}".format(name)) 225 | with open(name, "rb") as f: 226 | yaml_data = yaml.load(f.read()) 227 | 228 | if "libs" in yaml_data and yaml_data["libs"] is not None: 229 | libs = yaml_data["libs"] 230 | for libname in libs: 231 | _libname = libs[libname].get("name", libname) 232 | self.addLibrary(_libname, libs[libname]) 233 | 234 | def _downloadLib(self, url): 235 | """ Utilizes the :class:`Downloader` to download a file from 236 | the given URL. 237 | 238 | :param url: the URL of the file to download 239 | """ 240 | filename = url.split("/")[-1] 241 | 242 | # github archive urls need a bit of special treatment regarding 243 | # version and name of the library 244 | if "github" in url and "archive" in url: 245 | _split = url.split("//")[1].split("/") 246 | filename = _split[2] + "-" + _split[4] 247 | 248 | 249 | # check cache for presence of an already downloaded copy 250 | # and skip if there is one. Otherwise, download it. 251 | tempname = self._cachePrefix + filename 252 | if not os.path.exists(tempname): 253 | print("Downloading {}".format(filename)) 254 | 255 | data = Downloader(url).getData() 256 | if data is not None: 257 | file = open(tempname, "w+b") 258 | file.write(data) 259 | file.seek(0) 260 | return file 261 | return None 262 | else: 263 | print("Using cached {}".format(filename)) 264 | return open(tempname, "r+b") 265 | 266 | def _alreadyExtracted(self, name, version): 267 | """ Helper function that checks if a library was already extracted. 268 | 269 | :param name: name of the library 270 | :param version: version of the library 271 | """ 272 | return os.path.exists("{}{}-{}".format( 273 | self._extractedPrefix, name, version)) 274 | -------------------------------------------------------------------------------- /modules/ida.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | import re 4 | import hashlib 5 | from urllib.request import Request, urlopen 6 | from base64 import b64encode 7 | 8 | REGEX = re.compile(r".*[/\\](.*?)-([^/\\]*)_(.*?)[/\\]bin[/\\](.*?)\.dll") 9 | 10 | 11 | class IDAHelper(object): 12 | """ Helper class that provides an easy-to-use interface to IDA Pro. """ 13 | 14 | def __init__(self, dll, pdb, idaq, idaq64, artifactoryPath, auth): 15 | """ Initializes an instance of this class. 16 | 17 | :param dll: the path of the dll to be analyzed with IDA Pro 18 | :param pdb: the path of the PDB file that should be applied 19 | :param idaq: the full path to idaq.exe 20 | :param idaq64: the full path to idaq64.exe 21 | :param artifactortPath: the URL base path for the artifactory 22 | :param auth: HTTP basic auth tokens for the artifactory 23 | """ 24 | super(IDAHelper, self).__init__() 25 | self._dll = (os.getcwd() + "/" + dll).replace("\\", "/") 26 | self._pdb = (os.getcwd() + "/" + pdb).replace("\\", "/") 27 | self._idaq = idaq if "x64" not in dll else idaq64 28 | self._idb = (self._dll.replace(".dll", ".idb") if "x64" not in self._dll 29 | else self._dll.replace(".dll", ".i64")) 30 | self._cwd = os.getcwd() + "/" + "/".join(dll.split("/")[:-1]) 31 | self._cwd = self._cwd.replace("\\", "/") 32 | self._artifactoryPath = artifactoryPath 33 | self._auth = auth 34 | 35 | def makeidb(self): 36 | """ Runs IDA Pro with command line flags to output an IDB file. """ 37 | args = [self._idaq, 38 | # overwrite existing 39 | "-c", 40 | # batch mode (create IDB and ASM file automatically and exit) 41 | "-B", 42 | # autonomous mode (no dialog boxes etc; remove on IDA crash) 43 | "-A", 44 | # pass arguments to our script 45 | "-Obindifflib:{}".format(self._pdb), 46 | # tell IDA to execute the bindifflib_exporter script 47 | "-S\"{}/bindifflib_exporter.py\"".format(os.getcwd()), 48 | # pack database 49 | "-P+", 50 | self._dll] 51 | # run IDA 52 | subprocess.run(args, cwd=self._cwd) 53 | 54 | def storeresult(self): 55 | """ Stores the IDB, DLL, and PDB file in the artifactory. """ 56 | 57 | # well, storing into void is not that useful 58 | if self._artifactoryPath is None: 59 | return 60 | 61 | m = REGEX.search(self._dll) 62 | if m: 63 | # extract some information from the path where the DLL is 64 | name = m.group(1) 65 | version = m.group(2) 66 | compiler = m.group(3) 67 | filename = m.group(4) 68 | 69 | # send each file separately 70 | names = [self._dll, self._pdb, self._idb] 71 | for file in names: 72 | # construct the PUT header, e.g. MD5 and SHA-1 hashes 73 | # of the file and, most importantly, setup HTTP basic auth 74 | headers = { 75 | "Content-Type": "application/octet-stream", 76 | "X-Checksum-md5": hashlib.md5( 77 | open(file, "rb").read()).hexdigest(), 78 | "X-Checksum-sha1": hashlib.sha1( 79 | open(file, "rb").read()).hexdigest(), 80 | "Authorization": "Basic {}".format( 81 | b64encode( 82 | ":".join(self._auth).encode()).decode("ascii")), 83 | } 84 | 85 | # construct the urllib request 86 | r = Request(self._artifactoryPath + 87 | "bin/{name}/{version}/{compiler}/{fname}".format( 88 | name=name, version=version, compiler=compiler, 89 | fname=file.replace("\\", "/").split("/")[-1]), 90 | headers=headers, data=open(file, "rb").read(), 91 | method="PUT") 92 | 93 | # send the request and upload the file 94 | urlopen(r) 95 | 96 | @property 97 | def dll(self): 98 | return self._dll 99 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | artifactory==0.1.17 2 | pathlib==1.0.1 3 | python-dateutil==2.6.0 4 | PyYAML==3.12 5 | requests==2.13.0 6 | six==1.10.0 7 | -------------------------------------------------------------------------------- /settings.yml: -------------------------------------------------------------------------------- 1 | artifactory_path: http://artifactory.example.com/artifactory/repo/ 2 | artifactory_user: user 3 | artifactory_pass: password --------------------------------------------------------------------------------