Codebase list cppad / upstream/2014.03.28 build.sh
upstream/2014.03.28

Tree @upstream/2014.03.28 (Download .tar.gz)

build.sh @upstream/2014.03.28raw · history · blame

  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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
#! /bin/bash -e
# $Id: build.sh 3117 2014-02-24 22:51:19Z bradbell $
# -----------------------------------------------------------------------------
# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
#
# CppAD is distributed under multiple licenses. This distribution is under
# the terms of the 
#                     GNU General Public License Version 3.
#
# A copy of this license is included in the COPYING file of this distribution.
# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
# -----------------------------------------------------------------------------
# prefix directories for the corresponding packages
ADOLC_DIR=$HOME/prefix/adolc
BOOST_DIR=/usr
CPPAD_DIR=$HOME/prefix/cppad  
EIGEN_DIR=$HOME/prefix/eigen
FADBAD_DIR=$HOME/prefix/fadbad
IPOPT_DIR=$HOME/prefix/ipopt
SACADO_DIR=$HOME/prefix/sacado
# version type is one of "trunk" or "stable"
version_type="trunk"
# -----------------------------------------------------------------------------
if [ $0 != "./build.sh" ]
then
	echo "./build.sh: must be executed in the directory that contians it"
	exit 1
fi
if [ "$2" != "" ]
then
	# when running multiple options, start by removing old log files
	touch junk.log
	list=`ls *.log`
	for log in $list
	do
		echo "rm $log"
		rm $log
	done
	#
	# run multiple options in order
     for option in $*
     do
		echo "=============================================================="
		echo "begin: ./build.sh $option"
          ./build.sh $option
     done
	echo "=============================================================="
     exit 0
fi
# -----------------------------------------------------------------------------
if [ ! -e build ]
then
	echo "mkdir build"
	mkdir build
fi
# -----------------------------------------------------------------------------
# Today's date in yyyy-mm-dd decimal digit format where 
# yy is year in century, mm is month in year, dd is day in month.
yyyy_mm_dd=`date +%F`
#
# Version of cppad that corresponds to today.
if [ "$version_type" == "trunk" ]
then
	version=`bin/version.sh get`
else
	version=`grep '^ *AC_INIT(' configure.ac | 
		sed -e 's/[^,]*, *\([^ ,]*\).*/\1/'`
	yyyy_mm_dd=`echo $version | 
		sed -e 's|\..*||' -e 's|\(....\)\(..\)|\1-\2-|'`
fi
#
# Files are created by the configure command and copied to the source tree
configure_file_list="
	cppad/configure.hpp
	example/test_one.sh
	test_more/test_one.sh
"
# -----------------------------------------------------------------------------
# change version to current date
if [ "$1" = "version" ]
then
	echo 'bin/version.sh copy'
	bin/version.sh copy 
	#
	echo "OK: ./build.sh version"
	exit 0
fi
# -----------------------------------------------------------------------------
if [ "$1" = "automake" ] 
then
	#
	# check that autoconf and automake output are in original version
	makefile_in=`sed configure.ac \
        	-n \
        	-e '/END AC_CONFIG_FILES/,$d' \
        	-e '1,/AC_CONFIG_FILES/d' \
        	-e 's|/makefile$|&.in|' \
        	-e '/\/makefile.in/p'`
	auto_output="
		depcomp 
		install-sh 
		missing 
		configure 
		config.guess
		config.sub
		$makefile_in
	"
	missing=""
	for name in $auto_output
	do
		if [ ! -e $name ]
		then
			if [ "$missing" != "" ]
			then
				missing="$missing, $name"
			else
				missing="$name"
			fi
		else
			# force remake of files
			rm "$name"
		fi
	done
	if [ "$missing" != "" ]
	then
		echo "The following files:"
		echo "	$missing"
		echo "are not in subversion repository."
		echo "Check them in when this command is done completes."
	fi
	#
	echo "aclocal"
	aclocal
	#
	echo "skipping libtoolize"
	# echo "libtoolize -c -f -i"
	# if ! libtoolize -c -f -i
	# then
	# 	exit 1
	# fi
	#
	echo "autoconf"
	autoconf
	#
	echo "automake --add-missing"
	automake --add-missing
	#
	link_list="missing install-sh depcomp config.sub config.guess"
	for name in $link_list
	do
		if [ -h "$name" ]
		then
			echo "Converting $name from a link to a regular file"
			#
			echo "cp $name $name.$$"
			cp $name $name.$$
			#
			echo "mv $name.$$ $name"
			mv $name.$$ $name
		fi
	done
	#
	echo "OK: ./build.sh automake"
	exit 0
