add option -d in order to indicate the path to configuration files
[zik.git] / configure
blob50f38589c2b1bcf92a1e34aec0ccc8eaa651ea2e
1 #!/bin/sh
2 ####################
3 #---Help---
4 #####################
5 if test "X$1" = 'X--help'
6 then
7 echo "Usage:"
8 echo "configure --option1=value1 --option2=value2"
9 echo "Valid options are:"
10 echo "prefix -> Default is /usr/local"
11 echo "exec-prefix -> Default is prefix"
12 echo "That is all for now."
13 exit 0
15 ####################
16 #---Parse the options---
17 #####################
18 OPTION=''
19 until test -z "$1"
21 case "$1" in
22 --prefix=*) PREFIX=`expr "$1" : '--prefix\=\(.*\)'`;OPTION="$OPTION PREFIX";;
23 --prefix) PREFIX="$2";shift;OPTION="$OPTION PREFIX";;
24 --exec-prefix=*) EXEC_PREFIX=`expr "$1" : '--exec-prefix\=\(.*\)'`;OPTION="$OPTION EXEC_PREFIX";;
25 --exec-prefix) EXEC_PREFIX="$2";shift;OPTION="$OPTION EXEC_PREFIX";;
26 *) echo;echo "Try configure --help\nERROR:unknown options.";exit 1;;
27 esac
28 shift
29 done
30 ####################
31 #---Check for the required programms---
32 #####################
33 ERROR=0
34 WARNING=0
36 if dirname --version 1> /dev/null 2>&1
37 then
38 YNDIR="yes"
39 else
40 YNDIR="no"
41 ERROR=1
43 echo "Checking for dirname..$YNDIR"
44 if sed --version 1> /dev/null 2>&1
45 then
46 YNSED="yes"
47 else
48 YNSED="no"
49 ERROR=1
51 echo "Checking for sed..$YNSED"
52 if install --version 1> /dev/null 2>&1
53 then
54 YNINSTALL="yes"
55 else
56 YNINSTALL="no"
57 ERROR=1
59 echo "Checking for install..$YNINSTALL"
60 if make --version 1> /dev/null 2>&1
61 then
62 YNMAKE="yes"
63 else
64 YNMAKE="no"
65 ERROR=1
67 echo "Checking for make..$YNMAKE"
68 if rmsgfmt --version 1> /dev/null 2>&1
69 then
70 YNRMSG="yes"
71 else
72 YNRMSG="no"
73 ERROR=1
75 echo "Checking for rmsgfmt..$YNRMSG"
76 if test "$ERROR" -gt 0
77 then
78 echo
79 echo "ERROR: Some programms are missing. You have to install them."
80 exit 1
82 ####################
83 #---Check options---
84 ####################
85 DIR=`dirname $0`
86 if test "X$DIR"="X."
87 then
88 SED_FILE=config.sed
89 else
90 SED_FILE=$DIR/config.sed
92 #Delete previous SED_FILE if any
93 if test -e $SED_FILE
94 then
95 rm -f $SED_FILE
97 #---
98 for i in $OPTION
100 case $i in
101 PREFIX)
102 path=`expr "$PREFIX" : '\/\(.*\)'`
103 if test -z $path
104 then
105 echo
106 echo "ERROR: prefix have to be an absolute path"
107 ERROR=1
108 exit 1
110 path=`expr "$PREFIX" : '\(.*\)\/$'`
111 if test -n "$path"
112 then
113 PREFIX=$path
114 echo "WARNING: prefix is set to $PREFIX."
115 WARNING=1
117 cat >> $SED_FILE << CEOF
118 s!PREFIX\=\/usr\/local!PREFIX\=$PREFIX!
119 CEOF
121 EXEC_PREFIX)
122 path=`expr "$EXEC_PREFIX" : '\/\(.*\)'`
123 if test -z $path
124 then
125 echo
126 echo "ERROR: exec-prefix have to be an absolute path"
127 ERROR=1
128 exit 1
130 path=`expr "$EXEC_PREFIX" : '\(.*\)\/$'`
131 if test -n "$path"
132 then
133 EXEC_PREFIX=$path
134 echo "WARNING: exec-prefix is set to $EXEC_PREFIX."
135 WARNING=1
137 cat >> $SED_FILE << CEOF
138 s!EXEC\_PREFIX\=\$(PREFIX)!EXEC\_PREFIX=$EXEC_PREFIX!
139 CEOF
141 esac
142 done
143 ####################
144 #---Create Makefile---
145 ####################
146 if test -n "$OPTION"
147 then
148 sed -f $SED_FILE $DIR/Makefile.in > $DIR/Makefile
149 else
150 cp $DIR/Makefile.in $DIR/Makefile
152 echo "Creating Makefile."
153 ####################
154 #---Exit---
155 ####################
156 echo "Configuration done."
157 if test -z "$PREFIX"
158 then
159 echo "The Programm will be installed in /usr/local."
160 else
161 echo "The Programm will be installed in $PREFIX."
163 if test "$WARNING" -gt 0
164 then
165 echo "Warning(s) occured."
168 exit 0