xref: /freebsd/contrib/ntp/bootstrap (revision 276da39a)
1ea906c41SOllivier Robert#! /bin/sh
2ea906c41SOllivier Robert
3ea906c41SOllivier Robert#  This "bootstrap" script performs various pre-autoreconf actions
4ea906c41SOllivier Robert#  that are required after pulling fresh sources from the repository.
5ea906c41SOllivier Robert#
62b15cb3dSCy Schubert#  --force is supported and will be passed to autoreconf
72b15cb3dSCy Schubert#
8ea906c41SOllivier Robert#  NOTE:  THE NTP VERSION NUMBER COMES FROM packageinfo.sh
9ea906c41SOllivier Robert#
10ea906c41SOllivier Robert#  all other instances of it anywhere in the source base have propagated
11ea906c41SOllivier Robert#  from this one source.
12ea906c41SOllivier Robert#
13ea906c41SOllivier Robert#  To use the raw sources from the repository, you must have the following
14ea906c41SOllivier Robert#  tools available to you:
15ea906c41SOllivier Robert#
16ea906c41SOllivier Robert#  1.  Autoconf and Automake.
17ea906c41SOllivier Robert#
18ea906c41SOllivier Robert#  2.  lynx.  This is used to extract the COPYRIGHT file extracted from
19ea906c41SOllivier Robert#      the html documentation.
20ea906c41SOllivier Robert#
21ea906c41SOllivier Robert#  *** The following are no longer needed for simple builds from the repo
22ea906c41SOllivier Robert#  3.  AutoGen.  The repository does *not* contain the files generated from
23ea906c41SOllivier Robert#      the option definition files and it does not contain the libopts
24ea906c41SOllivier Robert#      tear-off/redistributable library.
25ea906c41SOllivier Robert#
26ea906c41SOllivier Robert#      Note: AutoGen needs GNU Guile.
27ea906c41SOllivier Robert#
28ea906c41SOllivier Robert#  4.  gunzip.  The tear-off library is a gzipped tarball.
29ea906c41SOllivier Robert
30ea906c41SOllivier Robertset -e
31ea906c41SOllivier Robert
322b15cb3dSCy Schubert(cd sntp  && ../scripts/build/genver) || {
332b15cb3dSCy Schubert    echo scripts/build/genver failed ; exit 1; }
34ea906c41SOllivier Robert
35ea906c41SOllivier Robert# autoreconf says:
36ea906c41SOllivier Robert# The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
37ea906c41SOllivier Robert# AUTOPOINT, LIBTOOLIZE, M4 are honored.
38ea906c41SOllivier Robert
39ea906c41SOllivier RobertAUTORECONF=${AUTORECONF:-autoreconf}
40ea906c41SOllivier Robert
412b15cb3dSCy Schubert# case `hostname` in
422b15cb3dSCy Schubert#  pogo.udel.edu)
432b15cb3dSCy Schubert#     if fgrep -q 4.2.4 sntp/m4/version.m4; then
442b15cb3dSCy Schubert# 	AUTOCONF=autoconf-2.59
452b15cb3dSCy Schubert# 	AUTOHEADER=autoheader-2.59
462b15cb3dSCy Schubert# 	AUTOMAKE=automake-1.9
472b15cb3dSCy Schubert# 	ACLOCAL=aclocal-1.9
482b15cb3dSCy Schubert# 	export AUTOCONF AUTOHEADER AUTOMAKE ACLOCAL
492b15cb3dSCy Schubert#     fi
502b15cb3dSCy Schubert#     ;;
512b15cb3dSCy Schubert# esac
52ea906c41SOllivier Robert
53*276da39aSCy Schubert## Old way
54ea906c41SOllivier Robert# 20060629: HMS: Let's try checking in libopts and the autogen-generated files
55ea906c41SOllivier Robert## The copy for ntp...
56ea906c41SOllivier Robert#rm -rf libopts*
57ea906c41SOllivier Robert#gunzip -c $(autoopts-config --libsrc) | (
58ea906c41SOllivier Robert#  tar -xvf -
59ea906c41SOllivier Robert#  mv libopts-*.*.* libopts )
60ea906c41SOllivier Robert
61ea906c41SOllivier Robert## The copy for sntp...
62ea906c41SOllivier Robert#rm -rf sntp/libopts*
63ea906c41SOllivier Robert#gunzip -c $(autoopts-config --libsrc) | (
64ea906c41SOllivier Robert#  cd sntp
65ea906c41SOllivier Robert#  tar -xvf -
66ea906c41SOllivier Robert#  mv libopts-*.*.* libopts )
67ea906c41SOllivier Robert
68*276da39aSCy Schubert## EOOld way
69*276da39aSCy Schubert
70*276da39aSCy Schubert## Unity test runners
71*276da39aSCy Schubert# the ruby generator must be older than the test files.
72*276da39aSCy Schubert# the test files must be older than the runner files.
73*276da39aSCy Schubert
74*276da39aSCy Schubertrunner_files=`find [B-Za-z]* -type f -name 'run-*' -print | fgrep -v /SCCS/`
75*276da39aSCy Schubertl=
76*276da39aSCy Schubertlt=
77*276da39aSCy Schubertlr=
78*276da39aSCy Schubertfor f in ${runner_files}
79*276da39aSCy Schubertdo
80*276da39aSCy Schubert    fb=`echo $f | sed -e 's/run-//'`
81*276da39aSCy Schubert    lt="$lt $fb"
82*276da39aSCy Schubert    lr="$lr $f"		# Yes, lr and runner_files are eventually the same
83*276da39aSCy Schubertdone
84*276da39aSCy Schuberttouch $lt
85*276da39aSCy Schubertecho "Touching <$lt>"
86*276da39aSCy Schubertsleep 1
87*276da39aSCy Schuberttouch $lr
88*276da39aSCy Schubertecho "Touching <$lr>"
89*276da39aSCy Schubert
90*276da39aSCy Schubert## EOUnity test runners
91ea906c41SOllivier Robert
92ea906c41SOllivier Robert## AutoGen stuff
93ea906c41SOllivier Robert
94*276da39aSCy Schubertdef_files=`find [B-Za-z]* -type f -name '*.def' -print | fgrep -v /SCCS/`
95*276da39aSCy Schubertprog_opt_files=`grep -l '^prog.name' $def_files`
96ea906c41SOllivier Robert
97ea906c41SOllivier Robert# touch the stuff generated by the opt files
98ea906c41SOllivier Robert
992b15cb3dSCy Schubertl=
1002b15cb3dSCy Schubertlh=
1012b15cb3dSCy Schubertli=
102ea906c41SOllivier Robertfor f in ${prog_opt_files}
103ea906c41SOllivier Robertdo
1042b15cb3dSCy Schubert    f=`echo $f | sed -e 's/-opts.def//' -e 's/.def//'`
1052b15cb3dSCy Schubert    dfi=`dirname $f`
1062b15cb3dSCy Schubert    dfi=`echo $dfi | sed -e 's:$:/invoke-*:'`
1072b15cb3dSCy Schubert    for i in `ls -1 $f* $dfi`
108ea906c41SOllivier Robert    do
109ea906c41SOllivier Robert	case "$i" in
1102b15cb3dSCy Schubert	 *invoke-*)
1112b15cb3dSCy Schubert	    li="$li $i"
1122b15cb3dSCy Schubert	    ;;
1132b15cb3dSCy Schubert	 *.c|*.h|*.[1-9]*man|*.[1-9]*mdoc|*.man.in|*.mdoc.in|*-opts|*.texi|*.menu)
114ea906c41SOllivier Robert	    l="$l $i"
115ea906c41SOllivier Robert	    ;;
1162b15cb3dSCy Schubert	 *.html)
1172b15cb3dSCy Schubert	    lh="$lh $i"
1182b15cb3dSCy Schubert	    ;;
119ea906c41SOllivier Robert	esac
120ea906c41SOllivier Robert    done
1212b15cb3dSCy Schubertdone
122ea906c41SOllivier Robertcase "$l" in
123ea906c41SOllivier Robert '') ;;
124ea906c41SOllivier Robert *) touch $l
1252b15cb3dSCy Schubert    echo "Touching <$l>"
1262b15cb3dSCy Schubert    sleep 1
127ea906c41SOllivier Robert    ;;
128ea906c41SOllivier Robertesac
1292b15cb3dSCy Schubertcase "$li" in
1302b15cb3dSCy Schubert '') ;;
1312b15cb3dSCy Schubert *) touch $li
1322b15cb3dSCy Schubert    echo "Touching <$li>"
1332b15cb3dSCy Schubert    sleep 1
1342b15cb3dSCy Schubert    ;;
1352b15cb3dSCy Schubertesac
1362b15cb3dSCy Schubertcase "$lh" in
1372b15cb3dSCy Schubert '') ;;
1382b15cb3dSCy Schubert *) touch $lh
1392b15cb3dSCy Schubert    echo "Touching <$lh>"
1402b15cb3dSCy Schubert    ;;
1412b15cb3dSCy Schubertesac
142ea906c41SOllivier Robert
143ea906c41SOllivier Robert## EOAutoGen stuff
144ea906c41SOllivier Robert
145*276da39aSCy Schubert## Yacc/bison files
146*276da39aSCy Schubert
1472b15cb3dSCy Schubert# Yacc/bison files ntp_parser.[ch] so we don't require the tool if
1482b15cb3dSCy Schubert# ntp_parser.y hasn't been updated.  At the same time, keyword-gen-utd
1492b15cb3dSCy Schubert# and ntp_keyword.h which are derived from ntp_parser.h and
1502b15cb3dSCy Schubert# keyword-gen.c.
1512b15cb3dSCy Schubert
1522b15cb3dSCy Schuberttouch ntpd/ntp_parser.[ch] ntpd/keyword-gen-utd ntpd/ntp_keyword.h
1532b15cb3dSCy Schubert
154*276da39aSCy Schubert## EOYacc/bison files
155*276da39aSCy Schubert
156ea906c41SOllivier Robertcp bincheck.mf sntp/
1572b15cb3dSCy Schubertcp depsver.mf sntp/
158ea906c41SOllivier Robert
1592b15cb3dSCy Schubert${AUTORECONF} -i -v "$@"
160ea906c41SOllivier Robert
1612b15cb3dSCy Schubert# Because some systems do not support 'test a -nt b'
1622b15cb3dSCy Schubertcase `ls -1tr config.h.in aclocal.m4 | tail -1` in
1632b15cb3dSCy Schubert aclocal.m4) touch config.h.in ;;
1642b15cb3dSCy Schubertesac
1652b15cb3dSCy Schubertcase `ls -1tr sntp/config.h.in sntp/aclocal.m4 | tail -1` in
1662b15cb3dSCy Schubert sntp/aclocal.m4) touch sntp/config.h.in ;;
1672b15cb3dSCy Schubertesac
1682b15cb3dSCy Schubertcase `ls -1tr sntp/libevent/config.h.in sntp/libevent/aclocal.m4 | tail -1` in
1692b15cb3dSCy Schubert sntp/libevent/aclocal.m4) touch sntp/libevent/config.h.in ;;
1702b15cb3dSCy Schubertesac
1712b15cb3dSCy Schubert
1722b15cb3dSCy Schubert# DH: 20110118: Due to our workaround for the AM_COND_IF bug that was
1732b15cb3dSCy Schubert# triggering the buggy recursive autoreconf, we can once again use a
1742b15cb3dSCy Schubert# single autoreconf invocation.  See
1752b15cb3dSCy Schubert# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7860
1762b15cb3dSCy Schubert# DH: 20101120: We are back to a single copy of libopts, and
1772b15cb3dSCy Schubert# once again it seems we need to run autoreconf in sntp after
1782b15cb3dSCy Schubert# the top-level run to get a correct sntp/libopts/Makefile.in.
1792b15cb3dSCy Schubert# To reduce redundancy, the top-level autoreconf uses --no-recursive.
1802b15cb3dSCy Schubert#
181ea906c41SOllivier Robert# HMS: 20060618: Now that we use separate copies of libopts
182ea906c41SOllivier Robert# we should only need the previous line.
183ea906c41SOllivier Robert#
184ea906c41SOllivier Robert## HMS: 20060615: the next line seems to be needed to make sure
185ea906c41SOllivier Robert## we get the correct srcdir path in sntp/libopts/Makefile.in
186ea906c41SOllivier Robert#rm -rf sntp/autom4te.cache
187ea906c41SOllivier Robert#
1882b15cb3dSCy Schubert# (cd sntp && ${AUTORECONF} -i -v "$@")
189