diff --git a/.travis.yml b/.travis.yml index 09cb04148..d608984dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,71 @@ language: c -compiler: - - gcc +matrix: + include: + - env: test="Original" + + os: linux + dist: trusty + compiler: gcc + script: ./autogen.sh && ./configure && make && make check && make distcheck + before_script: + - ./.travis/install-gettext.sh + - ./.travis/install-automake.sh + - export PATH=$HOME/bin:$PATH + + - env: test="x64 4.8.4 (CMake gcc)" + os: linux + dist: trusty + compiler: gcc + before_script: + - mkdir gcc_rel && cd gcc_rel + - cmake .. + script: make + + - env: test="x64 (CMake clang)" + os: linux + dist: trusty + compiler: clang + before_script: + - mkdir clang_rel && cd clang_rel + - cmake .. + script: make + + - env: test="x64 (CMake clang - Ninja) Debug" + os: linux + dist: trusty + compiler: clang + before_script: + - mkdir clang_ninja_dbg && cd clang_ninja_dbg + - cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug + script: ninja + + - env: test="x64 (CMake clang - Ninja) Install / Uninstall" + os: linux + dist: trusty + compiler: clang + before_script: + - mkdir clang_ninja && cd clang_ninja + - cmake .. -GNinja -DCMAKE_INSTALL_PREFIX=./out + script: + - ninja install + - ninja uninstall addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - autoconf - - bison - - gcc-6 - - help2man - - lzip - - texinfo - - texlive - -before_script: - - ./.travis/install-gettext.sh - - ./.travis/install-automake.sh - - export PATH=$HOME/bin:$PATH - -script: ./autogen.sh && ./configure && make && make check && make distcheck + + apt: + packages: + - autoconf + - bison + - gcc-6 + - help2man + - lzip + - texinfo + - texlive + - automake + - libtool + - m4 + - cmake + - ninja-build + sources: + - ubuntu-toolchain-r-test diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..2b5a6dad1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,128 @@ +cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) + +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake") + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: DEBUG, RELEASE, or MINSIZEREL." FORCE) + message(STATUS "No build type specified, defaulting to Release.") +endif() + +project(flex LANGUAGES C) + +# Create config.h +include(make_config_h) + +# Build options +option(ENABLE_NLS "Enable NLS" FALSE) +if(ENABLE_NLS) + add_definitions(-DENABLE_NLS -DYYENABLE_NLS) +endif() +option(ENABLE_C_ALLOCA "Enable alloca.c" FALSE) +option(ENABLE_MEM_SHIM "Replacement malloc, realloc" FALSE) + +# Locate M4 path if not set +if(NOT M4_PATH) + if(UNIX OR APPLE) + set(SEARCH_CMD which) + elseif(MINGW OR CYGWIN OR WIN32) + set(SEARCH_CMD where) + endif() + + execute_process( + COMMAND ${SEARCH_CMD} m4 + OUTPUT_VARIABLE M4_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() +MESSAGE(STATUS "Using M4: ${M4_PATH}") + +# compiler specifics +if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") + add_definitions(-D_GNU_SOURCE) +elseif (CMAKE_C_COMPILER_ID MATCHES "MSVC") + add_definitions(-D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_WARNINGS) +endif() + +# generate parse.c +include(FindBISON) +bison_target(parse src/parse.y ${CMAKE_BINARY_DIR}/gen/parse.c) + +# generate scan.c +include(FindFLEX) +FLEX_TARGET(scan src/scan.l ${CMAKE_BINARY_DIR}/gen/scan.c) + +# generate skel.c +string(REPLACE ";" "" STRIPPED_VERSION "${VERSION}") +include(FindUnixCommands) +if(BASH) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/gen/skel.c + COMMAND ${BASH} -c "${CMAKE_SOURCE_DIR}/src/mkskel.sh ${CMAKE_SOURCE_DIR}/src ${M4_PATH} ${STRIPPED_VERSION}>skel.c" + DEPENDS ${CMAKE_SOURCE_DIR}/src/mkskel.sh + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gen + COMMENT "[m4][flex.skl] Creating skel.c" +) +# TODO make this step target generic via CMake script +endif() + +set(GENERATED_SOURCES + ${BISON_parse_OUTPUT_SOURCE} + ${FLEX_scan_OUTPUTS} + ${CMAKE_BINARY_DIR}/gen/skel.c +) + +# inlcude files +include_directories(src) +include_directories(${CMAKE_BINARY_DIR}/gen) + +# source files +set(sources + src/buf.c src/ccl.c src/dfa.c src/ecs.c + src/scanflags.c src/filter.c src/flexdef.h + src/gen.c src/misc.c src/nfa.c + src/options.c src/options.h src/regex.c + src/scanopt.c src/scanopt.h src/sym.c + src/tables.c src/tables.h + src/tables_shared.c src/tables_shared.h + src/tblcmp.c src/yylex.c +) + +if(ENABLE_MEM_SHIM) + list(APPEND sources lib/malloc.c lib/realloc.c) +endif() + +# command line +add_executable(flex ${sources} src/main.c ${GENERATED_SOURCES}) +add_library(fl SHARED ${sources} ${GENERATED_SOURCES}) +if(UNIX AND NOT ANDROID) + target_link_libraries(flex -lm) + target_link_libraries(fl -lm) + set(PKGCONFIG_LIBS "-lm -lc") +endif() + +# Installation +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +install(TARGETS flex DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS fl DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# pkgconfig +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix "\${prefix}") +set(libdir "\${exec_prefix}/lib") +configure_file(${CMAKE_SOURCE_DIR}/src/libfl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libfl.pc @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libfl.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# CMake +configure_package_config_file(cmake/FlexConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FlexConfigVersion.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/flex/cmake) + +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FlexConfigVersion.cmake + VERSION ${PACKAGE_VERSION} COMPATIBILITY ExactVersion) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FlexConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/flex/cmake ) + +# uninstall +add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/cmake/make_uninstall.cmake") diff --git a/cmake/FlexConfig.cmake.in b/cmake/FlexConfig.cmake.in new file mode 100644 index 000000000..eaf5fd734 --- /dev/null +++ b/cmake/FlexConfig.cmake.in @@ -0,0 +1,8 @@ +set(FLEX_VERSION @PACKAGE_VERSION@) +... +@PACKAGE_INIT@ +... +set_and_check(FLEX_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(FLEX_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@") + +check_required_components(flex) diff --git a/cmake/config.h.in b/cmake/config.h.in new file mode 100644 index 000000000..4f7df13a3 --- /dev/null +++ b/cmake/config.h.in @@ -0,0 +1,264 @@ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#cmakedefine CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#cmakedefine C_ALLOCA + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#cmakedefine ENABLE_NLS @ENABLE_NLS@ + +/* Define to 1 if you have `alloca', as a function or macro. */ +#cmakedefine HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#cmakedefine HAVE_ALLOCA_H + +/* Define to 1 if you have the `available.' function. */ +#cmakedefine HAVE_AVAILABLE_ + +/* Define to 1 if you have the `by' function. */ +#cmakedefine HAVE_BY + +/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +#cmakedefine HAVE_CFLOCALECOPYCURRENT + +/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +#cmakedefine HAVE_CFPREFERENCESCOPYAPPVALUE + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +#cmakedefine HAVE_DCGETTEXT + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H + +/* Define to 1 if you have the `dnl' function. */ +#cmakedefine HAVE_DNL + +/* Define to 1 if you have the `dup2' function. */ +#cmakedefine HAVE_DUP2 + +/* Define to 1 if you have the `enabled' function. */ +#cmakedefine HAVE_ENABLED + +/* Define to 1 if you have the `fork' function. */ +#cmakedefine HAVE_FORK + +/* Define to 1 if you have the `function.' function. */ +#cmakedefine HAVE_FUNCTION_ + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#cmakedefine HAVE_GETTEXT + +/* Define to 1 if you have the `have' function. */ +#cmakedefine HAVE_HAVE + +/* Define if you have the iconv() function and it works. */ +#cmakedefine HAVE_ICONV + +/* Define to 1 if you have the `if' function. */ +#cmakedefine HAVE_IF + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H + +/* Define to 1 if you have the `is' function. */ +#cmakedefine HAVE_IS + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIBINTL_H + +/* Define to 1 if you have the `m' library (-lm). */ +#cmakedefine HAVE_LIBM + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIMITS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LOCALE_H + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#cmakedefine HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MALLOC_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#cmakedefine HAVE_MEMSET + +/* Define to 1 if you have the `Needed' function. */ +#cmakedefine HAVE_NEEDED + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IN_H + +/* Define to 1 if you have the `NLS' function. */ +#cmakedefine HAVE_NLS + +/* Define to 1 if you have the `not' function. */ +#cmakedefine HAVE_NOT + +/* Define to 1 if you have the `only' function. */ +#cmakedefine HAVE_ONLY + +/* Define to 1 if you have the `OpenBSD' function. */ +#cmakedefine HAVE_OPENBSD + +/* Define to 1 if you have the `pow' function. */ +#cmakedefine HAVE_POW + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PTHREAD_H + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#cmakedefine HAVE_REALLOC + +/* Define to 1 if you have the `reallocarray' function. */ +#cmakedefine HAVE_REALLOCARRAY + +/* Define to 1 if you have the `regcomp' function. */ +#cmakedefine HAVE_REGCOMP + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_REGEX_H + +/* Define to 1 if you have the `replacement' function. */ +#cmakedefine HAVE_REPLACEMENT + +/* Define to 1 if you have the `setlocale' function. */ +#cmakedefine HAVE_SETLOCALE + +/* Define to 1 if stdbool.h conforms to C99. */ +#cmakedefine HAVE_STDBOOL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#cmakedefine HAVE_STRCASECMP + +/* Define to 1 if you have the `_stricmp' function. */ +#cmakedefine HAVE__STRICMP + +/* Define to 1 if you have the `strchr' function. */ +#cmakedefine HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#cmakedefine HAVE_STRDUP + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H + +/* Define to 1 if you have the `strtol' function. */ +#cmakedefine HAVE_STRTOL + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H + +/* Define to 1 if you have the `Used' function. */ +#cmakedefine HAVE_USED + +/* Define to 1 if you have the `vfork' function. */ +#cmakedefine HAVE_VFORK + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_VFORK_H + +/* Define to 1 if you have the `We' function. */ +#cmakedefine HAVE_WE + +/* Define to 1 if `fork' works. */ +#cmakedefine HAVE_WORKING_FORK + +/* Define to 1 if `vfork' works. */ +#cmakedefine HAVE_WORKING_VFORK + +/* Define to 1 if the system has the type `_Bool'. */ +#cmakedefine HAVE__BOOL + +/* Define to the m4 executable name. */ +#define M4 "@M4_PATH@" + +/* Name of package */ +#cmakedefine PACKAGE "@PACKAGE@" + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@" + +/* Define to the home page for this package. */ +#cmakedefine PACKAGE_URL "@PACKAGE_URL@" + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#cmakedefine STACK_DIRECTION @STACK_DIRECTION@ + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +#cmakedefine VERSION @VERSION@ + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#cmakedefine YYTEXT_POINTER + +/* Define to empty if `const' does not conform to ANSI C. */ +#cmakedefine const + +/* Define to rpl_malloc if the replacement function should be used. */ +#cmakedefine malloc @malloc@ + +/* Define to `int' if does not define. */ +#cmakedefine pid_t @pid_t@ + +/* Define to rpl_realloc if the replacement function should be used. */ +#cmakedefine realloc + +/* Define to `unsigned int' if does not define. */ +#cmakedefine size_t @size_t@ + +/* Define as `fork' if `vfork' does not work. */ +#cmakedefine vfork diff --git a/cmake/make_config_h.cmake b/cmake/make_config_h.cmake new file mode 100644 index 000000000..1dad46437 --- /dev/null +++ b/cmake/make_config_h.cmake @@ -0,0 +1,221 @@ +include(CheckIncludeFiles) +include(CheckFunctionExists) +include(CheckLibraryExists) +include(CheckTypeSize) +include(CheckPrototypeDefinition) + + +check_include_files(dlfcn.h HAVE_DLFCN_H) +check_include_files(stdint.h HAVE_STDINT_H) +check_include_files(stddef.h HAVE_STDDEF_H) +check_include_files(inttypes.h HAVE_INITTYPES_H) +check_include_files(stdlib.h HAVE_STDLIB_H) +check_include_files(strings.h HAVE_STRINGS_H) +check_include_files(string.h HAVE_STRING_H) + +if(HAVE_DLFCN_H AND HAVE_STDINT_H AND HAVE_STDDEF_H AND HAVE_INITTYPES_H AND + HAVE_STDLIB_H AND HAVE_STRINGS_H AND HAVE_STRING_H ) + check_function_exists(memchr string.h memchrExists) + if(memchrExists) + check_function_exists(free freeExists) + if(freeExists) + message(STATUS "ANSI C header files - found") + set(STDC_HEADERS 1 CACHE INTERNAL "System has ANSI C header files") + endif(freeExists) + endif(memchrExists) +endif() + + +check_function_exists(alloca HAVE_ALLOCA) +check_include_files(alloca.h HAVE_ALLOCA_H_CHECK) +if(ENABLE_C_ALLOCA AND HAVE_ALLOCA_H_CHECK) + set(HAVE_ALLOCA_H TRUE) + if(NOT STACK_DIRECTION) + set(STACK_DIRECTION 0) # auto - direction of growth unknown + endif() +endif() + +check_function_exists("available." HAVE_AVAILABLE_) +check_function_exists(by HAVE_BY) + +if(APPLE) + check_function_exists(CFLocaleCopyCurrent HAVE_CFLOCALECOPYCURRENT) + check_function_exists(CFPreferencesCopyAppValue HAVE_CFPREFERENCESCOPYAPPVALUE) +endif() + +check_function_exists(dcgettext HAVE_DCGETTEXT) +check_function_exists(dnl HAVE_DNL) +check_function_exists(dup2 HAVE_DUP2) +check_function_exists(enabled HAVE_ENABLED) +check_function_exists(fork HAVE_FORK) +check_function_exists(function. HAVE_FUNCTION_) +check_function_exists(gettext HAVE_GETTEXT) +check_function_exists(have HAVE_HAVE) +check_function_exists(iconv HAVE_ICONV) +check_function_exists(if HAVE_IF) +check_function_exists(is HAVE_IS) +check_include_files(libintl.h HAVE_LIBINTL_H) +check_library_exists(m log10 "" HAVE_LIBM) +check_include_files(limits.h HAVE_LIMITS_H) +check_include_files(locale.h HAVE_LOCALE_H) +check_function_exists(malloc HAVE_MALLOC) +check_include_files(malloc.h HAVE_MALLOC_H) +check_include_files(memory.h HAVE_MEMORY_H) +check_function_exists(memset HAVE_MEMSET) +check_function_exists(Needed HAVE_NEEDED) +check_include_files(netinet/in.h HAVE_NETINET_IN_H) +check_function_exists(NLS HAVE_NLS) +check_function_exists("not" HAVE_NOT) +check_function_exists(only HAVE_ONLY) +check_function_exists(OpenBSD HAVE_OPENBSD) +check_function_exists(pow HAVE_POW) +check_include_files(pthread.h HAVE_PTHREAD) +find_package(Threads REQUIRED) +if (CMAKE_USE_PTHREADS_INIT) + add_definitions(-DHAVE_PTHREAD) +endif (CMAKE_USE_PTHREADS_INIT) +check_function_exists(realloc HAVE_REALLOC) +check_function_exists(reallocarray HAVE_REALLOCARRAY) +check_function_exists(regcomp HAVE_REGCOMP) +check_include_files(regex.h HAVE_REGEX_H) +check_function_exists(replacement HAVE_REPLACEMENT) +check_function_exists(setlocale HAVE_SETLOCALE) +check_include_files(stdbool.h HAVE_STDBOOL_H) +check_function_exists(strcasecmp HAVE_STRCASECMP) +check_function_exists(_stricmp HAVE__STRICMP) +check_function_exists(strchr HAVE_STRCHR) +check_function_exists(strdup HAVE_STRDUP) +check_function_exists(strtol HAVE_STRTOL) +check_include_files("sys/stat.h" HAVE_SYS_STAT_H) +check_include_files("sys/types.h" HAVE_SYS_TYPES_H) +check_include_files("sys/wait.h" HAVE_SYS_WAIT_H) +check_include_files(unistd.h HAVE_UNISTD_H) +if(NOT HAVE_UNISTD_H) + add_definitions(-DYY_NO_UNISTD_H) +endif() +check_function_exists(Used HAVE_USED) +check_function_exists(vfork HAVE_VFORK) +check_include_files(vfork.h HAVE_VFORK_H) +check_function_exists(We HAVE_WE) + +# Define to 1 if `fork' works. +set(HAVE_WORKING_FORK FALSE) + +# Define to 1 if `vfork' works. +set(HAVE_WORKING_VFORK FALSE) + +check_type_size(_Bool HAVE__BOOL_SIZE) +if(HAVE__BOOL_SIZE) + set(HAVE__BOOL 1) +else() + set(HAVE__BOOL 0) +endif() + + +# Parse package info from configure.ac +file(STRINGS "configure.ac" flex_ACINIT_LINE LIMIT_COUNT 1 REGEX "^AC_INIT") + +#Before: "AC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex])" +string(REPLACE "(" "_" flex_ACINIT_LINE ${flex_ACINIT_LINE}) +string(REPLACE ")" "_" flex_ACINIT_LINE ${flex_ACINIT_LINE}) +string(REPLACE "[" "_" flex_ACINIT_LINE ${flex_ACINIT_LINE}) +string(REPLACE "]" "_" flex_ACINIT_LINE ${flex_ACINIT_LINE}) +#After: "AC_INIT__the fast lexical analyser generator_,_2.6.4_,_flex-help@lists.sourceforge.net_,_flex__" + +# Parse name +string(REGEX REPLACE "^AC_INIT__([^_]+).*$" "\\1" flex_PACKAGE_NAME "${flex_ACINIT_LINE}") +MESSAGE(STATUS "PACAKGE_NAME=${flex_PACKAGE_NAME}") + +# Parse version string +string(REGEX REPLACE "^AC_INIT__${flex_PACKAGE_NAME}_,_([^_]+).*$" "\\1" flex_VERSION_STRING "${flex_ACINIT_LINE}") +string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\1" + flex_VERSION_MAJOR "${flex_VERSION_STRING}") +string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\2" + flex_VERSION_MINOR "${flex_VERSION_STRING}") +string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\3" + flex_VERSION_PATCH "${flex_VERSION_STRING}") + +# Package version +set(flex_VERSION ${flex_VERSION_MAJOR}.${flex_VERSION_MINOR}.${flex_VERSION_PATCH}) + +# Name of package +set(PACKAGE "flex") +MESSAGE(STATUS "PACKAGE=${PACKAGE}") + +# Define to the address where bug reports for this package should be sent. +set(PACKAGE_BUGREPORT ${flex_BUGREPORT_STRING}) +MESSAGE(STATUS "PACKAGE_BUGREPORT=${PACKAGE_BUGREPORT}") + +# Define to the full name of this package. +set(PACKAGE_NAME ${flex_NAME}) +MESSAGE(STATUS "PACKAGE_NAME=${PACKAGE_NAME}") + +# Define to the full name and version of this package. +set(PACKAGE_STRING "") + +# Define to the one symbol short name of this package. +set(PACKAGE_TARNAME "") + +# Define to the home page for this package. +set(PACKAGE_URL "") + +# Define to the version of this package. +set(PACKAGE_VERSION ${flex_VERSION}) +set(PROJECT_VERSION ${flex_VERSION}) +MESSAGE(STATUS "PACKAGE_VERSION=${PACKAGE_VERSION}") + +# If using the C implementation of alloca, define if you know the +# direction of stack growth for your system; otherwise it will be +# automatically deduced at runtime. +# STACK_DIRECTION > 0 => grows toward higher addresses +# STACK_DIRECTION < 0 => grows toward lower addresses +# STACK_DIRECTION = 0 => direction of growth unknown +#cmakedefine STACK_DIRECTION + + +# Version number of package +set(VERSION "\"${flex_VERSION_MAJOR}.${flex_VERSION_MINOR}.${flex_VERSION_PATCH}\";") + +# Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. +#cmakedefine YYTEXT_POINTER + +# Define to empty if `const' does not conform to ANSI C. +#cmakedefine const + +# Define to rpl_malloc if the replacement function should be used. +if(ENABLE_MEM_SHIM) + set(malloc rpl_malloc) +endif() + +# Define to `int' if does not define. +check_type_size(pid_t PID_T_TYPE_SIZE) +if(NOT PID_T_TYPE_SIZE) + MESSAGE(STATUS "Setting pid_t to int") + set(pid_t "int") +endif() + +# Define to rpl_realloc if the replacement function should be used. +#cmakedefine realloc + +# Define to `unsigned int' if does not define. +check_type_size(size_t SIZE_T_TYPE_SIZE) +if(NOT SIZE_T_TYPE_SIZE) + MESSAGE(STATUS "Setting size_t to unsigned int") + set(size_t "unsigned int") +endif() + +# Define as `fork' if `vfork' does not work. +#cmakedefine vfork + +check_include_files(libgen.h HAVE_LIBGEN_H) +check_include_files(assert.h HAVE_ASSERT_H) + +include(TestBigEndian) +test_big_endian(HOST_IS_BIG_ENDIAN) +if(NOT HOST_IS_BIG_ENDIAN) + add_definitions(-DHOST_IS_LITTLE_ENDIAN) +endif() + + +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.in ${CMAKE_BINARY_DIR}/gen/config.h @ONLY) +add_definitions(-DHAVE_CONFIG_H) diff --git a/cmake/make_uninstall.cmake b/cmake/make_uninstall.cmake new file mode 100644 index 000000000..451614ee7 --- /dev/null +++ b/cmake/make_uninstall.cmake @@ -0,0 +1,19 @@ + +if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") +endif() + +file(READ "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt" files) +string(REGEX REPLACE "[\r\n]" ";" files "${files}") + +foreach(file ${files}) + message(STATUS "Uninstalling ${file}") + if(EXISTS "${file}") + file(REMOVE ${file}) + if (EXISTS "${file}") + message(FATAL_ERROR "Problem when removing ${file}, please check your permissions") + endif() + else() + message(STATUS "File ${file} does not exist.") + endif() +endforeach()