fi
# -----------------------------------------------------------------------------
# configure
if [ "$1" == "configure" ]
then
	log_dir=`pwd`
	log_file="$1.log"
	#
	echo "cd build"
	cd build
	#
	dir_list="
		--prefix=$CPPAD_DIR
	"
	if [ -e $ADOLC_DIR/include/adolc ]
	then
		dir_list="$dir_list 
			ADOLC_DIR=$ADOLC_DIR"
	fi
	if [ -e $BOOST_DIR/include/boost ]
	then
		dir_list="$dir_list BOOST_DIR=$BOOST_DIR"
#_build_test_only:	if [ ! -e $EIGEN_DIR/include/Eigen ]
#_build_test_only:	then
#_build_test_only:		dir_list="$dir_list --with-boostvector"
#_build_test_only:	fi
	fi
	if [ -e $EIGEN_DIR/include/Eigen ]
	then
		dir_list="$dir_list 
			EIGEN_DIR=$EIGEN_DIR"
#_build_test_only:	dir_list="$dir_list --with-eigenvector"
	fi
	if [ -e $FADBAD_DIR/include/FADBAD++ ]
	then
		dir_list="$dir_list 
			FADBAD_DIR=$FADBAD_DIR"
	fi
	if [ -e $IPOPT_DIR/include/coin/IpIpoptApplication.hpp ]
	then
		dir_list="$dir_list 
		IPOPT_DIR=$IPOPT_DIR"
	fi
	if [ -e $SACADO_DIR/include/Sacado.hpp ]
	then
		dir_list="$dir_list 
			SACADO_DIR=$SACADO_DIR"
	fi
	# Use =int (a signed type) to do more checking for 
	# slicing from size_t to addr_t.
	special_types=""
#_build_test_only:	special_types="TAPE_ADDR_TYPE=int TAPE_ID_TYPE=int"
	#
	dir_list=`echo $dir_list | sed -e 's|\t\t*| |g'`
	cxx_flags="-Wall -ansi -pedantic-errors -std=c++98 -Wshadow"
#_build_test_only:	if [ -e $EIGEN_DIR/include/Eigen ]
#_build_test_only:	then
#_build_test_only:	cxx_flags="-Wall -ansi -pedantic-errors -std=c++98 -Wno-long-long"
#_build_test_only:	fi
cat << EOF
../configure > $log_file \\
$dir_list \\
CXX_FLAGS=\"$cxx_flags\" \\
$special_types OPENMP_FLAGS=-fopenmp \\
--with-sparse_list --with-Documentation \\
--with-implicit_ctor
EOF
	#
	../configure > $log_dir/$log_file \
		$dir_list \
		CXX_FLAGS="$cxx_flags" \
		$special_types OPENMP_FLAGS=-fopenmp \
		--with-sparse_list --with-Documentation \
		--with-implicit_ctor
	#
	for file in $configure_file_list
	do
		echo "cp $file ../$file"
		cp $file ../$file
	done
	#
	echo "OK: ./build.sh configure"
	exit 0
fi
# -----------------------------------------------------------------------------
if [ "$1" = "dist" ] 
then
	# ----------------------------------------------------------------------
	# Things to do in the original source directory
	# ----------------------------------------------------------------------
	echo "Only include the *.xml version of the documentation in distribution"
	if ! grep < doc.omh > /dev/null \
		'This comment is used to remove the table below' 
	then
		echo "Missing comment expected in doc.omh"
		exit 1
	fi
	echo "sed -i.save doc.omh ..."
	sed -i.save doc.omh \
		-e '/This comment is used to remove the table below/,/$tend/d'
	#
	if [ -e doc ]
	then
		echo "rm -r doc"
		      rm -r doc
	fi
	#
	echo "bin/run_omhelp.sh xml"
	if ! bin/run_omhelp.sh xml
	then
		echo "mv doc.omh.save doc.omh"
	      	mv doc.omh.save doc.omh
		exit 1
	fi
	#
	echo "mv doc.omh.save doc.omh"
	      mv doc.omh.save doc.omh
	#
	# Run automated checking of file names in original source directory
	list="
		check_define.sh
		check_example.sh
		check_if.sh
		check_include_def.sh
		check_include_file.sh
		check_include_omh.sh
		check_makefile.sh
		check_op_code.sh
		check_replace.sh
		check_svn_id.sh
		check_verbatim.sh
	"
	for check in $list 
	do
		echo "bin/$check"
		      bin/$check
	done
	# ----------------------------------------------------------------------
	# Things to do in the build directory
	# ----------------------------------------------------------------------
	echo "cd build"
	      cd build
	#
	if [ -e cppad-$version ]
	then
		echo "rm -rf cppad-$version"
		      rm -rf cppad-$version
	fi
	for file in cppad-*.tgz 
	do
		if [ -e $file ]
		then
			echo "rm $file"
			rm $file
		fi
	done
	#
	echo "make dist"
	      make dist
	#
	if [ ! -e cppad-$version.tar.gz ]
	then
		echo "cppad-$version.tar.gz does not exist"
		echo "perhaps version is out of date"
		#
		exit 1
	fi
	# change *.tgz to *.epl.tgz
	echo "mv cppad-$version.tar.gz cppad-$version.epl.tgz"
	      mv cppad-$version.tar.gz cppad-$version.epl.tgz
	#
	echo "OK: ./build.sh dist"
	exit 0
fi
# -----------------------------------------------------------------------------
# omhelp comes after dist because dist only includes one help output
if [ "$1" = "omhelp" ] 
then
	if ! grep < doc.omh > /dev/null \
		'This comment is used to remove the table below'
	then
		echo "doc.omh is missing a table."
		echo "Try re-running build.sh configure."
	fi
	for flag in "printable" ""
	do
		# Run xml after htm so that index.htm points to cppad.xml
		# (see run_omhelp.sh).
		for ext in htm xml
		do
			echo "bin/run_omhelp.sh $ext $flag"
			      bin/run_omhelp.sh $ext $flag
		done
	done
	#
	echo "OK: ./build.sh omhelp"
	exit 0
fi
# -----------------------------------------------------------------------------
if [ "$1" = "doxygen" ]
then
	echo "bin/run_doxygen.sh"
	bin/run_doxygen.sh
	#
	echo "OK: ./build.sh doxygen"
	exit 0
fi
# -----------------------------------------------------------------------------
if [ "$1" = "gpl" ] 
then
	# create GPL licensed version
	echo "bin/gpl_license.sh cppad-$version build build"
	bin/gpl_license.sh cppad-$version build build
	#
	echo "OK: ./build.sh gpl"
	exit 0
fi
# -----------------------------------------------------------------------------
if [ "$1" = "copy2doc" ] 
then
	for ext in epl gpl
	do
		echo "cp build/cppad-$version.$ext.tgz doc/cppad-$version.$ext.tgz"
		cp build/cppad-$version.$ext.tgz doc/cppad-$version.$ext.tgz
	done
	#
	echo "cp -r doxydoc doc/doxydoc"
	cp -r doxydoc doc/doxydoc
	#
	echo "cp *.log doc"
	cp *.log doc
	#
	echo "OK: ./build.sh copy2doc"
	exit 0
fi
# -----------------------------------------------------------------------------
if [ "$1" == "all" ]
then
	list="
		version
		automake
		configure
		dist
		omhelp
		doxygen
		gpl
		copy2doc
	"
	if [ "$version_type" != "trunk" ]
	then
		# only use the help built during the build.sh dist command
		list=`echo $list | sed -e 's|omhelp||'`
	fi
	echo "./build.sh $list"
	./build.sh $list
	echo "OK: ./build.sh all"
	exit 0
fi
# -----------------------------------------------------------------------------
if [ "$1" = "test" ] 
then
	log_dir=`pwd`
	log_file="build_test.log"
	# --------------------------------------------------------------
	# Things to do in the distribution directory
	# --------------------------------------------------------------
	#
	# start log for this test
	echo "date > $log_file"
	      date > $log_dir/$log_file
	# ----------------------------------------------------------------------
	# Things to do in the build directory
	# ----------------------------------------------------------------------
	echo "cd build"
	echo "cd build" >> $log_dir/$log_file
	      cd build
	#
	# erase old distribution directory
	if [ -e cppad-$version ]
	then
		echo "rm -rf cppad-$version"
		echo "rm -rf cppad-$version" >> $log_dir/$log_file
		      rm -rf cppad-$version
	fi
	#
	# create distribution directory
	echo "tar -xzf cppad-$version.epl.tgz"
	echo "tar -xzf cppad-$version.epl.tgz" >> $log_dir/$log_file
	      tar -xzf cppad-$version.epl.tgz
	#
	# ----------------------------------------------------------------------
	# Things to do in the build/disribution directory
	# ----------------------------------------------------------------------
	echo "cd cppad-$version"
	echo "cd cppad-$version" >> $log_dir/$log_file
	      cd cppad-$version
	#
	# build_test_only configuration
	echo "sed -i -e 's|^#_build_test_only:||' build.sh"
	sed -i -e 's|^#_build_test_only:||' build.sh
	#
	echo "./build.sh configure >> $log_file" 
	      ./build.sh configure >> $log_dir/$log_file
	#
	# test user documentation
	echo "bin/run_omhelp.sh xml  >> $log_file"
	      bin/run_omhelp.sh xml  >> $log_dir/$log_file
	# 
	# test developer documentation
	echo "./build.sh doxygen   >> $log_file"
	      ./build.sh doxygen   >> $log_dir/$log_file
	#
	# ----------------------------------------------------------------------
	# Things to do in the build/disribution/build directory
	# ----------------------------------------------------------------------
	echo "cd build"
	echo "cd build" >> $log_dir/$log_file
	      cd build
	#
	dir=`pwd` 
	echo "To see progress in the 'make test' log file use"
	echo "	../temp.sh ( OK | All | tail | follow | file )"
	cat << EOF > $log_dir/../temp.sh
#! /bin/bash -e
case "\$1" in

	OK)
	grep OK $dir/make_test.log
	exit 0
	;;

	All)
	grep All $dir/make_test.log
	exit 0
	;;

	tail)
	tail $dir/make_test.log
	exit 0
	;;

	follow)
	tail -f $dir/make_test.log
	exit 0
	;;

	file)
	echo "$dir/make_test.log"
	exit 0
	;;

	*)
	echo "usage: ../temp.sh option"
	echo "where option is one of following: OK, All, tail, follow, file."
	exit 1
esac
EOF
	chmod +x $log_dir/../temp.sh
	#
	# build and run all the tests
	echo "make test                >& make_test.log"
	      make test                >& make_test.log
	#
	echo "rm ../temp.sh"
	rm $log_dir/../temp.sh
	#
	echo "cat make_test.log        >> $log_file"
	      cat make_test.log        >> $log_dir/$log_file
	#
	# ignore warning in eigen (that has been reported)
	if grep ': *warning:' make_test.log
	then 
		echo "There are warnings in $dir/make_test.log"
		exit 1
	fi
	# --------------------------------------------------------------------
	echo "cd ../../.."
	cd ../../..
	# end the build_test.log file with the date and time
	echo "date >> $log_file"
	      date >> $log_dir/$log_file
	#
	echo "No errors or warnings found; see build_test.log."
	#
	echo "OK: ./build.sh test"
	exit 0
fi
# -----------------------------------------------------------------------------
# report build.sh usage error
if [ "$1" != "" ]
then
     echo "$1 is not a valid option"
fi
#
if [ "$version_type" == "trunk" ]
then
	all_cases="run all the options above in order"
else
	all_cases="run all the options above in order with exception of omhelp"
fi
cat << EOF
usage: ./build.sh option_1 option_2 ...

options                                                             requires
-------                                                             --------
version:  set version in AUTHORS, configure.ac, configure, ...
omhelp:   build all formats of user documentation in doc/*. 
automake: run the tools required by autoconf and automake.
configure:run the configure script in the build directory.          automake
dist:     create the distribution file build/cppad-version.epl.tgz. configure
doxygen:  build developer documentation in doxydoc/*.               configure
gpl:      create build/*.gpl.zip and build/*.epl.zip.               dist
copy2doc: copy logs, tarballs & doxygen output into doc directory.  dist,doxygen

all:      $all_cases
test:     use tarball to make test and put result in build_test.log. dist
EOF
#
exit 1