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