diff --git a/ASFilter/CMakeLists.txt b/ASFilter/CMakeLists.txt index e43bfc78c9..dfbfabbd07 100644 --- a/ASFilter/CMakeLists.txt +++ b/ASFilter/CMakeLists.txt @@ -18,9 +18,25 @@ cmake_minimum_required(VERSION 2.8) set(CMAKE_CXX_FLAGS "--std=c++0x") -find_package(Boost COMPONENTS regex) + +set(USE_BOOST_REGEX FALSE CACHE BOOL "Force use of boost for regular expressions") + +if(CMAKE_COMPILER_IS_GNUCXX) + if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.9) + set(USE_BOOST_REGEX TRUE) + message(STATUS "forcing use of boost::regex") + endif() +endif() + +if(USE_BOOST_REGEX) + add_definitions(-DUSE_BOOST_REGEX) + find_package(Boost COMPONENTS regex) +endif() add_executable(asfilter asfilter.cc) -target_link_libraries(asfilter ${Boost_LIBRARIES}) + +if(USE_BOOST_REGEX) + target_link_libraries(asfilter ${Boost_LIBRARIES}) +endif() install(TARGETS asfilter RUNTIME DESTINATION bin) diff --git a/ASFilter/asfilter.cc b/ASFilter/asfilter.cc index 447ff72a54..21accaf264 100644 --- a/ASFilter/asfilter.cc +++ b/ASFilter/asfilter.cc @@ -25,10 +25,17 @@ #include #include #include -#include using namespace std::placeholders; +#ifdef USE_BOOST_REGEX +#include +namespace rx = boost; +#else +#include +namespace rx = std; +#endif + int main(int argc, char *argv[]) { std::vector argv2; @@ -50,7 +57,7 @@ int main(int argc, char *argv[]) { inputFileName = p; p = tempFileName; - std::cerr << "Temp file: " << tempFileName << std::endl; + //std::cerr << "Temp file: " << tempFileName << std::endl; } } @@ -59,11 +66,11 @@ int main(int argc, char *argv[]) std::ofstream out(tempFileName); std::string wordS = "[0-9a-f][0-9a-f][0-9a-f][0-9a-f]"; - boost::regex jsr("\tjsr __magic_inline_(" + wordS + "(_" + wordS + ")*)"); - boost::regex word(wordS); - //boost::regex size("\t\\.size\t([a-zA-Z0-9_]+), \\.-([a-zA-Z0-9_]+)"); - boost::regex globl("\t\\.globl\t([a-zA-Z0-9_]+)"); - boost::regex rts("\trts"); + rx::regex jsr("\tjsr __magic_inline_(" + wordS + "(_" + wordS + ")*)"); + rx::regex word(wordS); + //std::regex size("\t\\.size\t([a-zA-Z0-9_]+), \\.-([a-zA-Z0-9_]+)"); + rx::regex globl("\t\\.globl\t([a-zA-Z0-9_]+)"); + rx::regex rts("\trts"); std::string function_name = "__unknown"; while(in) @@ -73,30 +80,30 @@ int main(int argc, char *argv[]) if(!in) break; - boost::smatch match; - if(boost::regex_match(line, match, jsr)) + rx::smatch match; + if(rx::regex_match(line, match, jsr)) { - const boost::sregex_token_iterator end; - for (boost::sregex_token_iterator p(line.cbegin(), line.cend(), word); + const rx::sregex_token_iterator end; + for (rx::sregex_token_iterator p(line.cbegin(), line.cend(), word); p != end; ++p) { out << "\tdc.w 0x" << *p << std::endl; } } - /*else if(boost::regex_match(line, match, size) && match[1] == match[2]) + /*else if(rx::regex_match(line, match, size) && match[1] == match[2]) { out << "\tdc.b 0x8e\n"; out << "\t.string \"" << match[1] << "\"\n"; out << "\t.align 2\n"; out << line << std::endl; }*/ - else if(boost::regex_match(line, match, globl)) + else if(rx::regex_match(line, match, globl)) { out << line << std::endl; function_name = match[1]; } - /*else if(boost::regex_match(line, rts)) + /*else if(rx::regex_match(line, rts)) { out << line << std::endl; out << "\tdc.b 0x8e\n"; diff --git a/README.md b/README.md index 8feedf7dfa..0b3b68e528 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Prerequisites ------------- - Linux or Mac OS X +- boost, if using gcc 4.8 or earlier to compile on Linux - CMake 2.8 -- boost - Glasgow Haskell Compiler (GHC) - GCC dependencies: GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+ - Apple Universal Interfaces (tested with version 3.1 - see below) @@ -22,7 +22,7 @@ Prerequisites For Ubuntu Linux, the following should help a bit: - sudo apt-get install cmake ghc libboost-dev libgmp-dev libmpfr-dev libmpc-dev + sudo apt-get install cmake ghc libgmp-dev libmpfr-dev libmpc-dev On a Mac, get the homebrew package manager and: