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