configure: exec-prefix
[zik.git] / configure
blob9e2fddc468530e95350289a72735093245772e3f
1 #!/bin/sh
3 ERROR=0
4 WARNING=0
5 OPTION=''
6 DIR=`dirname $0`
7 if test "X$DIR"="X."
8 then
9 SED_FILE=config.sed
10 else
11 SED_FILE=$DIR/config.sed
14 #Help
15 if test "X$1" = 'X--help'
16 then
17 echo -ne "Usage:\n"
18 echo -ne "configure --option1=value1 --option2=value2\n"
19 echo -ne "Valid options are:\n"
20 echo -ne "prefix -> Default is /usr/local\n"
21 echo -ne "exec-prefix -> Default is prefix\n"
22 echo -ne "That is all for now.\n"
23 exit 0
26 #Check for the required programms
27 echo -ne "Checking for dirname.."
28 if dirname --version &> /dev/null
29 then
30 echo -ne " yes\n"
31 else
32 echo -ne " no\n"
33 ERROR=1
35 echo -ne "Checking for sed.."
36 if sed --version &> /dev/null
37 then
38 echo -ne " yes\n"
39 else
40 echo -ne " no\n"
41 ERROR=1
43 echo -ne "Checking for install.."
44 if install --version &> /dev/null
45 then
46 echo -ne " yes\n"
47 else
48 echo -ne " no\n"
49 ERROR=1
51 echo -ne "Checking for make.."
52 if make --version &> /dev/null
53 then
54 echo -ne " yes\n"
55 else
56 echo -ne " no\n"
57 ERROR=1
59 echo -ne "Checking for rmsgfmt.."
60 if rmsgfmt --version &> /dev/null
61 then
62 echo -ne " yes\n"
63 else
64 echo -ne " no\n"
65 ERROR=1
67 if test "$ERROR" -gt 0
68 then
69 echo -ne "\nERROR: Some programms are missing. You have to install them.\n\n"
70 exit 1
73 #Parse the options
74 until test -z "$1"
76 case "$1" in
77 --prefix=*) PREFIX=`expr "$1" : '--prefix\=\(.*\)'`;OPTION="$OPTION PREFIX";;
78 --prefix) PREFIX="$2";shift;OPTION="$OPTION PREFIX";;
79 --exec-prefix=*) EXEC_PREFIX=`expr "$1" : '--exec-prefix\=\(.*\)'`;OPTION="$OPTION EXEC_PREFIX";;
80 --exec-prefix) EXEC_PREFIX="$2";shift;OPTION="$OPTION EXEC_PREFIX";;
81 *) echo -ne "\nTry configure --help\nERROR:unknown options.\n\n";exit 1;;
82 esac
83 shift
84 done
86 #Check options
87 for i in $OPTION
89 case $i in
90 PREFIX)
91 path=`expr "$PREFIX" : '\/\(.*\)'`
92 if test -z $path
93 then
94 echo -ne "\nERROR: prefix have to be an absolute path\n\n"
95 ERROR=1
96 exit 1
98 path=`expr "$PREFIX" : '\(.*\)\/$'`
99 if test -n "$path"
100 then
101 PREFIX=$path
102 echo -ne "\nWARNING: prefix is set to $PREFIX.\n\n"
103 WARNING=1
104 fi;;
105 EXEC_PREFIX)
106 path=`expr "$EXEC_PREFIX" : '\/\(.*\)'`
107 if test -z $path
108 then
109 echo -ne "\nERROR: exec-prefix have to be an absolute path\n\n"
110 ERROR=1
111 exit 1
113 path=`expr "$EXEC_PREFIX" : '\(.*\)\/$'`
114 if test -n "$path"
115 then
116 EXEC_PREFIX=$path
117 echo -ne "\nWARNING: exec-prefix is set to $EXEC_PREFIX.\n\n"
118 WARNING=1
119 fi;;
120 esac
121 done
123 #Write options to config.sed
124 cat > $SED_FILE << CEOF
125 s!PREFIX\=\/usr\/local!PREFIX\=$PREFIX!
126 s!EXEC\_PREFIX\=\$(PREFIX)!EXEC\_PREFIX=$EXEC_PREFIX!
127 CEOF
129 #Create Makefile
130 echo -ne "Creating Makefile.\n"
131 if test -n "$OPTION"
132 then
133 sed -f $SED_FILE $DIR/Makefile.in > $DIR/Makefile
134 else
135 cp $DIR/Makefile.in $DIR/Makefile
138 #Exit
139 echo -ne "Configuration done.\nThe Programm will be installed in $PREFIX.\n"
140 if test "$WARNING" -gt 0
141 then
142 echo -ne "Warning(s) occured.\n"
145 exit 0