summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/plain/pdcmac/configure
blob: 267494d6269512fa6fdd1922c1bb406eadcef4ea (plain)
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
#!/bin/sh

#  Mini-configure script for PDCMAC for the benefit of UNIX users

version="1.0 Time-stamp: <pdc 1995-03-24>"

#  Takes arguments a bit like the GNU autoconf, but only uses them to
#  try to guess the TeX root directory

package=pdcmac
date=`date +19%y-%m-%d`
files=makefile
unique=pdcmisc.dtx
cmd="$0 $@"
me=`basename $0`

# The flag used with "test" to see if a directory is writable.
# For debugging, I sometimes set writable to -d so that 
#  the searches will pretend that I have write-access to system
#  directories (so I can simulate running the script as root)
writable=-w

echo "This is configure for $package $version $cfgdate"

tmp=${TMPDIR-/tmp}/cfg$$
trap 'rm -f $tmp; exit 1' 1 2 15

while test $# -gt 0; do
	case $1 in
	    -n*|--n*)
		nocreate=t ;;
	    -v*|--v*)
		echo "configure for $package $version <$cfgauthor $cfgdate>" 1>&2
		exit 0 ;;
	    -h*|--h*)
		cat 1>&2 <<@EOF
USAGE:  configure [ option ]...

Running this script creates config.status and optionally 
$files.

Options:
    -h, -help, --help, -v, -version, --version
	print a message and exit

    -p DIR, -prefix DIR, --prefix=DIR
	prefix for installed file names, for example /usr/local

    -e DIR, -exec_prefix DIR, --exec_prefix=DIR
	ignored

    -t DIR, -texmf DIR, --texmf=DIR
	prefix for all TeX-related installed file names, for
	example /usr/texmf or /usr/local/lib/tex

    -w tds, -with tds, --with-tds
	Assume a TDS-like directory tree
@EOF
		exit 0 ;;
	    --p*=*)
		prefix=`expr $1 : '--p.*=\(.*\)'` ;;
	    -p|-prefix|--p*)
		prefix=$2; shift ;;
	    -p*)
		prefix=`expr $1 : '-p\(.*\)$'` ;;
	    --s*=*)
		srcdir=`expr $1 : '--s.*=\(.*\)'` ;;
	    -s|-srcdir|--s*)
		srcdir=$2; shift ;;
	    -s*)
		srcdir=`expr $1 : '-s\(.*\)$'` ;;
	    --t*=*)
		texmf=`expr $1 : '--t.*=\(.*\)'` ;;
	    -t|-texmf|--t*)
		texmf=$2; shift ;;
	    -t*)
		texmf=`expr $1 : '-t\(.*\)$'` ;;
	    --f*=*)
		fonts=`expr $1 : '--f.*=\(.*\)'` ;;
	    -f|-fonts|--f*)
		fonts=$2; shift ;;
	    -f*)
		fonts=`expr $1 : '-f\(.*\)$'` ;;
	    --w*-*)
		with=$with/`expr $1 : '--w.*-\(.*\)'`/ ;;
	    -w|-with|--w*)
		with=$with/$2/; shift ;;
	    -w*)
		with=$with/`expr $1 : '-w\(.*\)$'`/ ;;
	    -e*|--e*=*)
		;;
	    -e|--e*)
		shift ;;
	    *)
		echo $me: ignoring $1 1>&2
		;;
	esac
	shift
done

#  Check for the "with" keywords we're interested in:
case $with in */tds/*) tds=t ;; esac
#  case $with in */bigendian/*) bigendian=t ;; esac
	#  endianness doesn't matter because no fonts in this package


#  Find out how to print a dot with no newline
n=-n c=
echo $n x$c > $tmp
case "`cat $tmp`" in
    -n*)
	n= c='\\c' ;;
esac
dot="$n .$c"


#  INSTALL -- oh, I can't be bothered trying to be clever.
if install --version 2>&1 | grep GNU >/dev/null; then
	INSTALL="install"
else
	INSTALL='$(srcdir)/pinstall'
fi
INSTALL_DATA='$(INSTALL) --mode=644'
echo $me: install files with $INSTALL


# find srcdir
if test -z "$srcdir" ; then
	echo $n "$me: searching for srcdir (package directory)..$c"
	for d in . `dirname $0` ..; do
		echo $dot
		if test -f $d/$unique; then
			echo srcdir=$d
			srcdir=$d
			break
		fi
	done
fi

if test -z "$srcdir"; then
	echo ""
	echo $me: fatal error: could not find sourcdir
	exit 1
fi

#  User might use --prefix to give the TeX prefix:

if test -z "$texmf"; then
	case "$prefix" in
	    */texmf|*/tex)
		texmf=$prefix ;;
	esac
