diff --git a/CMakeLists.txt b/CMakeLists.txt index ddc7e66..6d72293 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,15 @@ add_custom_target( ) # Install the ttrts man page -install( FILES "${CMAKE_BINARY_DIR}/ttrts.6" DESTINATION man/man6/ ) +if( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) + set ( MANPAGE_LOC share/man/man6 ) +elseif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) + set ( MANPAGE_LOC man/man6 ) +else() + message(ERROR "Unsupported system detected") +endif() + +install( FILES "${CMAKE_BINARY_DIR}/ttrts.6" DESTINATION ${MANPAGE_LOC} ) # Subprojects add_subdirectory( source/ttrts ) diff --git a/scripts/gen_manpage.sh b/scripts/gen_manpage.sh index 9b7e02a..57ad57c 100755 --- a/scripts/gen_manpage.sh +++ b/scripts/gen_manpage.sh @@ -1,13 +1,15 @@ #! /bin/bash # Used to a man page from markdown - - echo ".\" Man page for the ttrts project" > $4 echo ".\" this man page is auto-generated, do not edit directly" >> $4 echo ".TH TTRTS\ v$1.$2.$3 6 $(date +%Y-%m-%d) http://mdiluz.github.io/ttrts/" >> $4 +# NOTE: For the OSX version of sed we use -E, which on linux appears be an undocumented switch for -r +# we also have to use [A-Za-z] instead of \w for some reason +# as well as escaped new line characters and literal tabs instead of \n and \t + # sections to section headers # sub-sections in man page sub-sections # 4-space lines to tabs @@ -19,13 +21,15 @@ echo ".TH TTRTS\ v$1.$2.$3 6 $(date +%Y-%m-%d) http://mdiluz.github.io/ttrts/" > # underline mapfile opt # ensure name section uses correct cat "$5" \ - | sed -r 's/^# (\w+)/.SH \1/g' \ - | sed -r 's/^##+ (\w+)/.SS \1/g' \ - | sed -r 's/^ (.*)$/\n\t\1\n/g' \ - | sed -r 's/^\t//g' \ - | sed -r 's/\$\{(\w+)\}/\\fB\$\1\\fR/g' \ - | sed -r 's/\{(\w+)\}/\\fI\1\\fR/g' \ - | sed -r 's/-----+//g' \ - | sed -r 's/`(.*?)`/\\fB\1\\fR/g' \ - | sed -r 's/MAPFILE/\\fImapfile\\fR/g' \ - | sed -r 's/\tttrts -/\tttrts \\-/g' >> $4 + | sed -E 's/^# ([A-Za-z]+)/.SH \1/g' \ + | sed -E 's/^##+ ([A-Za-z]+)/.SS \1/g' \ + | sed -E 's/^ (.*)$/\ + \1\ +/g' \ + | sed -E 's/^ //g' \ + | sed -E 's/\$\{([A-Za-z]+)\}/\\fB\$\1\\fR/g' \ + | sed -E 's/\{([A-Za-z]+)\}/\\fI\1\\fR/g' \ + | sed -E 's/-----+//g' \ + | sed -E 's/`(.*)`/\\fB\1\\fR/g' \ + | sed -E 's/MAPFILE/\\fImapfile\\fR/g' \ + | sed -E 's/ ttrts -/ ttrts \\-/g' >> $4 diff --git a/scripts/gen_usage.sh b/scripts/gen_usage.sh index c989b2d..efeab0a 100755 --- a/scripts/gen_usage.sh +++ b/scripts/gen_usage.sh @@ -1,10 +1,10 @@ #! /bin/bash # Used to generate usage text from markdown + cat README.md \ - | sed 's/^#\+ //g' \ - | sed 's/^\t/\\t/g' \ - | sed 's/^ /\\t/g' \ - | sed ':a;N;$!ba;s/\n/\\n\n/g' \ - | sed 's/^/\"/' \ - | sed 's/$/\"/' \ + | sed -E 's/^#+ //g' \ + | sed -E 's/^ /\\t/g' \ + | sed -E 's/^ /\\t/g' \ + | sed -E 's/^/\"/' \ + | sed -E 's/$/\\n\"/' \ > $1 diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 7d12cef..6549943 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -13,6 +13,14 @@ set( SOURCES main.cpp ) +# Set defaults for ttrts maps and games +set( TTRTS_MAPS "/usr/local/share/ttrts/maps/" ) +set( TTRTS_GAMES "/tmp/" ) + +# define these defaults in code +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTTRTS_MAPS=${TTRTS_MAPS}" ) +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTTRTS_GAMES=${TTRTS_GAMES}" ) + # Add the executable add_executable( ${PROJECT_NAME} ${SOURCES} ) diff --git a/source/client/main.cpp b/source/client/main.cpp index 76ce858..35bf5de 100644 --- a/source/client/main.cpp +++ b/source/client/main.cpp @@ -12,6 +12,9 @@ #include "game.h" +#define STRINGIFY(x) _STRINGIFY(x) +#define _STRINGIFY(x) #x + static const char* sk_usage = #include "usage.h" ; @@ -69,7 +72,7 @@ int main(int argc, char* argv[]) std::string gameFile = argv[1]; // Default for maps - std::string ttrts_maps_dir = "/usr/share/ttrts/maps/"; + std::string ttrts_maps_dir = STRINGIFY(TTRTS_MAPS); if( getenv("TTRTS_MAPS") ) { ttrts_maps_dir = getenv("TTRTS_MAPS"); @@ -80,7 +83,7 @@ int main(int argc, char* argv[]) } // Default for games - std::string ttrts_games_dir = "/tmp/"; + std::string ttrts_games_dir = STRINGIFY(TTRTS_GAMES); if( getenv("TTRTS_GAMES") ) { ttrts_games_dir = getenv("TTRTS_GAMES"); diff --git a/source/gen/CMakeLists.txt b/source/gen/CMakeLists.txt index 7d0a030..466e233 100644 --- a/source/gen/CMakeLists.txt +++ b/source/gen/CMakeLists.txt @@ -25,4 +25,4 @@ add_custom_target( add_dependencies(ttrts-gen-maps ${PROJECT_NAME}) # Installation target -install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/maps DESTINATION /usr/share/ttrts ) \ No newline at end of file +install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/maps DESTINATION /usr/local/share/ttrts ) \ No newline at end of file