~johanvdw/osgeo-fdo/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#!/bin/sh

##
## Copyright (C) 2013  Autodesk, Inc.
## 
## This library is free software; you can redistribute it and/or
## modify it under the terms of version 2.1 of the GNU Lesser
## General Public License as published by the Free Software Foundation.
## 
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## Lesser General Public License for more details.
## 
## You should have received a copy of the GNU Lesser General Public
## License along with this library; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
##

TYPEACTION=buildinstall
TYPEBUILD=release
TYPECONFIGURE=configure
TYPEARCHITECTURE=32
PREFIXVAL=/usr/local/fdo-4.2.0

DEFMODIFY=no
ALLENABLE=yes
FDOENABLE=no
SDFENABLE=no
WFSENABLE=no
WMSENABLE=no
GDALENABLE=no
OGRENABLE=no

### study parameters ###
while test $# -gt 0
do
  arg="$1"
  shift
  case $arg in
  -h |--h | --help)
    SHOWHELP=yes
    break
    ;;
  -b | --b | --build)
    if test "$1" == ""; then
        echo "$arg Invalid parameter $1"
        exit 1
    else
        TYPEARCHITECTURE="$1"
    fi
    shift
    ;;
  -p | --p | --prefix)
    if test "$1" == ""; then
        echo "$arg Invalid parameter $1"
        exit 1
    else
        PREFIXVAL="$1"
    fi
    shift
    ;;
  -m | --m | --makefile)
    if test "$1" == configure; then
        TYPECONFIGURE=configure
    elif test "$1" == noconfigure; then
        TYPECONFIGURE=noconfigure
    else
        echo "$arg Invalid parameter $1"
	exit 1
    fi
    shift
    ;;
  -a | --a | --action)
    if test "$1" == buildinstall; then
        TYPEACTION=buildinstall
    elif test "$1" == build; then
        TYPEACTION=build
    elif test "$1" == install; then
        TYPEACTION=install
    elif test "$1" == uninstall; then
        TYPEACTION=uninstall
    elif test "$1" == clean; then
        TYPEACTION=clean
    else
        echo "$arg Invalid parameter $1"
	exit 1
    fi
    shift
    ;;
  -c | --c | --config)
    if test "$1" == debug; then
        TYPEBUILD=debug
    elif test "$1" == release; then
        TYPEBUILD=release
    else
        echo "$arg Invalid parameter $1"
    exit 1
    fi
    shift
    ;;
  -w | --w | --with)
    if test "$DEFMODIFY" == no; then
       DEFMODIFY=yes
       ALLENABLE=no
       FDOENABLE=no
       SDFENABLE=no
       WFSENABLE=no
       WMSENABLE=no
       GDALENABLE=no
       OGRENABLE=no
    fi
    if test -z "$1"; then
       echo "$arg Invalid parameter $1"
       exit 1
    elif test "$1" == all; then
       ALLENABLE=yes
       FDOENABLE=no
       SDFENABLE=no
       WFSENABLE=no
       WMSENABLE=no
       GDALENABLE=no
       OGRENABLE=no
    elif test "$1" == fdo; then
        FDOENABLE=yes
    elif test "$1" == sdf; then
        SDFENABLE=yes
    elif test "$1" == wfs; then
        WFSENABLE=yes
    elif test "$1" == wms; then
        WMSENABLE=yes
    elif test "$1" == gdal; then
        GDALENABLE=yes
    elif test "$1" == ogr; then
        OGRENABLE=yes
    else
        echo "$arg Invalid parameter $1"
        exit 1
    fi
    shift
    ;;
  -*)
    echo "The command option is not recognized: $arg"
    echo "Please use the format:"
    SHOWHELP=yes
    break
    ;;

  *)
    echo "The command is not recognized: $arg"
    echo "Please use the format:"
    SHOWHELP=yes
    break
    ;;
  esac
done
### end of study parameters ###

if test "$SHOWHELP" == yes; then

   echo "*******************************************************************"
   echo "build_thirdparty.sh [--h]"
   echo "                    [--a Action]"
   echo "                    [--c BuildType]" 
   echo "                    [--w WithModule]"
   echo "                    [--m ConfigMakefiles]"
   echo "                    [--p Prefix]"
   echo "                    [--b BuildArchicture]"
   echo " "
   echo "Help:                  --h[elp]"
   echo "BuildType:             --c[onfig] release(default), debug"
   echo "Action:                --a[ction] buildinstall(default), "
   echo "                                  build,"
   echo "                                  install,"
   echo "                                  uninstall,"
   echo "                                  clean"
   echo "WithModule:            --w[ith] all(default),"
   echo "                                fdo,"
   echo "                                sdf,"
   echo "                                wms,"
   echo "                                wfs,"
   echo "                                gdal"
   echo "                                ogr"
   echo "ConfigMakefiles:       --m[akefile] configure(default), noconfigure"
   echo "BuildArchitecture:     --b[uild] 32(default), 64"
   echo "Prefix:                --p[refix] <fdo install location>"
   echo "*******************************************************************"

   exit 0