fi

#  If $texmf is not set, then search for it
#  We look in all sorts of prefixes like /usr/local (with or without extra
#  lib), using all sorts of directiry names like "tex"
#  

if test -z "$texmf"; then
	prefixes="$prefix 
		`echo $TEXINPUTS:$TEXFONTS | tr : \\\\12 | 
		sed -n -e 's,/[Tt]e[Xx].*,,p' -e 's,/font.*,,p' | uniq` 
		/ /usr /usr/local /opts /p /packages /package
		/pd /usr/pd /usr/local/pd /usr/contrib /usr/TeX
		$HOME"
	echo $n $me: searching for \$texmf..$c
	for d in texmf tex TeX tex3.14 tex3 tex82; do
		for p in $prefixes; do
			echo $dot
			if test -d $p/$d -a $writable $p/$d; then
				echo texmf=$p/$d
				texmf=$p/$d
				break 2
			fi
			if test -d $p/lib/$d -a $writable $p/lib/$d; then
				echo texmf=$p/lib/$d
				texmf=$p/lib/$d
				break 2
			fi
		done
	done
fi
if test -z "$texmf"; then
	echo ""
	echo $me: fatal error: could not guess a texmf directory 1>&2
	exit 1
fi
if test ! -d "$texmf" -o ! -w "$texmf"; then
	echo $me: warning: $texmf needs to be a writable directory 1>&2
fi


#  If --with-tds not set, try to guess whether we have found
#   a TDS directory or not:
if test -n "$tds" || test -d $texmf/tex/plain; then
	tds=t 
	echo "$me: using TWG-TDS 0.61 directory structure"
else
	echo "$me: using old-style directory structure :-("
fi


#  Start making the config.status file

f=config.status

# Special care is taken with the -n option
#  -- -n is not to be included by default when configure is run with 
#     "config.status -r", so it must be removed from $cmd
#  -- -n (or other options) may be included on the command line 
#      of "config.status -r" and will be passed to configure
cmd2=`echo $cmd | sed 's/ --*n[a-z-]*//g'`
cat >$f <<@EOF
# config.status -- configuration status file
# creator: configure for $package $version <$cfgauthor $cfgdate>
# created: $date
# command: $cmd

case "\$1" in
    -r*|--r*)
	shift
	echo \$0: rerunning $cmd2 1>&2
	exec sh $cmd2 \$* ;;
esac

echo This is config.status, generated by configure for $package on $date

srcdir=$srcdir
date=`date +19%y-%m-%d`
files="\${*-$files}"
sedscript='
	s,@package@,$package,
	s,@srcdir@,$srcdir,
	s,@texmf@,$texmf,
	s,@configure@,$0,
	s,@INSTALL@,$INSTALL,
	s,@INSTALL_DATA@,$INSTALL_DATA,
@EOF

if test -n "$tds"; then
	echo >>$f "	s,@texdir@,\$(texmf)/tex/plain/\$(package),"
	echo >>$f "	s,@docdir@,\$(texmf)/doc/plain/\$(package),"
else
	echo $n $me: searching for TeX macro dir..$c; found=
	for d in inputs macros; do
		echo $dot
		if test -d $texmf/$d -a $writable $texmf/$d; then
			echo $texmf/$d
			echo >>$f "	s,@texdir@,$texmf/$d,"
			found=t
			break
		fi
	done
	if test -z "$found"; then 
		echo ""
		echo $0: fatal error: TeX macro dir NOT FOUND 1>&2
		exit 1
	fi

	# now same again for a documentation directory
	echo $n $me: searching for documentation dir..$c; found=
	for p in $texmf $fonts $prefixes; do
		for d in doc doc/tex docs docs/tex ; do
			echo $dot
			if test -d $p/$d -a $writable $p/$d; then
				echo $p/$d/$package
				echo >>$f "	s,@docdir@,$p/$d/\$(package),"
				found=t
				break 2
			fi
		done
	done
	if test -z "$found"; then 
		echo ""
		echo $0: warning: documentation dir NOT FOUND 1>&2
	fi
fi		


# Finish off the config.status file:

cat >>$f <<'@EOF'
'

for file in $files; do
	echo $0: writing $file... 1>&2
	sed -e 's,Template for configure,Generated from '$file'.in on '$date' by '$0, \
		-e "$sedscript" $srcdir/$file.in > $file || exit 1
done

exit 0
@EOF

echo $me: configuration status written on config.status

if test -z "$nocreate"; then
	sh config.status
fi

rm -f $tmp
exit 0