diff --git a/CMakeLists.txt b/CMakeLists.txt index c34eec783d3..474400f166d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,6 +242,8 @@ else() message(STATUS "IPO / LTO not supported: <${error}>") endif() +find_program(SED sed gsed) + add_subdirectory(src) add_subdirectory(regression) add_subdirectory(unit) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ede10e72e3b..9529b881f69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,10 +41,15 @@ macro(generic_bison name) COMPILE_FLAGS "${bison_warnings_as_errors} -pyy${name}" ) set(renamed_parser_header "${CMAKE_CURRENT_BINARY_DIR}/${bison_header}") - add_custom_command(OUTPUT "${renamed_parser_header}" - COMMAND "${CMAKE_COMMAND}" -E copy "${BISON_parser_OUTPUT_HEADER}" "${renamed_parser_header}" - MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}" - ) + if(${SED} STREQUAL "SED-NOTFOUND") + add_custom_command(OUTPUT "${renamed_parser_header}" + COMMAND "${CMAKE_COMMAND}" -E copy "${BISON_parser_OUTPUT_HEADER}" "${renamed_parser_header}" + MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}") + else() + add_custom_command(OUTPUT "${renamed_parser_header}" + COMMAND ${SED} -e "s,enum yytokentype,enum yytokentype_${name}," <${BISON_parser_OUTPUT_HEADER} >${renamed_parser_header} + MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}") + endif() list(REMOVE_ITEM BISON_parser_OUTPUTS "${BISON_parser_OUTPUT_HEADER}") list(APPEND BISON_parser_OUTPUTS "${renamed_parser_header}") endmacro(generic_bison) diff --git a/src/ansi-c/Makefile b/src/ansi-c/Makefile index 64ffa497072..4f5d2886776 100644 --- a/src/ansi-c/Makefile +++ b/src/ansi-c/Makefile @@ -86,6 +86,9 @@ all: ansi-c$(LIBEXT) ansi_c_y.tab.cpp: parser.y $(YACC) $(YFLAGS) -pyyansi_c parser.y --defines=ansi_c_y.tab.h -o $@ + $(SED) -e's,enum yytokentype,enum yytokentype_ansi,' \ + ansi_c_y.tab.h.tmp && \ + mv ansi_c_y.tab.h.tmp ansi_c_y.tab.h ansi_c_y.tab.h: ansi_c_y.tab.cpp diff --git a/src/common b/src/common index bf4190c5bd5..71ac0a56caa 100644 --- a/src/common +++ b/src/common @@ -98,6 +98,9 @@ endif ifeq ($(origin LEX),default) LEX = flex endif +ifeq ($(origin SED),default) + SED = sed +endif else ifeq ($(BUILD_ENV_),Cygwin) # use these for Cygwin: @@ -130,6 +133,9 @@ endif ifeq ($(origin LEX),default) LEX = flex endif +ifeq ($(origin SED),default) + SED = sed +endif else ifeq ($(BUILD_ENV_),MSVC) @@ -158,6 +164,10 @@ endif ifeq ($(origin LEX),default) LEX = win_flex endif +ifeq ($(origin SED),default) + # on MSVC there is no lto + SED = rem +endif else diff --git a/src/statement-list/Makefile b/src/statement-list/Makefile index b23de346064..54ec5aa771f 100644 --- a/src/statement-list/Makefile +++ b/src/statement-list/Makefile @@ -31,6 +31,9 @@ all: statement-list$(LIBEXT) statement_list_y.tab.cpp: parser.y $(YACC) $(YFLAGS) -pyystatement_list parser.y --defines=statement_list_y.tab.h -o $@ + $(SED) -e's,enum yytokentype,enum yytokentype_stmt,' \ + statement_list_y.tab.h.tmp && \ + mv statement_list_y.tab.h.tmp statement_list_y.tab.h statement_list_y.tab.h: statement_list_y.tab.cpp