File: configure

package info (click to toggle)
bsdgames 2.1-3hamm1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 8,368 kB
  • ctags: 4,860
  • sloc: ansic: 59,005; makefile: 1,058; sh: 511; yacc: 327; lex: 79; sed: 13; csh: 5
file content (317 lines) | stat: -rwxr-xr-x 11,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#!/bin/bash
# configure - home-grown configuration script for bsd-games

# This will only ask some questions if the previous answers are appropriate.
# It will substitute values in the directories built in, and the main
# Makefile.

subst_vars=srcdir

srcdir="`pwd`"

ask () {
    long_query="$1"
    query_var="$2"
    default="$3"
    echo -n "$long_query [$default] "
    read input
    case "$input" in
	'')
	    input="$default"
	    ;;
	*)
	    ;;
    esac
    eval $query_var=\"\$input\"
    subst_vars="$subst_vars $query_var"
    echo $input
}

ask_yn () {
    eval $2=
    eval answer=\$$2
    while test "x$answer" = x; do
	ask "$1" $2 $3
	eval answer=\$$2
	case "$answer" in
	    [yY]*)
		answer=y
		;;
	    [nN]*)
		answer=n
		;;
	    *)
		answer=
		echo "Please answer y or n"
		;;
        esac
    done
    eval $2=\$answer
}

askperms () {
    filetype=$1
    var_prefix=$2
    def_owner=$3
    def_group=$4
    def_perms=$5
    if [ $do_chown = y ]; then
	ask "$filetype owner" ${var_prefix}_owner $def_owner
	ask "$filetype group" ${var_prefix}_group $def_group
    fi
    ask "$filetype permissions" ${var_prefix}_perms $def_perms
    if [ $do_chown = y ]; then
	eval install_$var_prefix=\"install -c -m \$${var_prefix}_perms -o \$${var_prefix}_owner -g \$${var_prefix}_group\"
    else
	eval install_$var_prefix=\"install -c -m \$${var_prefix}_perms\"
    fi
    subst_vars="$subst_vars install_$var_prefix"
}

building_in () {
    echo "$build_dirs" |grep -w "$1" >/dev/null
}

game_ask () {
    game="$1"
    if building_in "$game"; then
	ask "$2" "$3" "$4"
    fi
}

echo "For normal usage the installation prefix will be empty.  If you wish"
echo "to install everything in another directory to that in which it will"
echo "finally be located (so that your packaging system can then move it"
echo "there) you should name that directory here.  This is most likely to"
echo "be the case if you are packaging bsd-games for a Linux distribution."
ask "Installation prefix" install_prefix `pwd`'/debian/tmp'

def_build_dirs=
for file in *; do
	# Don't build dm or banner or fortune or factor.
    if [ -e "$file/Makefile" -a "$file" != "dm" -a "$file" != "banner" \
	 -a "$file" != "fortune" -a "$file" != "factor" ]; then
	def_build_dirs="$def_build_dirs $file"
    fi
