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