
1: #!/bin/sh 2: # configure - home-grown configuration script for bsd-games. 3: # 4: # Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Joseph Samuel Myers. 5: # All rights reserved. 6: # 7: # Redistribution and use in source and binary forms, with or without 8: # modification, are permitted provided that the following conditions 9: # are met: 10: # 1. Redistributions of source code must retain the above copyright 11: # notice, this list of conditions and the following disclaimer. 12: # 2. Redistributions in binary form must reproduce the above copyright 13: # notice, this list of conditions and the following disclaimer in the 14: # documentation and/or other materials provided with the distribution. 15: # 3. The name of the author may not be used to endorse or promote products 16: # derived from this software without specific prior written permission. 17: # 18: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19: # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20: # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21: # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22: # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23: # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24: # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25: # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26: # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28: # SUCH DAMAGE. 29: 30: # Default paths follow Filesystem Hierarchy Standard version 2.0. 31: 32: # This will only ask some questions if the previous answers are appropriate. 33: # It will substitute values in the directories built in, and the main 34: # GNUmakefile. 35: 36: # Allow defaults to be given by a script 37: if [ -e ./config.params ]; then 38: . ./config.params 39: fi 40: 41: subst_vars=srcdir 42: 43: srcdir="`pwd`" 44: 45: ask () { 46: long_query="$1" 47: query_var="$2" 48: dflt_var="bsd_games_cfg_$query_var" 49: eval default=\"\$\{${dflt_var}-\$3\}\" 50: printf "%s [%s] " "$long_query" "$default" 51: if [ "x$bsd_games_cfg_non_interactive" = xy ]; then 52: # Follow default 53: input='' 54: echo "[ Using default ]" 55: else 56: read input 57: fi 58: case "$input" in 59: ('') 60: input="$default" 61: ;; 62: (*) 63: ;; 64: esac 65: eval $query_var=\"\$input\" 66: subst_vars="$subst_vars $query_var" 67: } 68: 69: ask_yn () { 70: eval $2= 71: eval answer=\$$2 72: while test "x$answer" = x; do 73: ask "$1" $2 $3 74: eval answer=\$$2 75: case "$answer" in 76: ([yY]*) 77: answer=y 78: ;; 79: ([nN]*) 80: answer=n 81: ;; 82: (*) 83: answer= 84: echo "Please answer y or n" 85: ;; 86: esac 87: done 88: eval $2=\$answer 89: } 90: 91: askperms () { 92: filetype=$1 93: var_prefix=$2 94: def_owner=$3 95: def_group=$4 96: def_perms=$5 97: if [ $do_chown = y ]; then 98: ask "$filetype owner" ${var_prefix}_owner $def_owner 99: ask "$filetype group" ${var_prefix}_group $def_group 100: fi 101: ask "$filetype permissions" ${var_prefix}_perms $def_perms 102: if [ $do_chown = y ]; then 103: eval install_$var_prefix=\"install -c -m \$${var_prefix}_perms -o \$${var_prefix}_owner -g \$${var_prefix}_group\" 104: else 105: eval install_$var_prefix=\"install -c -m \$${var_prefix}_perms\" 106: fi 107: subst_vars="$subst_vars install_$var_prefix" 108: } 109: 110: building_in () { 111: echo " $build_dirs " |grep -q " $1 " 112: } 113: 114: not_building_in () { 115: echo " $no_build_dirs " |grep -q " $1 " 116: } 117: 118: game_ask () { 119: game="$1" 120: if building_in "$game"; then 121: ask "$2" "$3" "$4" 122: fi 123: } 124: 125: check_func () { 126: funcname=$1 127: subst_vars="$subst_vars ${funcname}_defs" 128: cat >conftest.c 129: printf "Checking for %s..." "$funcname" 130: compiler="$cc $optimize_flags $other_cflags $other_ldflags" 131: if $compiler conftest.c >/dev/null 2>&1; then 132: echo "found." 133: echo "#define HAVE_$funcname 1" >>include/bsd-games.h 134: # Check whether we need _GNU_SOURCE for a prototype. 135: if $compiler -Wall -Werror conftest.c >/dev/null 2>&1; then 136: eval ${funcname}_defs= 137: else 138: # Prototype not in headers by default (try _GNU_SOURCE). 139: eval ${funcname}_defs=-D_GNU_SOURCE 140: fi 141: rm -f a.out conftest.c 142: true 143: else 144: echo "not found." 145: rm -f a.out conftest.c 146: eval ${funcname}_defs= 147: false 148: fi 149: } 150: 151: echo "For normal usage the installation prefix will be empty. If you wish" 152: echo "to install everything in another directory to that in which it will" 153: echo "finally be located (so that your packaging system can then move it" 154: echo "there) you should name that directory here. This is most likely to" 155: echo "be the case if you are packaging bsd-games for a Linux distribution." 156: ask "Installation prefix" install_prefix '' 157: 158: echo "There may be some programs here you have from another package and so" 159: echo "do not want to build and install. The most likely ones are banner," 160: echo "factor and fortune." 161: 162: ask "Games not to build" no_build_dirs '' 163: 164: # Normalise white space in no_build_dirs 165: no_build_dirs="`echo $no_build_dirs`" 166: 167: def_build_dirs= 168: for file in *; do 169: if [ -e "$file/Makefrag" ] && ! not_building_in "$file" && [ "$file" != lib ]; then 170: def_build_dirs="$def_build_dirs $file" 171: fi 172: done 173: def_build_dirs=${def_build_dirs## } 174: 175: ask "Games to build" build_dirs "$def_build_dirs" 176: 177: # Normalise white space in build_dirs 178: build_dirs="`echo $build_dirs`" 179: 180: echo 181: echo "*** NOTE - The default directories for installation follow the" 182: echo "*** Filesystem Hierarchy Standard version 2.0 (FHS). If your" 183: echo "*** system still uses the older FSSTND 1.2, or if you wish to install" 184: echo "*** under /usr/local, you will need to check the paths and make" 185: echo "*** changes as appropriate. If this is your first installation with" 186: echo "*** the new FHS paths, you may need to remove some old files after" 187: echo "*** installation." 188: echo 189: 190: ask "Games directory" gamesdir /usr/games 191: 192: # We put huntd in /usr/games by default (instead of /usr/sbin as earlier, 193: # or /usr/lib) since it can reasonably be called by users and counts 194: # properly more as a game than an ordinary user binary. 195: if building_in hunt; then 196: echo 197: echo "Hunt includes a daemon for coordinating games with multiple players" 198: ask "Daemon directory" sbindir /usr/games 199: else 200: sbindir= 201: subst_vars="$subst_vars sbindir" 202: fi 203: if building_in fortune; then 204: echo 205: echo "Fortune includes a non-game utility strfile" 206: ask "Non-game binary directory" usrbindir /usr/bin 207: else 208: usrbindir= 209: subst_vars="$subst_vars usrbindir" 210: fi 211: 212: hidegame=: 213: subst_vars="$subst_vars hidegame" 214: if building_in dm; then 215: echo 216: echo "You may wish to restrict the use of games by user, terminal, load," 217: echo "etc.. This can be done by the use of dm. If you use this" 218: echo "configuration, then games will be kept in a non-world-searchable" 219: echo "directory such as /usr/lib/games/dm and replaced by symlinks to dm." 220: echo "Even if you don't choose this option, you will still be asked" 221: echo "for the directory name, since you are building dm, and can change" 222: echo "manually later. It is strongly recommended that you keep the" 223: echo "default answer of 'n'." 224: ask_yn "Use dm and hide games" use_dm n 225: # The default location is now /usr/lib/games/dm to conform to FHS 2.0. 226: ask "Directory for hidden games" libexecdir /usr/lib/games/dm 227: if [ "$use_dm" = y ]; then 228: hidegame=$srcdir/hide-game 229: fi 230: fi 231: ask "Section 6 manpage directory" man6dir /usr/share/man/man6 232: if building_in dm || building_in fortune; then 233: ask "Section 8 manpage directory" man8dir /usr/share/man/man8 234: else 235: man8dir= 236: subst_vars="$subst_vars man8dir" 237: fi 238: if building_in dm; then 239: ask "Section 5 manpage directory" man5dir /usr/share/man/man5 240: else 241: man5dir= 242: subst_vars="$subst_vars man5dir" 243: fi 244: 245: if building_in trek || building_in rogue; then 246: ask "Directory for miscellaneous documentation" docdir /usr/share/doc/bsd-games 247: else 248: docdir= 249: subst_vars="$subst_vars docdir" 250: fi 251: 252: # The paths for data are as per the FHS. If a future version removes the 253: # games ghettoes of /usr/games, /var/games, etc., then a subdirectory for 254: # this package (/usr/share/bsdgames, /var/state/bsdgames, etc.) would be 255: # desirable, but I don't feel it necessary at present. 256: 257: ask "Library directory for constant data 258: (architecture independent)" sharedir /usr/share/games 259: ask "Library directory for variable data" varlibdir /var/games 260: 261: ask_yn "Set owners/groups on installed files" do_chown y 262: 263: echo 264: echo "See SECURITY for a discussion of security issues related to score files." 265: echo "There are at least two possible security policies if you want them to" 266: echo "work. You can make the files world-writable, and then anyone who wants" 267: echo "can put anything in them, which may not be desirable if you think people" 268: echo "might cheat this way. Or you can make the games that use them setgid" 269: echo "games, and give the files permissions 0664. Note, however, that some" 270: echo "of the games may well be insecure when this is done and" 271: echo "malicious users may still be able to overwrite anything writable by" 272: echo "group games, since the games were probably not designed with security in" 273: echo "mind, although version 2.2 is more secure than earlier versions." 274: echo "The default is neither of these: it creates scorefiles with" 275: echo "permissions 0644 and gives the games no special privileges, which is" 276: echo "more secure but means that the games will fail when trying to write" 277: echo "to their scorefiles." 278: 279: askperms "Binary" binary root root 0755 280: askperms "Game with scorefile" score_game root root 0755 # or root games 2755? 281: if building_in hunt; then 282: askperms "Daemon" daemon root root 0755 283: fi 284: if building_in dm; then 285: askperms "Directory for hidden games" dmdir root games 0750 286: install_dmdir=`echo "$install_dmdir"| sed 's/install -c/install -d/'` 287: askperms "dm" dm root games 2755 288: fi 289: askperms "Manpage" manpage root root 0644 290: askperms "Constant data" constdata root root 0644 291: askperms "Variable data" vardata root root 0644 # or 0666? 292: 293: ask "Permissions on variable data that should not be world readable" vardata_perms_priv 0640 294: 295: use_dot_so= 296: while test x$use_dot_so = x; do 297: ask "Use .so or symlinks for manpages" use_dot_so .so 298: case "$use_dot_so" in 299: (.so) 300: ;; 301: (syml*) 302: use_dot_so=symlinks 303: ;; 304: (*) 305: use_dot_so= 306: echo "Please answer \`.so\' or \`symlinks\'" 307: ;; 308: esac 309: done 310: subst_vars="$subst_vars use_dot_so" 311: 312: ask_yn "Gzip manpages" gzip_manpages y 313: 314: # What we do with manpages is a bit complicated. If either ppt or morse is 315: # being built, we must also install the bcd manpage, even if bcd isn't being 316: # built. We then need to do either .so or symlink. This should all be handled 317: # by the install-man.in script, but the installation of linked-to manpages 318: # isn't implemented yet. 319: 320: # Copy install_binary to install_script 321: install_script="$install_binary" 322: subst_vars="$subst_vars install_script" 323: 324: echo 325: echo "It is presumed in some places by the Makefiles that the compiler" 326: echo "will be some form of gcc." 327: ask "C compiler" cc gcc 328: if building_in dab; then 329: ask "C++ compiler" cxx g++ 330: fi 331: ask "Optimize flags" optimize_flags "-g -O2" 332: echo 333: echo "The default warning flags should give a compile with few warnings." 334: # -Wbad-function-cast and -Wshadow give lots of warnings that are basically 335: # harmless. 336: ask "C compiler warning flags" warning_flags "-Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings" 337: if building_in dab; then 338: ask "C++ compiler warning flags" cxx_warning_flags "-Wall -W -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings" 339: fi 340: echo 341: echo "You probably want the default here, or could use -lncurses_g for" 342: echo "debugging ncurses. Use -lcurses -ltermcap if you want to try that," 343: echo "but note that this is no longer supported and may not work." 344: ask "Ncurses library" ncurses_lib -lncurses 345: echo 346: echo "If you have a directory /usr/include/ncurses with the ncurses include" 347: echo "files in it, and the <curses.h>, <termcap.h>, etc. in /usr/include" 348: echo "are for BSD curses/termcap, you will need to put -I/usr/include/ncurses" 349: echo "here. Otherwise (if the ncurses includes are in /usr/include), leave" 350: echo "this blank. Leave it blank if /usr/include/ncurses is a symbolic link" 351: echo "to /usr/include." 352: ask "Ncurses includes" ncurses_includes '' 353: 354: openssl_lib= 355: openssl_includes= 356: if building_in factor; then 357: echo 358: echo "factor can use libcrypto from OpenSSL to handle large numbers." 359: ask_yn "Use libcrypto" use_libcrypto y 360: if [ $use_libcrypto = y ]; then 361: echo "If the OpenSSL includes (with files such as bn.h) are not in" 362: echo "/usr/include/openssl, then you will need to specify a -I option" 363: echo "here, naming a directory containing an \"openssl\" subdirectory" 364: echo "with the OpenSSL headers." 365: ask "OpenSSL includes" openssl_includes '' 366: echo "If the OpenSSL libcrypto library is not in a location searched" 367: echo "by the compiler by default, or has a strange name, you will" 368: echo "need to specify the appropriate options to find it here" 369: echo "(for example, -L/usr/ssl/lib -lcrypto); otherwise, leave the" 370: echo "default, which is probably correct." 371: ask "OpenSSL libcrypto library" openssl_lib -lcrypto 372: fi 373: fi 374: subst_vars="$subst_vars openssl_lib openssl_includes" 375: 376: ask "Other CFLAGS" other_cflags '' 377: ask "Other LDFLAGS" other_ldflags '' 378: 379: # Check for functions - not in glibc 2.1.1, but could be added later. 380: echo "#ifndef LINUX_BSD_GAMES_H" >include/bsd-games.h 381: echo "#define LINUX_BSD_GAMES_H 1" >>include/bsd-games.h 382: 383: if [ "$use_libcrypto" = "y" ]; then 384: echo "#define HAVE_OPENSSL 1" >>include/bsd-games.h 385: fi 386: 387: check_func getloadavg <<EOF 388: #include <stdlib.h> 389: 390: int 391: main(void) 392: { 393: double la[3]; 394: getloadavg(la, 3); 395: return 0; 396: } 397: EOF 398: 399: check_func fgetln <<EOF 400: #include <stdio.h> 401: 402: int 403: main(void) 404: { 405: char *f; 406: size_t l; 407: f = fgetln(stdin, &l); 408: return 0; 409: } 410: EOF 411: 412: check_func strlcpy <<EOF 413: #include <string.h> 414: 415: int 416: main(void) 417: { 418: char s[1] = ""; 419: char d[1]; 420: strlcpy(d, s, 1); 421: return 0; 422: } 423: EOF 424: 425: check_func sig_t <<EOF 426: #include <signal.h> 427: 428: sig_t s; 429: 430: int 431: main(void) 432: { 433: return 0; 434: } 435: EOF 436: 437: check_func getprogname <<EOF 438: #include <stdlib.h> 439: 440: int 441: main(void) 442: { 443: const char *n = getprogname(); 444: return 0; 445: } 446: EOF 447: 448: echo "#endif /* !defined(LINUX_BSD_GAMES_H) */" >>include/bsd-games.h 449: 450: 451: echo 452: echo "For some special purposes you may want to link all games with a" 453: echo "particular library, in addition to those they would normally be linked" 454: echo "with. Unless you know you want this, you can leave it empty." 455: ask "Base libraries" base_libs '' 456: 457: if building_in atc; then 458: ask "Yacc program" yacc "bison -y" 459: fi 460: if building_in atc; then 461: ask "Lex program" lex flex 462: ask "Lex library" lex_lib -lfl 463: fi 464: 465: echo 466: echo "You can choose the default pager for those games that use one (for" 467: echo "example, for viewing instructions). This can be an absolute path," 468: echo "or the name of the pager to be searched for via the PATH at runtime." 469: echo "All these games will also honour the PAGER environment variable if set," 470: echo "in the correct (POSIX.2) way." 471: ask "Pager" pager /usr/bin/less 472: 473: if building_in fortune; then 474: echo 475: echo "Fortune comes with some potentially offensive fortunes. You should" 476: echo "only install these if you are sure that your users want them." 477: ask_yn "Install offensive fortunes" offensive_fortunes n 478: if [ $offensive_fortunes = y ]; then 479: fortune_type=real 480: else 481: fortune_type=fake 482: fi 483: subst_vars="$subst_vars fortune_type" 484: fi 485: 486: if building_in sail; then 487: echo 488: echo "Sail needs its own directory it can write to for temporary files" 489: echo "to synchronise among multiple players. Note that with the" 490: echo "default permissions given here this will not work: you may want" 491: echo "to choose permissions appropriate to the security policy you are" 492: echo "using. It may be more secure if this directory is not world" 493: echo "accessible (e.g. mode 2770)." 494: ask "Directory for sail temporary files" sail_dir "$varlibdir/sail" 495: askperms "Sail directory" sail_dir root root 0750 496: install_sail_dir=`echo "$install_sail_dir" |sed 's/install -c/install -d/'` 497: fi 498: 499: echo 500: echo "You can configure the exact names used for data files by various" 501: echo "of the games. Most probably the defaults are OK." 502: echo 503: echo "Note that bsd-games no longer comes with its own word list." 504: echo "For hangman you should specify the path to a word list to be read" 505: echo "at runtime (probably /usr/share/dict/words or /usr/dict/words)." 506: echo "For boggle you should specify one to be used at compile time to" 507: echo "generate boggle's own data. In both cases they should probably be" 508: echo "English dictionaries; all words which do not consist entirely of" 509: echo "lower-case ASCII letters will be silently ignored." 510: echo 511: game_ask atc "Directory for atc static data" atc_dir "$sharedir/atc" 512: game_ask atc "Score file for atc" atc_scorefile "$varlibdir/atc_score" 513: game_ask battlestar "Score file for battlestar" battlestar_scorefile "$varlibdir/battlestar.log" 514: # Bog has some other configuration 515: game_ask boggle "Dictionary for boggle (CHECK ANSWER)" dictionary_src /usr/share/dict/words 516: game_ask boggle "Directory for boggle static data" boggle_dir "$sharedir/boggle" 517: game_ask canfield "Score file for canfield" canfield_scorefile "$varlibdir/cfscores" 518: game_ask cribbage "File for cribbage instructions" cribbage_instrfile "$sharedir/cribbage.instr" 519: game_ask cribbage "Score file for cribbage" cribbage_scorefile "$varlibdir/criblog" 520: game_ask dm "Configuration file for dm" dm_configfile /etc/dm.conf 521: game_ask dm "File to disable games playing" dm_nogamesfile /etc/nogames 522: game_ask dm "Log file for dm" dm_logfile "$varlibdir/games.log" 523: game_ask fish "File for fish instructions" fish_instrfile "$sharedir/fish.instr" 524: game_ask fortune "Directory for fortune files" fortune_dir "$sharedir/fortune" 525: game_ask hack "Directory for hack variable data" hack_dir "$varlibdir/hack" 526: 527: if building_in hack; then 528: echo 529: echo "This directory will need to be writable by hack at runtime." 530: echo "Note that with the default permissions given here this will" 531: echo "not work: you may want to choose permissions appropriate to the" 532: echo "security policy you are using (e.g. 2775 root.games for setgid" 533: echo "games)." 534: askperms "Hack directory" hack_dir root root 0755 535: install_hack_dir=`echo "$install_hack_dir" |sed 's/install -c/install -d/'` 536: fi 537: 538: game_ask hangman "Words file for hangman (CHECK ANSWER)" hangman_wordsfile /usr/share/dict/words 539: # Hunt has some other configuration 540: game_ask monop "File for monop cards" monop_cardsfile "$sharedir/monop-cards.pck" 541: game_ask phantasia "Directory for phantasia variable data" phantasia_dir "$varlibdir/phantasia" 542: game_ask quiz "Directory for quiz static data" quiz_dir "$sharedir/quiz" 543: game_ask robots "Score file for robots" robots_scorefile "$varlibdir/robots_roll" 544: game_ask rogue "Score file for rogue" rogue_scorefile "$varlibdir/rogue.scores" 545: game_ask sail "Score file for sail" sail_scorefile "$varlibdir/saillog" 546: game_ask snake "Score file for snake" snake_scorefile "$varlibdir/snake.log" 547: game_ask snake "Raw score file for snake" snake_rawscorefile "$varlibdir/snakerawscores" 548: game_ask tetris "Score file for tetris" tetris_scorefile "$varlibdir/tetris-bsd.scores" 549: game_ask wtf "Acronym database for wtf" wtf_acronymfile "/usr/share/misc/acronyms" 550: game_ask wump "File for wump info" wump_infofile "$sharedir/wump.info" 551: 552: # Generate simplistic substitution script. 553: # This does not allow escaped @s in the substituted file, will fail on 554: # newline or % in filenames, etc.. The justification is that proper insertion 555: # of arbitrary 8-bit data in different files requires too much knowledge 556: # of escapes specific to the particular file type, so these things would 557: # probably fail anyway. 558: : >subst.sed 559: for var in $subst_vars; do 560: eval echo \""s%@$var@%\$$var%g"\" >> subst.sed 561: done 562: 563: substitute () { 564: for file in "$@"; do 565: dir="${file%%/*}" 566: if building_in $dir || [ "$file" = "$dir" ]; then 567: source_file="${file}.in" 568: case "$file" in 569: (quiz/datfiles/index) 570: # Can't put a comment in this file 571: subst_type=n 572: ;; 573: (Makeconfig) 574: subst_type=h 575: ;; 576: (*.[1-9]) 577: subst_type=m 578: ;; 579: (*.[ch]) 580: subst_type=c 581: ;; 582: (*) 583: subst_type=s 584: ;; 585: esac 586: if [ "$rules_only" = y ]; then 587: ./substscr r "$subst_type" "$source_file" "$file" 588: else 589: ./substscr gr "$subst_type" "$source_file" "$file" 590: fi 591: fi 592: done 593: } 594: 595: : >subst.rules 596: 597: rules_only=n 598: subst_files="`sed '/^#/d' <substfiles`" 599: 600: substitute $subst_files 601: 602: rules_only=y 603: subst_files="`sed '/^#/d' <substfiles2`" 604: 605: substitute $subst_files 606: 607: # Now we want to create the main GNUmakefile that includes the subdirectory 608: # fragments and all the necessary dependencies. This may take some time. 609: 610: echo "Generating the main GNUmakefile, please wait..." 611: 612: prog_to_exec () { 613: if [ "x$(dirname $1)" = x. ]; then 614: echo "$1/$1" 615: else 616: echo "$1" 617: fi 618: } 619: 620: slashdot_to_under () { 621: echo "$1" |sed 's:/:_:g' |sed 's:\.:_:g' 622: } 623: 624: exec_to_libs () { 625: eval echo \$$(slashdot_to_under $1)_libs 626: } 627: 628: exec_to_objs () { 629: eval echo \$$(slashdot_to_under $1)_objs 630: } 631: 632: make_dirs_tmp="$(find $build_dirs -depth -type d) lib" 633: 634: make_dirs= 635: 636: for dir in $make_dirs_tmp; do 637: if [ -e $dir/Makefrag ]; then 638: make_dirs="$make_dirs $dir" 639: fi 640: done 641: 642: all_dependencies= 643: 644: for dir in $make_dirs; do 645: udir=$(slashdot_to_under $dir) 646: all_dependencies="$all_dependencies ${udir}_all" 647: done 648: 649: cat >GNUmakefile <<EOF 650: # GNUmakefile - automatically generated by configure. Do not edit. 651: 652: # No suffix rules 653: .SUFFIXES: 654: 655: # Include configuration 656: include Makeconfig 657: 658: .PHONY: all $all_dependencies 659: all: $all_dependencies 660: 661: # Include substitution rules. 662: include subst.rules 663: 664: EOF 665: 666: for dir in $make_dirs; do 667: udir=$(slashdot_to_under $dir) 668: eval clean_$udir= 669: if [ $dir = dab ]; then 670: cat >>GNUmakefile <<EOF 671: include $dir/Makefrag 672: 673: $dir/%.o: $dir/%.cc 674: \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@ 675: 676: $dir/%.ii: $dir/%.cc 677: \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@ 678: 679: $dir/%.s: $dir/%.cc 680: \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@ 681: 682: $dir/%.d: $dir/%.cc 683: ./mkdep \$< \$@ \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) 684: 685: EOF 686: else 687: cat >>GNUmakefile <<EOF 688: include $dir/Makefrag 689: 690: $dir/%.o: $dir/%.c 691: \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@ 692: 693: $dir/%.i: $dir/%.c 694: \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@ 695: 696: $dir/%.s: $dir/%.c 697: \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@ 698: 699: $dir/%.d: $dir/%.c 700: ./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) 701: 702: EOF 703: fi 704: done 705: 706: # This temporary file is needed because we don't know whether the last 707: # part of a pipeline is in the current shell execution environment 708: # (POSIX.2, 3.12 and rationale). 709: sed '/^#/d' <exec.libs >exec.libs.tmp 710: while read prog libs; do 711: if ! building_in ${prog%%/*}; then 712: continue 713: fi 714: exec=$(prog_to_exec $prog) 715: evar=$(slashdot_to_under $exec)_libs 716: eval $evar=\"\$libs\" 717: done <exec.libs.tmp 718: 719: sed '/^#/d' <exec.objs >exec.objs.tmp 720: while read prog objs; do 721: if ! building_in ${prog%%/*}; then 722: continue 723: fi 724: exec=$(prog_to_exec $prog) 725: evar=$(slashdot_to_under $exec)_libs 726: eval libs=\"\$$evar\" 727: dir=$(dirname $exec) 728: udir=$(slashdot_to_under $dir) 729: nobjs= 730: deps_to_inc= 731: eval clean_$udir=\"\$clean_$udir $(basename $exec)\" 732: for obj in $objs; do 733: if [ "x$(dirname $obj)" = x. ]; then 734: obj=$dir/$obj 735: fi 736: nobjs="$nobjs $obj" 737: obj_dep_var=$(slashdot_to_under $obj) 738: obj_dep_var=${obj_dep_var}_deps_included 739: eval obj_dep_val=\$$obj_dep_var 740: if [ "x$obj_dep_val" = "x" ]; then 741: deps_to_inc="$deps_to_inc ${obj%%.o}.d" 742: eval $obj_dep_var=y 743: fi 744: done 745: if [ $dir = dab ]; then 746: ccvar=CXX 747: else 748: ccvar=CC 749: fi 750: cat >>GNUmakefile <<EOF 751: ifneq (\$(nodep),true) 752: include $deps_to_inc 753: endif 754: 755: $exec: $nobjs 756: \$($ccvar) \$(LDFLAGS) \$^ $libs \$(BASE_LIBS) -o \$@ 757: 758: EOF 759: done <exec.objs.tmp 760: 761: rm -f exec.libs.tmp exec.objs.tmp 762: 763: clean_dependencies= 764: install_dependencies= 765: 766: for dir in $make_dirs; do 767: udir=$(slashdot_to_under $dir) 768: clean_dependencies="$clean_dependencies ${udir}_clean" 769: install_dependencies="$install_dependencies ${udir}_install" 770: eval clean=\"\$clean_$udir\" 771: cat >>GNUmakefile <<EOF 772: .PHONY: ${udir}_clean 773: ${udir}_clean: 774: cd $dir && rm -f -- a.out core *.o *.d *.i *.s *.d.tmp $clean \$(${udir}_CLEANFILES) 775: 776: .PHONY: ${udir}_install ${udir}_install-strip ${udir}_installdirs 777: ${udir}_install: ${udir}_installdirs 778: 779: ${udir}_install-strip: 780: \$(MAKE) ${udir}_install \$(DEFS_TO_PASS_STRIP) 781: 782: ${udir}_installdirs: 783: set -e; for d in \$(${udir}_DIRS) /; do mkdir -p \$(INSTALL_PREFIX)\$\$d; done 784: 785: EOF 786: done 787: 788: cat >>GNUmakefile <<EOF 789: .PHONY: clean mostlyclean distclean maintainer-clean 790: clean mostlyclean: $clean_dependencies 791: 792: distclean maintainer-clean: clean 793: rm -f subst.sed subst.rules 794: rm -f test.out 795: rm -f \`cat substfiles substfiles2 |sed '/^#/d'\` 796: rm -f GNUmakefile 797: rm -f a.out conftest.c include/bsd-games.h 798: rm -f exec.libs.tmp exec.objs.tmp 799: 800: .PHONY: install install-strip