comparison configure @ 2:5f36d8d69aba

Set up a build framework.
author David A. Holland
date Sun, 19 Feb 2012 18:57:59 -0500
parents
children 923ea629c29f
comparison
equal deleted inserted replaced
1:5f96b693f41a 2:5f36d8d69aba
1 #!/bin/sh
2 # configure - configure swallowtail
3 # usage: see configure --help
4 # note: this is not an autoconf-generated script
5
6 help() {
7 cat <<EOF
8 Usage: $0 [args]
9 where args can be:
10 --help Print usage
11 --destdir=DIR Set install chroot [none]
12 --prefix=DIR Set install prefix [/usr/local]
13 --python=FILE Set path to Python interpreter [probed]
14 --sh=FILE Set path to Bourne shell [/bin/sh]
15 EOF
16 }
17
18 usage() {
19 echo "Usage: $0 [args}" 1>&2
20 echo "Try --help" 1>&2
21 }
22
23 ############################################################
24 # args
25
26 DESTDIR=
27 PREFIX=/usr/local
28 PYTHON=probed
29 SH=/bin/sh
30
31 for ARG in "$@"; do
32 case "$ARG" in
33 --help) help; exit;;
34 --destdir=*) DESTDIR=`echo "$ARG" | sed 's/^[^=]*=//'`;;
35 --prefix=*) PREFIX=`echo "$ARG" | sed 's/^[^=]*=//'`;;
36 --python=*) PYTHON=`echo "$ARG" | sed 's/^[^=]*=//'`;;
37 --sh=*) SHELL=`echo "$ARG" | sed 's/^[^=]*=//'`;;
38 *) usage; exit 1;;
39 esac
40 done
41
42 ############################################################
43 # check for python
44
45 echo -n 'Checking for python... '
46
47 nopython() {
48 echo "failed"
49 echo "$0: $1" 1>&2
50 echo "$0: Install python or use --python=PATH option" 1>&2
51 exit 1
52 }
53
54 testpython() {
55 if [ ! -x "$1" ]; then
56 return 1
57 fi
58 VER=$("$1" -V 2>&1)
59 case "$VER" in
60 "Python "*.*.*) return 0;;
61 "Python "*.*) return 0;;
62 *) ;;
63 esac
64 return 1
65 }
66
67 FOUND=0
68 case "$PYTHON" in
69 probed)
70 for D in \
71 /usr/local/bin \
72 /usr/pkg/bin \
73 /usr/contrib/bin \
74 /usr/bin \
75 /opt/bin \
76 ; do
77 for PY in \
78 python \
79 python2.7 python27 \
80 python2.6 python26 \
81 python2.5 python25 \
82 python2.4 python24 \
83 ; do
84 if testpython $D/$PY; then
85 PYTHON="$D/$PY"
86 FOUND=1
87 break
88 fi
89 done
90 if [ $FOUND = 1 ]; then
91 break
92 fi
93 done
94 if [ $FOUND = 0 ]; then
95 nopython "Cannot find python"
96 fi
97 ;;
98 /*)
99 if testpython "$PYTHON"; then
100 :
101 else
102 nopython "$PYTHON does not appear to be python"
103 fi
104 ;;
105 *)
106 nopython "$PYTHON is not an absolute path"
107 ;;
108 esac
109 echo "$PYTHON"
110
111 ############################################################
112 # Generate config.*
113
114 echo 'Generating config.sed'
115
116 cat > config.sed.new <<EOF
117 s,@@PYTHON@@,$PYTHON,
118 s,@@SH@@,$SH,
119 EOF
120
121 mv -f config.sed.new config.sed
122
123 echo 'Generating config.mk'
124
125 cat > config.mk.new <<EOF
126 DESTDIR=$DESTDIR
127 PREFIX=$PREFIX
128 EOF
129
130 mv -f config.mk.new config.mk
131
132 ############################################################
133 # done
134
135 exit 0