configure 25 KB

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