5 kx #!/bin/sh
5 kx # configure - home-grown configuration script for bsd-games.
5 kx #
5 kx # Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Joseph Samuel Myers.
5 kx # All rights reserved.
5 kx #
5 kx # Redistribution and use in source and binary forms, with or without
5 kx # modification, are permitted provided that the following conditions
5 kx # are met:
5 kx # 1. Redistributions of source code must retain the above copyright
5 kx # notice, this list of conditions and the following disclaimer.
5 kx # 2. Redistributions in binary form must reproduce the above copyright
5 kx # notice, this list of conditions and the following disclaimer in the
5 kx # documentation and/or other materials provided with the distribution.
5 kx # 3. The name of the author may not be used to endorse or promote products
5 kx # derived from this software without specific prior written permission.
5 kx #
5 kx # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
5 kx # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
5 kx # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
5 kx # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
5 kx # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
5 kx # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5 kx # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
5 kx # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5 kx # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5 kx # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5 kx # SUCH DAMAGE.
5 kx
5 kx # Default paths follow Filesystem Hierarchy Standard version 2.0.
5 kx
5 kx # This will only ask some questions if the previous answers are appropriate.
5 kx # It will substitute values in the directories built in, and the main
5 kx # GNUmakefile.
5 kx
5 kx # Allow defaults to be given by a script
5 kx if [ -e ./config.params ]; then
5 kx . ./config.params
5 kx fi
5 kx
5 kx subst_vars=srcdir
5 kx
5 kx srcdir="`pwd`"
5 kx
5 kx ask () {
5 kx long_query="$1"
5 kx query_var="$2"
5 kx dflt_var="bsd_games_cfg_$query_var"
5 kx eval default=\"\$\{${dflt_var}-\$3\}\"
5 kx printf "%s [%s] " "$long_query" "$default"
5 kx if [ "x$bsd_games_cfg_non_interactive" = xy ]; then
5 kx # Follow default
5 kx input=''
5 kx echo "[ Using default ]"
5 kx else
5 kx read input
5 kx fi
5 kx case "$input" in
5 kx ('')
5 kx input="$default"
5 kx ;;
5 kx (*)
5 kx ;;
5 kx esac
5 kx eval $query_var=\"\$input\"
5 kx subst_vars="$subst_vars $query_var"
5 kx }
5 kx
5 kx ask_yn () {
5 kx eval $2=
5 kx eval answer=\$$2
5 kx while test "x$answer" = x; do
5 kx ask "$1" $2 $3
5 kx eval answer=\$$2
5 kx case "$answer" in
5 kx ([yY]*)
5 kx answer=y
5 kx ;;
5 kx ([nN]*)
5 kx answer=n
5 kx ;;
5 kx (*)
5 kx answer=
5 kx echo "Please answer y or n"
5 kx ;;
5 kx esac
5 kx done
5 kx eval $2=\$answer
5 kx }
5 kx
5 kx askperms () {
5 kx filetype=$1
5 kx var_prefix=$2
5 kx def_owner=$3
5 kx def_group=$4
5 kx def_perms=$5
5 kx if [ $do_chown = y ]; then
5 kx ask "$filetype owner" ${var_prefix}_owner $def_owner
5 kx ask "$filetype group" ${var_prefix}_group $def_group
5 kx fi
5 kx ask "$filetype permissions" ${var_prefix}_perms $def_perms
5 kx if [ $do_chown = y ]; then
5 kx eval install_$var_prefix=\"install -c -m \$${var_prefix}_perms -o \$${var_prefix}_owner -g \$${var_prefix}_group\"
5 kx else
5 kx eval install_$var_prefix=\"install -c -m \$${var_prefix}_perms\"
5 kx fi
5 kx subst_vars="$subst_vars install_$var_prefix"
5 kx }
5 kx
5 kx building_in () {
5 kx echo " $build_dirs " |grep -q " $1 "
5 kx }
5 kx
5 kx not_building_in () {
5 kx echo " $no_build_dirs " |grep -q " $1 "
5 kx }
5 kx
5 kx game_ask () {
5 kx game="$1"
5 kx if building_in "$game"; then
5 kx ask "$2" "$3" "$4"
5 kx fi
5 kx }
5 kx
5 kx check_func () {
5 kx funcname=$1
5 kx subst_vars="$subst_vars ${funcname}_defs"
5 kx cat >conftest.c
5 kx printf "Checking for %s..." "$funcname"
5 kx compiler="$cc $optimize_flags $other_cflags $other_ldflags"
5 kx if $compiler conftest.c >/dev/null 2>&1; then
5 kx echo "found."
5 kx echo "#define HAVE_$funcname 1" >>include/bsd-games.h
5 kx # Check whether we need _GNU_SOURCE for a prototype.
5 kx if $compiler -Wall -Werror conftest.c >/dev/null 2>&1; then
5 kx eval ${funcname}_defs=
5 kx else
5 kx # Prototype not in headers by default (try _GNU_SOURCE).
5 kx eval ${funcname}_defs=-D_GNU_SOURCE
5 kx fi
5 kx rm -f a.out conftest.c
5 kx true
5 kx else
5 kx echo "not found."
5 kx rm -f a.out conftest.c
5 kx eval ${funcname}_defs=
5 kx false
5 kx fi
5 kx }
5 kx
5 kx echo "For normal usage the installation prefix will be empty. If you wish"
5 kx echo "to install everything in another directory to that in which it will"
5 kx echo "finally be located (so that your packaging system can then move it"
5 kx echo "there) you should name that directory here. This is most likely to"
5 kx echo "be the case if you are packaging bsd-games for a Linux distribution."
5 kx ask "Installation prefix" install_prefix ''
5 kx
5 kx echo "There may be some programs here you have from another package and so"
5 kx echo "do not want to build and install. The most likely ones are banner,"
5 kx echo "factor and fortune."
5 kx
5 kx ask "Games not to build" no_build_dirs ''
5 kx
5 kx # Normalise white space in no_build_dirs
5 kx no_build_dirs="`echo $no_build_dirs`"
5 kx
5 kx def_build_dirs=
5 kx for file in *; do
5 kx if [ -e "$file/Makefrag" ] && ! not_building_in "$file" && [ "$file" != lib ]; then
5 kx def_build_dirs="$def_build_dirs $file"
5 kx fi
5 kx done
5 kx def_build_dirs=${def_build_dirs## }
5 kx
5 kx ask "Games to build" build_dirs "$def_build_dirs"
5 kx
5 kx # Normalise white space in build_dirs
5 kx build_dirs="`echo $build_dirs`"
5 kx
5 kx echo
5 kx echo "*** NOTE - The default directories for installation follow the"
5 kx echo "*** Filesystem Hierarchy Standard version 2.0 (FHS). If your"
5 kx echo "*** system still uses the older FSSTND 1.2, or if you wish to install"
5 kx echo "*** under /usr/local, you will need to check the paths and make"
5 kx echo "*** changes as appropriate. If this is your first installation with"
5 kx echo "*** the new FHS paths, you may need to remove some old files after"
5 kx echo "*** installation."
5 kx echo
5 kx
5 kx ask "Games directory" gamesdir /usr/games
5 kx
5 kx # We put huntd in /usr/games by default (instead of /usr/sbin as earlier,
5 kx # or /usr/lib) since it can reasonably be called by users and counts
5 kx # properly more as a game than an ordinary user binary.
5 kx if building_in hunt; then
5 kx echo
5 kx echo "Hunt includes a daemon for coordinating games with multiple players"
5 kx ask "Daemon directory" sbindir /usr/games
5 kx else
5 kx sbindir=
5 kx subst_vars="$subst_vars sbindir"
5 kx fi
5 kx if building_in fortune; then
5 kx echo
5 kx echo "Fortune includes a non-game utility strfile"
5 kx ask "Non-game binary directory" usrbindir /usr/bin
5 kx else
5 kx usrbindir=
5 kx subst_vars="$subst_vars usrbindir"
5 kx fi
5 kx
5 kx hidegame=:
5 kx subst_vars="$subst_vars hidegame"
5 kx if building_in dm; then
5 kx echo
5 kx echo "You may wish to restrict the use of games by user, terminal, load,"
5 kx echo "etc.. This can be done by the use of dm. If you use this"
5 kx echo "configuration, then games will be kept in a non-world-searchable"
5 kx echo "directory such as /usr/lib/games/dm and replaced by symlinks to dm."
5 kx echo "Even if you don't choose this option, you will still be asked"
5 kx echo "for the directory name, since you are building dm, and can change"
5 kx echo "manually later. It is strongly recommended that you keep the"
5 kx echo "default answer of 'n'."
5 kx ask_yn "Use dm and hide games" use_dm n
5 kx # The default location is now /usr/lib/games/dm to conform to FHS 2.0.
5 kx ask "Directory for hidden games" libexecdir /usr/lib/games/dm
5 kx if [ "$use_dm" = y ]; then
5 kx hidegame=$srcdir/hide-game
5 kx fi
5 kx fi
5 kx ask "Section 6 manpage directory" man6dir /usr/share/man/man6
5 kx if building_in dm || building_in fortune; then
5 kx ask "Section 8 manpage directory" man8dir /usr/share/man/man8
5 kx else
5 kx man8dir=
5 kx subst_vars="$subst_vars man8dir"
5 kx fi
5 kx if building_in dm; then
5 kx ask "Section 5 manpage directory" man5dir /usr/share/man/man5
5 kx else
5 kx man5dir=
5 kx subst_vars="$subst_vars man5dir"
5 kx fi
5 kx
5 kx if building_in trek || building_in rogue; then
5 kx ask "Directory for miscellaneous documentation" docdir /usr/share/doc/bsd-games
5 kx else
5 kx docdir=
5 kx subst_vars="$subst_vars docdir"
5 kx fi
5 kx
5 kx # The paths for data are as per the FHS. If a future version removes the
5 kx # games ghettoes of /usr/games, /var/games, etc., then a subdirectory for
5 kx # this package (/usr/share/bsdgames, /var/state/bsdgames, etc.) would be
5 kx # desirable, but I don't feel it necessary at present.
5 kx
5 kx ask "Library directory for constant data
5 kx (architecture independent)" sharedir /usr/share/games
5 kx ask "Library directory for variable data" varlibdir /var/games
5 kx
5 kx ask_yn "Set owners/groups on installed files" do_chown y
5 kx
5 kx echo
5 kx echo "See SECURITY for a discussion of security issues related to score files."
5 kx echo "There are at least two possible security policies if you want them to"
5 kx echo "work. You can make the files world-writable, and then anyone who wants"
5 kx echo "can put anything in them, which may not be desirable if you think people"
5 kx echo "might cheat this way. Or you can make the games that use them setgid"
5 kx echo "games, and give the files permissions 0664. Note, however, that some"
5 kx echo "of the games may well be insecure when this is done and"
5 kx echo "malicious users may still be able to overwrite anything writable by"
5 kx echo "group games, since the games were probably not designed with security in"
5 kx echo "mind, although version 2.2 is more secure than earlier versions."
5 kx echo "The default is neither of these: it creates scorefiles with"
5 kx echo "permissions 0644 and gives the games no special privileges, which is"
5 kx echo "more secure but means that the games will fail when trying to write"
5 kx echo "to their scorefiles."
5 kx
5 kx askperms "Binary" binary root root 0755
5 kx askperms "Game with scorefile" score_game root root 0755 # or root games 2755?
5 kx if building_in hunt; then
5 kx askperms "Daemon" daemon root root 0755
5 kx fi
5 kx if building_in dm; then
5 kx askperms "Directory for hidden games" dmdir root games 0750
5 kx install_dmdir=`echo "$install_dmdir"| sed 's/install -c/install -d/'`
5 kx askperms "dm" dm root games 2755
5 kx fi
5 kx askperms "Manpage" manpage root root 0644
5 kx askperms "Constant data" constdata root root 0644
5 kx askperms "Variable data" vardata root root 0644 # or 0666?
5 kx
5 kx ask "Permissions on variable data that should not be world readable" vardata_perms_priv 0640
5 kx
5 kx use_dot_so=
5 kx while test x$use_dot_so = x; do
5 kx ask "Use .so or symlinks for manpages" use_dot_so .so
5 kx case "$use_dot_so" in
5 kx (.so)
5 kx ;;
5 kx (syml*)
5 kx use_dot_so=symlinks
5 kx ;;
5 kx (*)
5 kx use_dot_so=
5 kx echo "Please answer \`.so\' or \`symlinks\'"
5 kx ;;
5 kx esac
5 kx done
5 kx subst_vars="$subst_vars use_dot_so"
5 kx
5 kx ask_yn "Gzip manpages" gzip_manpages y
5 kx
5 kx # What we do with manpages is a bit complicated. If either ppt or morse is
5 kx # being built, we must also install the bcd manpage, even if bcd isn't being
5 kx # built. We then need to do either .so or symlink. This should all be handled
5 kx # by the install-man.in script, but the installation of linked-to manpages
5 kx # isn't implemented yet.
5 kx
5 kx # Copy install_binary to install_script
5 kx install_script="$install_binary"
5 kx subst_vars="$subst_vars install_script"
5 kx
5 kx echo
5 kx echo "It is presumed in some places by the Makefiles that the compiler"
5 kx echo "will be some form of gcc."
5 kx ask "C compiler" cc gcc
5 kx if building_in dab; then
5 kx ask "C++ compiler" cxx g++
5 kx fi
5 kx ask "Optimize flags" optimize_flags "-g -O2"
5 kx echo
5 kx echo "The default warning flags should give a compile with few warnings."
5 kx # -Wbad-function-cast and -Wshadow give lots of warnings that are basically
5 kx # harmless.
5 kx ask "C compiler warning flags" warning_flags "-Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings"
5 kx if building_in dab; then
5 kx ask "C++ compiler warning flags" cxx_warning_flags "-Wall -W -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings"
5 kx fi
5 kx echo
5 kx echo "You probably want the default here, or could use -lncurses_g for"
5 kx echo "debugging ncurses. Use -lcurses -ltermcap if you want to try that,"
5 kx echo "but note that this is no longer supported and may not work."
5 kx ask "Ncurses library" ncurses_lib -lncurses
5 kx echo
5 kx echo "If you have a directory /usr/include/ncurses with the ncurses include"
5 kx echo "files in it, and the <curses.h>, <termcap.h>, etc. in /usr/include"
5 kx echo "are for BSD curses/termcap, you will need to put -I/usr/include/ncurses"
5 kx echo "here. Otherwise (if the ncurses includes are in /usr/include), leave"
5 kx echo "this blank. Leave it blank if /usr/include/ncurses is a symbolic link"
5 kx echo "to /usr/include."
5 kx ask "Ncurses includes" ncurses_includes ''
5 kx
5 kx openssl_lib=
5 kx openssl_includes=
5 kx if building_in factor; then
5 kx echo
5 kx echo "factor can use libcrypto from OpenSSL to handle large numbers."
5 kx ask_yn "Use libcrypto" use_libcrypto y
5 kx if [ $use_libcrypto = y ]; then
5 kx echo "If the OpenSSL includes (with files such as bn.h) are not in"
5 kx echo "/usr/include/openssl, then you will need to specify a -I option"
5 kx echo "here, naming a directory containing an \"openssl\" subdirectory"
5 kx echo "with the OpenSSL headers."
5 kx ask "OpenSSL includes" openssl_includes ''
5 kx echo "If the OpenSSL libcrypto library is not in a location searched"
5 kx echo "by the compiler by default, or has a strange name, you will"
5 kx echo "need to specify the appropriate options to find it here"
5 kx echo "(for example, -L/usr/ssl/lib -lcrypto); otherwise, leave the"
5 kx echo "default, which is probably correct."
5 kx ask "OpenSSL libcrypto library" openssl_lib -lcrypto
5 kx fi
5 kx fi
5 kx subst_vars="$subst_vars openssl_lib openssl_includes"
5 kx
5 kx ask "Other CFLAGS" other_cflags ''
5 kx ask "Other LDFLAGS" other_ldflags ''
5 kx
5 kx # Check for functions - not in glibc 2.1.1, but could be added later.
5 kx echo "#ifndef LINUX_BSD_GAMES_H" >include/bsd-games.h
5 kx echo "#define LINUX_BSD_GAMES_H 1" >>include/bsd-games.h
5 kx
5 kx if [ "$use_libcrypto" = "y" ]; then
5 kx echo "#define HAVE_OPENSSL 1" >>include/bsd-games.h
5 kx fi
5 kx
5 kx check_func getloadavg <<EOF
5 kx #include <stdlib.h>
5 kx
5 kx int
5 kx main(void)
5 kx {
5 kx double la[3];
5 kx getloadavg(la, 3);
5 kx return 0;
5 kx }
5 kx EOF
5 kx
5 kx check_func fgetln <<EOF
5 kx #include <stdio.h>
5 kx
5 kx int
5 kx main(void)
5 kx {
5 kx char *f;
5 kx size_t l;
5 kx f = fgetln(stdin, &l);
5 kx return 0;
5 kx }
5 kx EOF
5 kx
5 kx check_func strlcpy <<EOF
5 kx #include <string.h>
5 kx
5 kx int
5 kx main(void)
5 kx {
5 kx char s[1] = "";
5 kx char d[1];
5 kx strlcpy(d, s, 1);
5 kx return 0;
5 kx }
5 kx EOF
5 kx
5 kx check_func sig_t <<EOF
5 kx #include <signal.h>
5 kx
5 kx sig_t s;
5 kx
5 kx int
5 kx main(void)
5 kx {
5 kx return 0;
5 kx }
5 kx EOF
5 kx
5 kx check_func getprogname <<EOF
5 kx #include <stdlib.h>
5 kx
5 kx int
5 kx main(void)
5 kx {
5 kx const char *n = getprogname();
5 kx return 0;
5 kx }
5 kx EOF
5 kx
5 kx echo "#endif /* !defined(LINUX_BSD_GAMES_H) */" >>include/bsd-games.h
5 kx
5 kx
5 kx echo
5 kx echo "For some special purposes you may want to link all games with a"
5 kx echo "particular library, in addition to those they would normally be linked"
5 kx echo "with. Unless you know you want this, you can leave it empty."
5 kx ask "Base libraries" base_libs ''
5 kx
5 kx if building_in atc; then
5 kx ask "Yacc program" yacc "bison -y"
5 kx fi
5 kx if building_in atc; then
5 kx ask "Lex program" lex flex
5 kx ask "Lex library" lex_lib -lfl
5 kx fi
5 kx
5 kx echo
5 kx echo "You can choose the default pager for those games that use one (for"
5 kx echo "example, for viewing instructions). This can be an absolute path,"
5 kx echo "or the name of the pager to be searched for via the PATH at runtime."
5 kx echo "All these games will also honour the PAGER environment variable if set,"
5 kx echo "in the correct (POSIX.2) way."
5 kx ask "Pager" pager /usr/bin/less
5 kx
5 kx if building_in fortune; then
5 kx echo
5 kx echo "Fortune comes with some potentially offensive fortunes. You should"
5 kx echo "only install these if you are sure that your users want them."
5 kx ask_yn "Install offensive fortunes" offensive_fortunes n
5 kx if [ $offensive_fortunes = y ]; then
5 kx fortune_type=real
5 kx else
5 kx fortune_type=fake
5 kx fi
5 kx subst_vars="$subst_vars fortune_type"
5 kx fi
5 kx
5 kx if building_in sail; then
5 kx echo
5 kx echo "Sail needs its own directory it can write to for temporary files"
5 kx echo "to synchronise among multiple players. Note that with the"
5 kx echo "default permissions given here this will not work: you may want"
5 kx echo "to choose permissions appropriate to the security policy you are"
5 kx echo "using. It may be more secure if this directory is not world"
5 kx echo "accessible (e.g. mode 2770)."
5 kx ask "Directory for sail temporary files" sail_dir "$varlibdir/sail"
5 kx askperms "Sail directory" sail_dir root root 0750
5 kx install_sail_dir=`echo "$install_sail_dir" |sed 's/install -c/install -d/'`
5 kx fi
5 kx
5 kx echo
5 kx echo "You can configure the exact names used for data files by various"
5 kx echo "of the games. Most probably the defaults are OK."
5 kx echo
5 kx echo "Note that bsd-games no longer comes with its own word list."
5 kx echo "For hangman you should specify the path to a word list to be read"
5 kx echo "at runtime (probably /usr/share/dict/words or /usr/dict/words)."
5 kx echo "For boggle you should specify one to be used at compile time to"
5 kx echo "generate boggle's own data. In both cases they should probably be"
5 kx echo "English dictionaries; all words which do not consist entirely of"
5 kx echo "lower-case ASCII letters will be silently ignored."
5 kx echo
5 kx game_ask atc "Directory for atc static data" atc_dir "$sharedir/atc"
5 kx game_ask atc "Score file for atc" atc_scorefile "$varlibdir/atc_score"
5 kx game_ask battlestar "Score file for battlestar" battlestar_scorefile "$varlibdir/battlestar.log"
5 kx # Bog has some other configuration
5 kx game_ask boggle "Dictionary for boggle (CHECK ANSWER)" dictionary_src /usr/share/dict/words
5 kx game_ask boggle "Directory for boggle static data" boggle_dir "$sharedir/boggle"
5 kx game_ask canfield "Score file for canfield" canfield_scorefile "$varlibdir/cfscores"
5 kx game_ask cribbage "File for cribbage instructions" cribbage_instrfile "$sharedir/cribbage.instr"
5 kx game_ask cribbage "Score file for cribbage" cribbage_scorefile "$varlibdir/criblog"
5 kx game_ask dm "Configuration file for dm" dm_configfile /etc/dm.conf
5 kx game_ask dm "File to disable games playing" dm_nogamesfile /etc/nogames
5 kx game_ask dm "Log file for dm" dm_logfile "$varlibdir/games.log"
5 kx game_ask fish "File for fish instructions" fish_instrfile "$sharedir/fish.instr"
5 kx game_ask fortune "Directory for fortune files" fortune_dir "$sharedir/fortune"
5 kx game_ask hack "Directory for hack variable data" hack_dir "$varlibdir/hack"
5 kx
5 kx if building_in hack; then
5 kx echo
5 kx echo "This directory will need to be writable by hack at runtime."
5 kx echo "Note that with the default permissions given here this will"
5 kx echo "not work: you may want to choose permissions appropriate to the"
5 kx echo "security policy you are using (e.g. 2775 root.games for setgid"
5 kx echo "games)."
5 kx askperms "Hack directory" hack_dir root root 0755
5 kx install_hack_dir=`echo "$install_hack_dir" |sed 's/install -c/install -d/'`
5 kx fi
5 kx
5 kx game_ask hangman "Words file for hangman (CHECK ANSWER)" hangman_wordsfile /usr/share/dict/words
5 kx # Hunt has some other configuration
5 kx game_ask monop "File for monop cards" monop_cardsfile "$sharedir/monop-cards.pck"
5 kx game_ask phantasia "Directory for phantasia variable data" phantasia_dir "$varlibdir/phantasia"
5 kx game_ask quiz "Directory for quiz static data" quiz_dir "$sharedir/quiz"
5 kx game_ask robots "Score file for robots" robots_scorefile "$varlibdir/robots_roll"
5 kx game_ask rogue "Score file for rogue" rogue_scorefile "$varlibdir/rogue.scores"
5 kx game_ask sail "Score file for sail" sail_scorefile "$varlibdir/saillog"
5 kx game_ask snake "Score file for snake" snake_scorefile "$varlibdir/snake.log"
5 kx game_ask snake "Raw score file for snake" snake_rawscorefile "$varlibdir/snakerawscores"
5 kx game_ask tetris "Score file for tetris" tetris_scorefile "$varlibdir/tetris-bsd.scores"
5 kx game_ask wtf "Acronym database for wtf" wtf_acronymfile "/usr/share/misc/acronyms"
5 kx game_ask wump "File for wump info" wump_infofile "$sharedir/wump.info"
5 kx
5 kx # Generate simplistic substitution script.
5 kx # This does not allow escaped @s in the substituted file, will fail on
5 kx # newline or % in filenames, etc.. The justification is that proper insertion
5 kx # of arbitrary 8-bit data in different files requires too much knowledge
5 kx # of escapes specific to the particular file type, so these things would
5 kx # probably fail anyway.
5 kx : >subst.sed
5 kx for var in $subst_vars; do
5 kx eval echo \""s%@$var@%\$$var%g"\" >> subst.sed
5 kx done
5 kx
5 kx substitute () {
5 kx for file in "$@"; do
5 kx dir="${file%%/*}"
5 kx if building_in $dir || [ "$file" = "$dir" ]; then
5 kx source_file="${file}.in"
5 kx case "$file" in
5 kx (quiz/datfiles/index)
5 kx # Can't put a comment in this file
5 kx subst_type=n
5 kx ;;
5 kx (Makeconfig)
5 kx subst_type=h
5 kx ;;
5 kx (*.[1-9])
5 kx subst_type=m
5 kx ;;
5 kx (*.[ch])
5 kx subst_type=c
5 kx ;;
5 kx (*)
5 kx subst_type=s
5 kx ;;
5 kx esac
5 kx if [ "$rules_only" = y ]; then
5 kx ./substscr r "$subst_type" "$source_file" "$file"
5 kx else
5 kx ./substscr gr "$subst_type" "$source_file" "$file"
5 kx fi
5 kx fi
5 kx done
5 kx }
5 kx
5 kx : >subst.rules
5 kx
5 kx rules_only=n
5 kx subst_files="`sed '/^#/d' <substfiles`"
5 kx
5 kx substitute $subst_files
5 kx
5 kx rules_only=y
5 kx subst_files="`sed '/^#/d' <substfiles2`"
5 kx
5 kx substitute $subst_files
5 kx
5 kx # Now we want to create the main GNUmakefile that includes the subdirectory
5 kx # fragments and all the necessary dependencies. This may take some time.
5 kx
5 kx echo "Generating the main GNUmakefile, please wait..."
5 kx
5 kx prog_to_exec () {
5 kx if [ "x$(dirname $1)" = x. ]; then
5 kx echo "$1/$1"
5 kx else
5 kx echo "$1"
5 kx fi
5 kx }
5 kx
5 kx slashdot_to_under () {
5 kx echo "$1" |sed 's:/:_:g' |sed 's:\.:_:g'
5 kx }
5 kx
5 kx exec_to_libs () {
5 kx eval echo \$$(slashdot_to_under $1)_libs
5 kx }
5 kx
5 kx exec_to_objs () {
5 kx eval echo \$$(slashdot_to_under $1)_objs
5 kx }
5 kx
5 kx make_dirs_tmp="$(find $build_dirs -depth -type d) lib"
5 kx
5 kx make_dirs=
5 kx
5 kx for dir in $make_dirs_tmp; do
5 kx if [ -e $dir/Makefrag ]; then
5 kx make_dirs="$make_dirs $dir"
5 kx fi
5 kx done
5 kx
5 kx all_dependencies=
5 kx
5 kx for dir in $make_dirs; do
5 kx udir=$(slashdot_to_under $dir)
5 kx all_dependencies="$all_dependencies ${udir}_all"
5 kx done
5 kx
5 kx cat >GNUmakefile <<EOF
5 kx # GNUmakefile - automatically generated by configure. Do not edit.
5 kx
5 kx # No suffix rules
5 kx .SUFFIXES:
5 kx
5 kx # Include configuration
5 kx include Makeconfig
5 kx
5 kx .PHONY: all $all_dependencies
5 kx all: $all_dependencies
5 kx
5 kx # Include substitution rules.
5 kx include subst.rules
5 kx
5 kx EOF
5 kx
5 kx for dir in $make_dirs; do
5 kx udir=$(slashdot_to_under $dir)
5 kx eval clean_$udir=
5 kx if [ $dir = dab ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx include $dir/Makefrag
5 kx
5 kx $dir/%.o: $dir/%.cc
5 kx \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.ii: $dir/%.cc
5 kx \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
5 kx
5 kx $dir/%.s: $dir/%.cc
5 kx \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
5 kx
5 kx $dir/%.d: $dir/%.cc
5 kx ./mkdep \$< \$@ \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
5 kx
5 kx EOF
5 kx elif [ $dir = adventure ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx include $dir/Makefrag
5 kx
5 kx $dir/setup.o: $dir/setup.c
5 kx \$(BUILD_CC) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.o: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.i: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
5 kx
5 kx $dir/%.s: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
5 kx
5 kx $dir/setup.d: $dir/setup.c
5 kx ./mkdep \$< \$@ \$(BUILD_CC) \$(${udir}_DEFS) -I$dir \$(${udir}_INCS)
5 kx
5 kx $dir/%.d: $dir/%.c
5 kx ./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
5 kx
5 kx EOF
5 kx elif [ $dir = hack ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx include $dir/Makefrag
5 kx
5 kx $dir/makedefs.o: $dir/makedefs.c
5 kx \$(BUILD_CC) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.o: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.i: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
5 kx
5 kx $dir/%.s: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
5 kx
5 kx $dir/makedefs.d: $dir/makedefs.c
5 kx ./mkdep \$< \$@ \$(BUILD_CC) \$(${udir}_DEFS) -I$dir \$(${udir}_INCS)
5 kx
5 kx $dir/%.d: $dir/%.c
5 kx ./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
5 kx
5 kx EOF
5 kx elif [ $dir = monop ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx include $dir/Makefrag
5 kx
5 kx $dir/initdeck.o: $dir/initdeck.c
5 kx \$(BUILD_CC) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.o: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.i: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
5 kx
5 kx $dir/%.s: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
5 kx
5 kx $dir/initdeck.d: $dir/initdeck.c
5 kx ./mkdep \$< \$@ \$(BUILD_CC) \$(${udir}_DEFS) -I$dir \$(${udir}_INCS)
5 kx
5 kx $dir/%.d: $dir/%.c
5 kx ./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
5 kx
5 kx EOF
5 kx elif [ $dir = phantasia ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx include $dir/Makefrag
5 kx
5 kx $dir/host_phantglobs.o: $dir/phantglobs.c
5 kx \$(BUILD_CC) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/setup.o: $dir/setup.c
5 kx \$(BUILD_CC) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.o: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.i: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
5 kx
5 kx $dir/%.s: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
5 kx
5 kx $dir/host_phantglobs.d: $dir/phantglobs.c
5 kx ./mkdep \$< \$@ \$(BUILD_CC) \$(${udir}_DEFS) -I$dir \$(${udir}_INCS)
5 kx
5 kx $dir/setup.d: $dir/setup.c
5 kx ./mkdep \$< \$@ \$(BUILD_CC) \$(${udir}_DEFS) -I$dir \$(${udir}_INCS)
5 kx
5 kx $dir/%.d: $dir/%.c
5 kx ./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
5 kx
5 kx EOF
5 kx elif [ $dir = fortune/strfile ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx include $dir/Makefrag
5 kx
5 kx $dir/%.o: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/strfile_build.o: $dir/strfile.c
5 kx \$(BUILD_CC) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.i: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
5 kx
5 kx $dir/%.s: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
5 kx
5 kx $dir/strfile_build.d: $dir/strfile.c
5 kx ./mkdep \$< \$@ \$(BUILD_CC) \$(${udir}_DEFS) -I$dir \$(${udir}_INCS)
5 kx
5 kx $dir/%.d: $dir/%.c
5 kx ./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
5 kx
5 kx EOF
5 kx else
5 kx cat >>GNUmakefile <<EOF
5 kx include $dir/Makefrag
5 kx
5 kx $dir/%.o: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
5 kx
5 kx $dir/%.i: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
5 kx
5 kx $dir/%.s: $dir/%.c
5 kx \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
5 kx
5 kx $dir/%.d: $dir/%.c
5 kx ./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
5 kx
5 kx EOF
5 kx fi
5 kx done
5 kx
5 kx # This temporary file is needed because we don't know whether the last
5 kx # part of a pipeline is in the current shell execution environment
5 kx # (POSIX.2, 3.12 and rationale).
5 kx sed '/^#/d' <exec.libs >exec.libs.tmp
5 kx while read prog libs; do
5 kx if ! building_in ${prog%%/*}; then
5 kx continue
5 kx fi
5 kx exec=$(prog_to_exec $prog)
5 kx evar=$(slashdot_to_under $exec)_libs
5 kx eval $evar=\"\$libs\"
5 kx done <exec.libs.tmp
5 kx
5 kx sed '/^#/d' <exec.objs >exec.objs.tmp
5 kx while read prog objs; do
5 kx if ! building_in ${prog%%/*}; then
5 kx continue
5 kx fi
5 kx exec=$(prog_to_exec $prog)
5 kx evar=$(slashdot_to_under $exec)_libs
5 kx eval libs=\"\$$evar\"
5 kx dir=$(dirname $exec)
5 kx udir=$(slashdot_to_under $dir)
5 kx nobjs=
5 kx deps_to_inc=
5 kx eval clean_$udir=\"\$clean_$udir $(basename $exec)\"
5 kx for obj in $objs; do
5 kx if [ "x$(dirname $obj)" = x. ]; then
5 kx obj=$dir/$obj
5 kx fi
5 kx nobjs="$nobjs $obj"
5 kx obj_dep_var=$(slashdot_to_under $obj)
5 kx obj_dep_var=${obj_dep_var}_deps_included
5 kx eval obj_dep_val=\$$obj_dep_var
5 kx if [ "x$obj_dep_val" = "x" ]; then
5 kx deps_to_inc="$deps_to_inc ${obj%%.o}.d"
5 kx eval $obj_dep_var=y
5 kx fi
5 kx done
5 kx if [ $dir = dab ]; then
5 kx ccvar=CXX
5 kx else
5 kx ccvar=CC
5 kx fi
5 kx cat >>GNUmakefile <<EOF
5 kx ifneq (\$(nodep),true)
5 kx include $deps_to_inc
5 kx endif
5 kx
5 kx EOF
5 kx
5 kx if [ "$exec" == "hack/makedefs" ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx $exec: $nobjs
5 kx \$(BUILD_CC) \$^ -o \$@
5 kx
5 kx EOF
5 kx elif [ "$exec" == "monop/initdeck" ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx $exec: $nobjs
5 kx \$(BUILD_CC) \$^ -o \$@
5 kx
5 kx EOF
5 kx elif [ "$exec" == "phantasia/setup" ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx $exec: phantasia/host_phantglobs.o phantasia/setup.o
5 kx \$(BUILD_CC) \$^ -o \$@
5 kx
5 kx EOF
5 kx elif [ "$exec" == "adventure/setup" ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx $exec: $nobjs
5 kx \$(BUILD_CC) \$^ -o \$@
5 kx
5 kx EOF
5 kx elif [ "$exec" == "fortune/strfile/strfile" ]; then
5 kx cat >>GNUmakefile <<EOF
5 kx fortune/strfile/strfile_build: fortune/strfile/strfile_build.o
5 kx \$(BUILD_CC) \$^ $libs \$(BASE_LIBS) -o \$@
5 kx
5 kx $exec: $nobjs
5 kx \$($ccvar) \$(LDFLAGS) \$^ $libs \$(BASE_LIBS) -o \$@
5 kx
5 kx EOF
5 kx else
5 kx cat >>GNUmakefile <<EOF
5 kx $exec: $nobjs
5 kx \$($ccvar) \$(LDFLAGS) \$^ $libs \$(BASE_LIBS) -o \$@
5 kx
5 kx EOF
5 kx fi
5 kx done <exec.objs.tmp
5 kx
5 kx rm -f exec.libs.tmp exec.objs.tmp
5 kx
5 kx clean_dependencies=
5 kx install_dependencies=
5 kx
5 kx for dir in $make_dirs; do
5 kx udir=$(slashdot_to_under $dir)
5 kx clean_dependencies="$clean_dependencies ${udir}_clean"
5 kx install_dependencies="$install_dependencies ${udir}_install"
5 kx eval clean=\"\$clean_$udir\"
5 kx cat >>GNUmakefile <<EOF
5 kx .PHONY: ${udir}_clean
5 kx ${udir}_clean:
5 kx cd $dir && rm -f -- a.out core *.o *.d *.i *.s *.d.tmp $clean \$(${udir}_CLEANFILES)
5 kx
5 kx .PHONY: ${udir}_install ${udir}_install-strip ${udir}_installdirs
5 kx ${udir}_install: ${udir}_installdirs
5 kx
5 kx ${udir}_install-strip:
5 kx \$(MAKE) ${udir}_install \$(DEFS_TO_PASS_STRIP)
5 kx
5 kx ${udir}_installdirs:
5 kx set -e; for d in \$(${udir}_DIRS) /; do mkdir -p \$(INSTALL_PREFIX)\$\$d; done
5 kx
5 kx EOF
5 kx done
5 kx
5 kx cat >>GNUmakefile <<EOF
5 kx .PHONY: clean mostlyclean distclean maintainer-clean
5 kx clean mostlyclean: $clean_dependencies
5 kx
5 kx distclean maintainer-clean: clean
5 kx rm -f subst.sed subst.rules
5 kx rm -f test.out
5 kx rm -f \`cat substfiles substfiles2 |sed '/^#/d'\`
5 kx rm -f GNUmakefile
5 kx rm -f a.out conftest.c include/bsd-games.h
5 kx rm -f exec.libs.tmp exec.objs.tmp
5 kx
5 kx .PHONY: install install-strip
5 kx
5 kx install: $install_dependencies
5 kx
5 kx install-strip:
5 kx \$(MAKE) install \$(DEFS_TO_PASS_STRIP)
5 kx
5 kx .PHONY: check test
5 kx check test: all
5 kx set -e; for f in tests/*.test; do echo \$\$f; \$\$f; done
5 kx
5 kx # Standard GNU targets we don't support
5 kx .PHONY: uninstall TAGS dist
5 kx uninstall TAGS dist:
5 kx @echo "The GNU target \\\`\$@' is not supported by this package." >&2; exit 1
5 kx
5 kx # GNU targets that can do nothing
5 kx .PHONY: info dvi
5 kx info dvi:
5 kx @echo "This package comes with no Texinfo documentation."
5 kx
5 kx EOF