done
def_build_dirs=${def_build_dirs## }

ask "Games to build" build_dirs "$def_build_dirs"
ask "Games directory" gamesdir /usr/games
if building_in hunt; then
    echo
    echo "Hunt includes a daemon for coordinating games with multiple players"
    ask "Daemon directory" sbindir /usr/sbin
else
    sbindir=
    subst_vars="$subst_vars sbindir"
fi
if building_in fortune; then
    echo
    echo "Fortune includes a non-game utility strfile"
    ask "Non-game binary directory" usrbindir /usr/bin
else
    usrbindir=
    subst_vars="$subst_vars usrbindir"
fi

hidegame=:
subst_vars="$subst_vars hidegame"
if building_in dm; then
    echo
    echo "You may wish to restrict the use of games by user, terminal, load,"
    echo "etc..  This can be done by the use of dm.  If you use this"
    echo "configuration, then games will be kept in a non-world-searchable"
    echo "directory such as /usr/libexec/dm and replaced by symlinks to dm."
    echo "Even if you don't choose this option, you will still be asked"
    echo "for the directory name, since you are building dm, and can change"
    echo "manually later."
    ask_yn "Use dm and hide games" use_dm n
    ask "Directory for hidden games" libexecdir /usr/libexec/dm
    if [ "$use_dm" = y ]; then
	hidegame=$srcdir/hide-game
    fi
fi
ask "Section 6 manpage directory" man6dir /usr/man/man6
if building_in dm || building_in fortune; then
    ask "Section 8 manpage directory" man8dir /usr/man/man8
else
    man8dir=
    subst_vars="$subst_vars man8dir"
fi
if building_in dm; then
    ask "Section 5 manpage directory" man5dir /usr/man/man5
else
    man5dir=
    subst_vars="$subst_vars man5dir"
fi
# arch-dependent data is a bad thing, and we should change the games to
# avoid it where possible, but until then this is needed.
ask "Library directory for constant data
	(architecture dependent)" usrlibdir /usr/lib/games/bsdgames
# We use /usr/share for this by the not-yet-released FHS, at least according
# to the discussion on debian-devel
ask "Library directory for constant data
	(architecture independent)" sharedir /usr/share/games/bsdgames
ask "Library directory for variable data" varlibdir /var/lib/games/bsdgames
ask_yn "Set owners/groups on installed files" do_chown n

echo
echo "For scorefiles there are at least two possible security policies if you"
echo "want them to work.  You can make the files world-writable, and then"
echo "anyone who wants can put anything in them, which may not be desirable if"
echo "you think people might cheat this way.  Or you can make the games that"
echo "use them setgid games, and give the files permissions 0664.  Note,"
echo "however, that the games may well be insecure when this is done and"
echo "malicious users can probably still overwrite anything writable by"
echo "group games, since the games were probably not designed with security in"
echo "mind.  The default is neither of these: it creates scorefiles with"
echo "permissions 0644 and gives the games no special privileges, which is"
echo "more secure but means that the games will fail when trying to write"
echo "to their scorefiles."

askperms "Binary" binary root root 0755
askperms "Game with scorefile" score_game root root 0755 # or root games 2755?
if building_in hunt; then
    askperms "Daemon" daemon root root 0755
fi
if building_in dm; then
    askperms "Directory for hidden games" dmdir root games 0750
    install_dmdir=`echo "$install_dmdir"| sed 's/install -c/install -d/'`
    askperms "dm" dm root games 2755
fi
askperms "Manpage" manpage root root 0644
askperms "Constant data" constdata root root 0644
askperms "Variable data" vardata root root 0644 # or 0666?

use_dot_so=
while test x$use_dot_so = x; do
    ask "Use .so or symlinks for manpages" use_dot_so symlinks
    case "$use_dot_so" in
        .so)
    	;;
        syml*)
    	use_dot_so=symlinks
    	;;
        *)
    	use_dot_so=
	echo "Please answer \`.so\' or \`symlinks\'"
    	;;
    esac
done
subst_vars="$subst_vars use_dot_so"

ask_yn "Gzip manpages" gzip_manpages n

# What we do with manpages is a bit complicated.  If either ppt or morse is
# being built, we must also install the bcd manpage, even if bcd isn't being
# built.  We then need to do either .so or symlink.  This should all be handled
# by the install-man.in script, but the installation of linked-to manpages
# isn't implemented yet.

# Copy install_binary to install_script
install_script="$install_binary"
subst_vars="$subst_vars install_script"

echo
echo "It is presumed in some places by the Makefiles that the compiler"
echo "will be some form of gcc."
ask "Compiler" cc gcc
ask "Optimize flags" optimize_flags "-g -O2"
echo
echo "The default warning flags should give a compile with few warnings."
ask "Compiler warning flags" warning_flags "-Wall -W -Wstrict-prototypes -Wmissing-prototypes"
echo
echo "You probably want the default here, or could use -lncurses_g for"
echo "debugging ncurses.  Use -lcurses -ltermcap if you want to try that,"
echo "but note that this is no longer supported and may not work."
ask "Ncurses library" ncurses_lib -lncurses
echo
echo "If you built ncurses with --disable-overwrite, you may need"
echo "-I/usr/include/ncurses here"
ask "Ncurses includes" ncurses_includes ''

