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