Salome HOME
Correct error in PointOnLinesIntersection
[modules/geom.git] / build_configure
1 #!/bin/bash
2
3 #
4 # Tool for updating list of .in file for the SALOME project 
5 # and regenerating configure script
6 #
7 # Author : Marc Tajchman - CEA
8 # Date : 10/10/2002
9 # $Header$
10 #
11
12 ORIG_DIR=`pwd`
13 CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
14 GEOM_WITH_GUI="yes"
15
16 ########################################################################
17 # Test if the KERNEL_ROOT_DIR is set correctly
18 if test ! -d "${KERNEL_ROOT_DIR}"; then
19     echo "failed : KERNEL_ROOT_DIR variable is not correct !"
20     exit
21 fi
22
23 # Test if the KERNEL_SRC is set correctly
24
25 #if test ! -d "${KERNEL_SRC}"; then
26 #    echo "failed : KERNEL_SRC variable is not correct !"
27 #    exit
28 #fi
29
30 for option
31 do
32   case $option in
33       -with-ihm | --with-ihm)
34           GEOM_WITH_GUI="yes"
35           break;;
36       -without-ihm | --without-ihm | -with-ihm=no | --with-ihm=no)
37           GEOM_WITH_GUI="no"
38           break;;
39   esac
40 done
41
42 ########################################################################
43 # Test if the GUI_ROOT_DIR is set correctly
44 if test ${GEOM_WITH_GUI} = yes; then
45     if test ! -d "${GUI_ROOT_DIR}"; then
46         echo "failed : GUI_ROOT_DIR variable is not correct !"
47         exit
48     fi
49 fi
50
51 ########################################################################
52 # find_in - utility function
53 #
54 # usage :  
55 #    find_in directory filename 
56 #
57 # Finds files following the *.in pattern, recursively in the
58 # directory (first argument).
59 # Results are appended into the file (second argument)
60 #
61 # Difference from the standard unix find is that files are tested
62 # before directories
63
64
65 find_in()
66 {
67   local i
68   local f=$2
69
70 # if the first argument is not a directory, returns
71
72   if [ ! -d "$1" ] ; then 
73      return 
74   fi
75
76 # dont look in the CVS directories
77
78   case $1 in
79     */CVS) return ;;
80     */adm_local/*) return ;;
81     *) ;;
82   esac
83
84 # for each regular file contained in the directory
85 # test if it's a .in file
86
87   for i in "$1"/*
88   do
89      if [ -f "$i" ] ; then
90        case $i in 
91          *.in) echo "   "$i" \\" >> $f;;
92          *) ;;
93         esac
94      fi
95   done
96
97 # for each subdirectory of the first argument, proceeds recursively
98
99   for i in "$1"/*
100   do
101      if [ -d "$i" ] ; then
102         find_in "$i" "$f"
103      fi
104   done
105 }
106
107
108 #######################################################################
109 # Generate list of .in files (Makefile.in, config.h.in, etc)
110 # appending it in file configure.in
111
112 cd ${CONF_DIR}
113 ABS_CONF_DIR=`pwd`
114
115 #
116 # Common part of the configure.in file
117 #
118 chmod u+w configure.in.base
119 if ! \cp -f configure.in.base configure.in_tmp1 
120 then
121         echo
122         echo "error : can't create files in" ${CONF_DIR}
123         echo "aborting ..."
124         chmod u-w configure.in.base 
125         exit
126 fi
127 chmod u-w configure.in.base 
128
129 if [ -e "${CONF_DIR}/salome_adm" ] ; then
130     \rm -f ${CONF_DIR}/salome_adm
131 fi
132
133 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
134 echo "" >> configure.in_tmp1
135 echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/.' >> configure.in_tmp1
136
137 echo  "" >> configure.in_tmp1
138 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
139
140 #
141 # List of .in files in the adm/unix directory
142 # These files MUST be on top of AC_OUTPUT list so we
143 # put them "manually"
144 #
145
146 echo "  ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
147 echo "  ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
148 echo "  ./salome_adm/unix/sstream \\" >> configure.in_tmp1
149 echo "  ./salome_adm/unix/depend \\" >> configure.in_tmp1
150 echo "  ./adm_local/unix/make_omniorb:${ABS_CONF_DIR}/adm_local/unix/make_omniorb.in \\" >> configure.in_tmp1
151 echo "  ./salome_adm/unix/envScript \\" >> configure.in_tmp1
152 echo "  ./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\" >> configure.in_tmp1
153 echo "  ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
154 echo "  ./salome_adm/unix/make_module \\" >> configure.in_tmp1
155
156 \rm -f configure.in_tmp2 configure.in_tmp3
157 touch configure.in_tmp2
158 find_in . configure.in_tmp2
159 sed -e '/^...salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
160 sed -e '/^...adm_local.unix.make_omniorb/d' configure.in_tmp3 > configure.in_tmp2
161 sed -e '/^...adm_local.unix.make_commence/d' configure.in_tmp2 > configure.in_tmp3
162 sed -e '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
163 sed -e 's/.in / /' configure.in_tmp2 >>  configure.in_tmp1
164 #sed '/^.salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
165 #sed '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
166 #sed 's/.in / /' configure.in_tmp2 >> configure.in_tmp1
167
168 echo  "])" >> configure.in_tmp1
169
170 # delete the link created for AC_OUTPUT
171 echo "" >> configure.in_tmp1
172 #echo 'rm -f ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
173 \mv configure.in_tmp1 configure.in_new
174 \rm  -f configure.in_tmp2 configure.in_tmp3
175
176
177 ########################################################################
178 # Create new (or replace old) configure.in file
179 # Print a message if the file is write protected
180 #
181
182 echo
183 if test ! -f configure.in
184 then
185         echo -n "Creating new file 'configure.in' ... "
186         if \mv configure.in_new configure.in >& /dev/null
187         then
188                 echo "done"
189         else
190                 echo "error, check your file permissions"
191         fi
192 else
193         echo -n "Updating 'configure.in' file ... "
194         if ! \cp configure.in configure.in_old >& /dev/null
195         then
196                 echo
197                 echo
198                 echo "Can't backup previous configure.in"
199                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
200                 read R
201                 case "x$R" in
202                     xn*) exit;;
203                     xN*) exit;;
204                 esac
205                 echo
206                 echo -n "                                 "
207         fi
208         if \cp configure.in_new configure.in >& /dev/null
209         then
210                 echo "done"
211         else
212                 echo
213                 echo "error, can't update previous configure.in"
214         fi
215 fi
216
217 ########################################################################
218 # Use autoconf to rebuild the configure script
219 #
220
221 if test -f configure
222 then
223         echo -n "Updating 'configure' script ...  "
224 else
225         echo -n "Creating 'configure' script ...  "
226 fi
227
228 if test ${GEOM_WITH_GUI} = yes; then
229 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
230                                        -I ${GUI_ROOT_DIR}/adm_local/unix/config_files
231 fi
232
233 if test ${GEOM_WITH_GUI} = no; then
234 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files
235 fi
236
237 if autoconf
238 then
239         echo "done"
240 else
241         echo "failed (check file permissions and/or user quotas ...)"
242 fi
243
244 cd ${ORIG_DIR}
245
246 echo