ask "Other CFLAGS" other_cflags ''
ask "Other LDFLAGS" other_ldflags ''
if building_in atc; then
    ask "Yacc program" yacc "bison -y"
fi
if building_in atc; then
    ask "Lex program" lex flex
    ask "Lex library" lex_lib -lfl
fi

echo
ask "Pager" pager /usr/bin/less

if building_in fortune; then
    echo
    echo "Fortune comes with some potentially offensive fortunes.  You should"
    echo "only install these if you are sure that your users want them."
    ask_yn "Install offensive fortunes" offensive_fortunes n
    if [ $offensive_fortunes = y ]; then
	fortune_type=real
    else
	fortune_type=fake
    fi
    subst_vars="$subst_vars fortune_type"
fi

echo
echo "You can configure the exact names used for data files by various"
echo "of the games.  Most probably the defaults are OK."
game_ask atc "Directory for atc static data" atc_dir "$sharedir/atc"
game_ask atc "Score file for atc" atc_scorefile "$varlibdir/atc_score"
game_ask battlestar "Score file for battlestar" battlestar_scorefile "$varlibdir/battlestar.log"
# Bog has some other configuration
game_ask boggle "Directory for boggle static data" boggle_dir "$sharedir/boggle"
game_ask canfield "Score file for canfield" canfield_scorefile "$varlibdir/cfscores"
game_ask cribbage "File for cribbage instructions" cribbage_instrfile "$sharedir/cribbage.instr"
game_ask cribbage "Score file for cribbage" cribbage_scorefile "$varlibdir/criblog"
game_ask dm "Configuration file for dm" dm_configfile /etc/dm.conf
game_ask dm "File to disable games playing" dm_nogamesfile /etc/nogames
game_ask dm "Log file for dm" dm_logfile "$varlibdir/games.log"
game_ask fish "File for fish instructions" fish_instrfile "$sharedir/fish.instr"
game_ask hangman "Words file for hangman" hangman_wordsfile "$sharedir/hangman-words"
# Hunt has some other configuration
game_ask monop "File for monop cards" monop_cardsfile "$usrlibdir/monop-cards.pck"
game_ask phantasia "Directory for phantasia variable data" phantasia_dir "$varlibdir/phantasia"
game_ask quiz "Directory for quiz static data" quiz_dir "$sharedir/quiz"
game_ask robots "Score file for robots" robots_scorefile "$varlibdir/robots_roll"
game_ask rogue "Score file for rogue" rogue_scorefile "$varlibdir/rogue.scores"
game_ask sail "Score file for sail" sail_scorefile "$varlibdir/saillog"
game_ask snake "Score file for snake" snake_scorefile "$varlibdir/snake.log"
game_ask snake "Raw score file for snake" snake_rawscorefile "$varlibdir/snakerawscores"
game_ask tetris "Score file for tetris" tetris_scorefile "$varlibdir/tetris-bsd.scores"
game_ask wump "File for wump info" wump_infofile "$sharedir/wump.info"

# Generate simplistic substitution script.
# This does not allow escaped @s in the substituted file, will fail on
# newline or % in filenames, etc..  The justification is that proper insertion
# of arbitrary 8-bit data in different files requires too much knowledge
# of escapes specific to the particular file type, so these things would
# probably fail anyway.
: >subst.sed
for var in $subst_vars; do
    eval echo \""s%@$var@%\$$var%g"\" >> subst.sed
done

substitute () {
    for file in "$@"; do
	dir="${file%%/*}"
	if building_in $dir || [ "$file" = "$dir" ]; then
	    source_file="${file}.in"
	    echo "Extracting $file from $source_file"
	    cp "$source_file" "$file" # set permissions
	    sed -f subst.sed <"$source_file" >"$file"
	fi
    done
}

subst_files="`cat substfiles`"

if [ x"$use_dm" = xy ]; then
    subst_files="$subst_files hide-game"
fi

substitute $subst_files