anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
Config (9759B)
1 #!/bin/sh 2 # 3 # Configuration script for Services. 4 # 5 # Anope (C) 2003-2022 Anope Team 6 # Contact us at team@anope.org 7 # 8 # This program is free but copyrighted software; see the file COPYING for 9 # details. 10 # 11 # Based on the original code of Epona by PegSoft. 12 # Based on the original code of Services by Andy Church. 13 # 14 ########################################################################### 15 16 echo2 () { 17 $ECHO2 "$*$ECHO2SUF" # these are defined later 18 } 19 20 exists () { # because some shells don't have test -e 21 if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then 22 return 0 23 else 24 return 1 25 fi 26 } 27 28 Load_Cache () { 29 if [ -f $SOURCE_DIR/config.cache -a -r $SOURCE_DIR/config.cache -a ! "$IGNORE_CACHE" ] ; then 30 echo "Using defaults from config.cache. To ignore, $SOURCE_DIR/Config -nocache" 31 echo "" 32 . $SOURCE_DIR/config.cache 33 CAN_QUICK="yes" 34 else 35 CAN_QUICK="no" 36 fi 37 } 38 39 Run_Build_System () { 40 WITH_INST="" 41 WITH_RUN="" 42 WITH_PERM="" 43 EXTRA_INCLUDE="" 44 EXTRA_LIBS="" 45 GEN_TYPE="" 46 47 if [ "$INSTDIR" != "" ] ; then 48 WITH_INST="-DINSTDIR:STRING=$INSTDIR" 49 fi 50 51 if [ "$RUNGROUP" != "" ] ; then 52 WITH_RUN="-DRUNGROUP:STRING=$RUNGROUP" 53 fi 54 55 if [ "$UMASK" != "" ] ; then 56 WITH_PERM="-DDEFUMASK:STRING=$UMASK" 57 fi 58 59 if [ "$DEBUG" = "yes" ] ; then 60 BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=DEBUG" 61 else 62 BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=RELEASE" 63 fi 64 65 if [ "$USE_PCH" = "yes" ] ; then 66 PCH="-DUSE_PCH:BOOLEAN=ON" 67 else 68 PCH="-DUSE_PCH:BOOLEAN=OFF" 69 fi 70 71 if [ "$EXTRA_INCLUDE_DIRS" != "" ] ; then 72 EXTRA_INCLUDE="-DEXTRA_INCLUDE:STRING=$EXTRA_INCLUDE_DIRS" 73 fi 74 75 if [ "$EXTRA_LIB_DIRS" != "" ] ; then 76 EXTRA_LIBS="-DEXTRA_LIBS:STRING=$EXTRA_LIB_DIRS" 77 fi 78 79 case `uname -s` in 80 MINGW*) 81 GEN_TYPE="-G\"MSYS Makefiles\"" 82 ;; 83 esac 84 85 if [ "$SOURCE_DIR" = "." ] ; then 86 pwdsave=`pwd` 87 test -d build || mkdir build 88 cd "build" 89 REAL_SOURCE_DIR=".." 90 else 91 REAL_SOURCE_DIR="$SOURCE_DIR" 92 fi 93 94 echo "cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $PCH $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR" 95 96 cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $PCH $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR 97 if [ $? -ne 0 ]; then 98 echo "You should fix these issues and then run ./Config -quick to rerun CMake." 99 exit 1 100 fi 101 102 echo "" 103 if [ "$SOURCE_DIR" = "." ] ; then 104 echo "Now cd build, then run make to build Anope." 105 cd "$pwdsave" 106 else 107 echo "Now run make to build Anope." 108 fi 109 } 110 111 ECHO2SUF='' 112 if [ "`echo -n a ; echo -n b`" = "ab" ] ; then 113 ECHO2='echo -n' 114 elif [ "`echo 'a\c' ; echo 'b\c'`" = "ab" ] ; then 115 ECHO2='echo' ; ECHO2SUF='\c' 116 elif [ "`printf 'a' 2>&1 ; printf 'b' 2>&1`" = "ab" ] ; then 117 ECHO2='printf "%s"' 118 else 119 # oh well... 120 ECHO2='echo' 121 fi 122 export ECHO2 ECHO2SUF 123 124 ########################################################################### 125 # Init values 126 ########################################################################### 127 128 INSTDIR=$HOME/services 129 RUNGROUP= 130 UMASK= 131 DEBUG="no" 132 USE_PCH="no" 133 EXTRA_INCLUDE_DIRS= 134 EXTRA_LIB_DIRS= 135 EXTRA_CONFIG_ARGS= 136 CAN_QUICK="no" 137 SOURCE_DIR=`dirname $0` 138 139 ########################################################################### 140 # Check out the options 141 ########################################################################### 142 143 while [ $# -ge 1 ] ; do 144 if [ $1 = "--help" ] ; then 145 echo "Config utility for Anope" 146 echo "------------------------" 147 echo "Syntax: ./Config [options]" 148 echo "-nocache Ignore settings saved in config.cache" 149 echo "-nointro Skip intro (disclaimer, etc)" 150 echo "-quick Skip questions, go straight to cmake" 151 exit 0 152 elif [ $1 = "-devel" ] ; then 153 DEBUG="yes" 154 INSTDIR="$PWD/run" 155 elif [ $1 = "-nocache" ] ; then 156 IGNORE_CACHE="1" 157 elif [ $1 = "-nointro" ] ; then 158 NO_INTRO="1" 159 elif [ $1 = "-quick" -o $1 = "-q" ] ; then 160 Load_Cache 161 if [ "$CAN_QUICK" = "yes" ] ; then 162 Run_Build_System 163 else 164 echo "" 165 echo "Can't find cache file (config.cache), aborting..." 166 fi 167 exit 0 168 fi 169 shift 1 170 done 171 172 ########################################################################### 173 # Check for CMake and (optionally) install it 174 ########################################################################### 175 176 cmake --version 2>&1 > /dev/null 177 if [ $? -ne 0 ] ; then 178 clear 179 echo "Anope requires CMake 2.4 or newer, which can be downloaded at https://cmake.org/ or through your system's package manager." 180 echo "If you have installed CMake already, ensure it is in your PATH environment variable." 181 exit 0 182 fi 183 184 ########################################################################### 185 186 if [ ! "$NO_INTRO" ] ; then 187 case `uname -s` in 188 MINGW*) 189 PAGER=less 190 ;; 191 *) 192 PAGER=more 193 clear 194 ;; 195 esac 196 . $SOURCE_DIR/src/version.sh 197 cat $SOURCE_DIR/.BANNER | sed "s/CURVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_EXTRA/" | sed "s@SOURCE_DIR@$SOURCE_DIR@" | $PAGER 198 echo "" 199 else 200 echo "" 201 fi 202 203 echo "Beginning Services configuration." 204 echo "" 205 206 ########################################################################### 207 # Load the cache 208 ########################################################################### 209 210 if [ ! "$IGNORE_CACHE" ] ; then 211 Load_Cache 212 fi 213 214 # Ask the user anything we need to know ahead of time. 215 216 export ok INPUT 217 218 #### 219 220 ok=0 221 echo "In what directory should Anope be installed?" 222 while [ $ok -eq 0 ] ; do 223 echo2 "[$INSTDIR] " 224 if read INPUT ; then : ; else echo "" ; exit 1 ; fi 225 if [ ! "$INPUT" ] ; then 226 INPUT=$INSTDIR 227 fi 228 if [ ! -d "$INPUT" ] ; then 229 if exists "$INPUT" ; then 230 echo "$INPUT exists, but is not a directory!" 231 else 232 echo "$INPUT does not exist. Create it?" 233 echo2 "[y] " 234 read YN 235 if [ "$YN" != "n" ] ; then 236 if mkdir -p $INPUT ; then 237 ok=1 238 fi 239 fi 240 fi 241 elif exists "$INPUT/include/services.h" ; then 242 echo "You cannot use the Services source directory as a target directory." 243 else 244 ok=1 245 fi 246 done 247 INSTDIR=$INPUT 248 echo "" 249 250 #### 251 252 OLD_RUNGROUP="$RUNGROUP" 253 if [ "$RUNGROUP" ] ; then 254 echo "Which group should all Services data files be owned by? (If Services" 255 echo "should not force files to be owned by a particular group, type \"none\"" 256 echo "(without the quotes) and press Return.)" 257 else 258 echo "Which group should all Services data files be owned by? (If Services" 259 echo "should not force files to be owned by a particular group, just press" 260 echo "Return.)" 261 fi 262 echo2 "[$RUNGROUP] " 263 if read INPUT ; then : ; else echo "" ; exit 1 ; fi 264 if [ "$INPUT" ] ; then 265 if [ "$INPUT" = "none" ] ; then 266 RUNGROUP="" 267 else 268 RUNGROUP="$INPUT" 269 fi 270 fi 271 echo "" 272 273 #### 274 275 if [ ! "$UMASK" -o "$RUNGROUP" != "$OLD_RUNGROUP" ] ; then 276 if [ "$RUNGROUP" ] ; then 277 UMASK=007 278 else 279 UMASK=077 280 fi 281 fi 282 283 ok=0 284 echo "What should the default umask for data files be (in octal)?" 285 echo "(077 = only accessible by owner; 007 = accessible by owner and group)" 286 while [ $ok -eq 0 ] ; do 287 echo2 "[$UMASK] " 288 if read INPUT ; then : ; else echo "" ; exit 1 ; fi 289 if [ ! "$INPUT" ] ; then 290 INPUT=$UMASK 291 fi 292 if [ `echo "$INPUT" | grep -c '[^0-7]'` -gt 0 ] ; then 293 echo "$UMASK is not a valid octal number!" 294 else 295 if [ "`echo $INPUT | cut -c1`" != "0" ] ; then 296 INPUT=0$INPUT 297 fi 298 ok=1 299 fi 300 done 301 UMASK=$INPUT 302 echo "" 303 304 #### 305 306 TEMP_YN="n" 307 if [ "$DEBUG" = "yes" ] ; then 308 TEMP_YN="y" 309 fi 310 echo "Would you like to build a debug version of Anope?" 311 echo2 "[$TEMP_YN] " 312 read YN 313 if [ "$YN" ] ; then 314 if [ "$YN" = "y" ] ; then 315 DEBUG="yes" 316 else 317 DEBUG="no" 318 fi 319 fi 320 echo "" 321 322 #### 323 324 TEMP_YN="n" 325 if [ "$USE_PCH" = "yes" ] ; then 326 TEMP_YN="y" 327 fi 328 echo "Do you want to build using precompiled headers? This can speed up" 329 echo "the build, but uses more disk space." 330 echo2 "[$TEMP_YN] " 331 read YN 332 if [ "$YN" ] ; then 333 if [ "$YN" = "y" ] ; then 334 USE_PCH="yes" 335 else 336 USE_PCH="no" 337 fi 338 fi 339 echo "" 340 341 #### 342 343 echo "Are there any extra include directories you wish to use?" 344 echo "You may only need to do this if CMake is unable to locate" 345 echo "missing dependencies without hints." 346 echo "Separate directories with semicolons." 347 echo "If you need no extra include directories, enter NONE in all caps." 348 echo2 "[$EXTRA_INCLUDE_DIRS] " 349 if read INPUT ; then : ; else echo "" ; exit 1 ; fi 350 if [ "$INPUT" ] ; then 351 if [ "$INPUT" = "NONE" ] ; then 352 EXTRA_INCLUDE_DIRS="" 353 else 354 EXTRA_INCLUDE_DIRS=$INPUT 355 fi 356 fi 357 echo "" 358 359 #### 360 361 echo "Are there any extra library directories you wish to use?" 362 echo "You may only need to do this if CMake is unable to locate" 363 echo "missing dependencies without hints." 364 echo "Separate directories with semicolons." 365 echo "If you need no extra library directories, enter NONE in all caps." 366 echo2 "[$EXTRA_LIB_DIRS] " 367 if read INPUT ; then : ; else echo "" ; exit 1 ; fi 368 if [ "$INPUT" ] ; then 369 if [ "$INPUT" = "NONE" ] ; then 370 EXTRA_LIB_DIRS="" 371 else 372 EXTRA_LIB_DIRS=$INPUT 373 fi 374 fi 375 echo "" 376 377 #### 378 379 echo "Are there any extra arguments you wish to pass to CMake?" 380 echo "If you need no extra arguments to CMake, enter NONE in all caps." 381 echo2 "[$EXTRA_CONFIG_ARGS] " 382 if read INPUT ; then : ; else echo "" ; exit 1 ; fi 383 if [ "$INPUT" ] ; then 384 if [ "$INPUT" = "NONE" ] ; then 385 EXTRA_CONFIG_ARGS="" 386 else 387 EXTRA_CONFIG_ARGS=$INPUT 388 fi 389 fi 390 echo "" 391 392 #### 393 394 ################################################################################ 395 # Store values 396 ################################################################################ 397 398 echo2 "Saving configuration results in config.cache... " 399 400 cat <<EOT >$SOURCE_DIR/config.cache 401 INSTDIR="$INSTDIR" 402 RUNGROUP="$RUNGROUP" 403 UMASK=$UMASK 404 DEBUG="$DEBUG" 405 USE_PCH="$USE_PCH" 406 EXTRA_INCLUDE_DIRS="$EXTRA_INCLUDE_DIRS" 407 EXTRA_LIB_DIRS="$EXTRA_LIB_DIRS" 408 EXTRA_CONFIG_ARGS="$EXTRA_CONFIG_ARGS" 409 EOT 410 echo "done." 411 412 413 ################################################################################ 414 # Build the build system string 415 ################################################################################ 416 417 Run_Build_System