fi


if [[ "$CFLAGS" != *"-m$TYPEARCHITECTURE"* ]]; then
CFLAGS="$CFLAGS -m$TYPEARCHITECTURE"
echo "Exporting CFLAGS: "$CFLAGS""
export CFLAGS
fi

if [[ "$CPPFLAGS" != *"-m$TYPEARCHITECTURE"* ]]; then
CPPFLAGS="$CPPFLAGS -m$TYPEARCHITECTURE"
echo "Exporting CPPFLAGS: "$CPPFLAGS""
export CPPFLAGS
fi

if [[ "$LDFLAGS" != *"-m$TYPEARCHITECTURE"* ]]; then
LDFLAGS="$LDFLAGS -m$TYPEARCHITECTURE"
echo "Exporting LDFLAGS: "$LDFLAGS""
export LDFLAGS
fi

if test "$TYPEARCHITECTURE" == "32" ; then
if test "$HOSTTYPE" == "i686" ; then
if [[ "$CPPFLAGS" != *"-march=i686"* ]]; then
CPPFLAGS="$CPPFLAGS -march=i686"
echo "Exporting CPPFLAGS: "$CPPFLAGS""
export CPPFLAGS
fi
fi
fi

if [[ "$CPPFLAGS" != *"-Wno-write-strings"* ]]; then
CPPFLAGS="$CPPFLAGS -Wno-write-strings"
echo "Exporting CPPFLAGS: "$CPPFLAGS""
export CPPFLAGS
fi

if [[ "$CPPFLAGS" != *"-Wno-deprecated"* ]]; then
CPPFLAGS="$CPPFLAGS -Wno-deprecated"
echo "Exporting CPPFLAGS: "$CPPFLAGS""
export CPPFLAGS
fi

if test "$TYPECONFIGURE" == configure ; then
  echo "Configuring FDO Makefiles"

  if test -e "m4"; then
     echo "m4 directory exists"
  else
     mkdir m4
  fi
  
  aclocal
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
  
  libtoolize --force
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi

  automake --add-missing --copy
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi

  autoconf
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi

  chmod a+x ./configure

  if test "$TYPEBUILD" == release; then
     ./configure --enable-silent-rules --prefix="$PREFIXVAL"
    if [ "$?" -ne 0 ] ; then
      exit 1
    fi
  else
     ./configure --enable-silent-rules --enable-debug=yes --prefix="$PREFIXVAL"
    if [ "$?" -ne 0 ] ; then
      exit 1
    fi
  fi
fi

if test ! -e "Thirdparty/Thirdparty.sh"; then
  echo "Thirdparty/Thirdparty.sh is missing!"
  exit 1;
fi

CMDEX="-b $TYPEARCHITECTURE -a $TYPEACTION"

pushd "Thirdparty" >& /dev/null

if test "$TYPEACTION" == clean ; then
  make clean
fi

if test "$ALLENABLE" == yes ; then
  chmod a+x ./Thirdparty.sh
  sh ./Thirdparty.sh $CMDEX
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
elif test "$FDOENABLE" == yes ; then
  chmod a+x ./Thirdparty_fdo.sh
  sh ./Thirdparty_fdo.sh $CMDEX
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
elif test "$SDFENABLE" == yes ; then
  chmod a+x ./Thirdparty_sdf.sh
  sh ./Thirdparty_sdf.sh $CMDEX
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
elif test "$WMSENABLE" == yes ; then
  chmod a+x ./Thirdparty_wms.sh
  sh ./Thirdparty_wms.sh $CMDEX
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
elif test "$WFSENABLE" == yes ; then
  chmod a+x ./Thirdparty_wfs.sh
  sh ./Thirdparty_wfs.sh $CMDEX
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
elif test "$GDALENABLE" == yes ; then
  chmod a+x ./Thirdparty_gdal.sh
  sh ./Thirdparty_gdal.sh $CMDEX
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
elif test "$OGRENABLE" == yes ; then
  chmod a+x ./Thirdparty_ogr.sh
  sh ./Thirdparty_ogr.sh $CMDEX
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
fi

if test "$TYPEACTION" == buildinstall || test "$TYPEACTION" == install ; then
  sudo make install
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
fi

if test "$TYPEACTION" == uninstall ; then
  sudo make uninstall
  if [ "$?" -ne 0 ] ; then
    exit 1
  fi
fi

popd >& /dev/null

exit 0