File: configure

package info (click to toggle)
chrony 1.30-2%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,312 kB
  • ctags: 3,032
  • sloc: ansic: 19,005; sh: 1,361; yacc: 871; perl: 323; makefile: 122
file content (687 lines) | stat: -rwxr-xr-x 18,440 bytes parent folder | download | duplicates (2)
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
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
#!/bin/sh
# =======================================================================
#
# chronyd/chronyc - Programs for keeping computer clocks accurate.
#
# Copyright (C) Richard P. Curnow  1997-2003
# Copyright (C) Miroslav Lichvar  2009, 2012-2014
#
# =======================================================================

rm -f config.h config.log

# This configure script determines the operating system type and version

if [ "x${CC}" = "x" ]; then
  MYCC="gcc"
else
  MYCC="${CC}"
fi

if [ "x${CFLAGS}" = "x" ]; then
  MYCFLAGS="-O2 -g"
else
  MYCFLAGS="${CFLAGS}"
fi

MYCPPFLAGS="${CPPFLAGS}"

if [ "x${MYCC}" = "xgcc" ]; then
  MYCFLAGS="${MYCFLAGS} -Wmissing-prototypes -Wall"
fi

MYLDFLAGS="${LDFLAGS}"

# ======================================================================
# FUNCTIONS

#{{{ test_code
test_code () {
  name=$1
  headers=$2
  cflags=$3
  ldflags=$4
  code=$5

  echo -n "Checking for $name : "

  (
    for h in $headers; do
      echo "#include <$h>"
    done
    echo "int main(int argc, char **argv) {"
    echo "$code"
    echo "return 0; }"
  ) > docheck.c

  echo "docheck.c:" >> config.log
  cat docheck.c >> config.log
  echo $MYCC $MYCFLAGS $MYCPPFLAGS $cflags -o docheck docheck.c $ldflags \
    $MYLDFLAGS >> config.log
  $MYCC $MYCFLAGS $MYCPPFLAGS $cflags -o docheck docheck.c $ldflags \
    $MYLDFLAGS >> config.log 2>&1

  if [ $? -eq 0 ]
  then
    echo "Yes"
    result=0
  else
    echo "No"
    result=1
  fi
  rm -f docheck.c docheck
  echo >> config.log
  return $result
}
#}}}
#{{{ usage
usage () {
  cat <<EOF
\`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]...

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, \`make install' will install all the files in
\`/usr/local/bin', \`/usr/local/lib' etc.  You can specify
an installation prefix other than \`/usr/local' using \`--prefix',
for instance \`--prefix=$HOME'.

For better control, use the options below.
  --disable-readline     Disable line editing support
  --without-readline     Don't use GNU readline even if it is available
  --without-editline     Don't use editline even if it is available
  --readline-dir=DIR     Specify parent of readline include and lib directories
  --readline-inc-dir=DIR Specify where readline include directory is
  --readline-lib-dir=DIR Specify where readline lib directory is
  --with-ncurses-library=DIR Specify where ncurses lib directory is
  --without-nss          Don't use NSS even if it is available
  --without-tomcrypt     Don't use libtomcrypt even if it is available
  --disable-ipv6         Disable IPv6 support
  --disable-phc          Disable PHC support
  --disable-pps          Disable PPS API support
  --disable-rtc          Don't include RTC even on Linux
  --disable-linuxcaps    Disable Linux capabilities support
  --disable-asyncdns     Disable asynchronous name resolving
  --disable-forcednsretry Don't retry on permanent DNS error
  --with-user=USER       Specify default chronyd user [root]
  --with-sendmail=PATH   Path to sendmail binary [/usr/lib/sendmail]
  --enable-debug         Enable debugging support

Fine tuning of the installation directories:
  --sysconfdir=DIR       chrony.conf location [/etc]
  --bindir=DIR           user executables [EPREFIX/bin]
  --sbindir=DIR          system admin executables [EPREFIX/sbin]
  --datarootdir=DIR      data root [PREFIX/share]
  --infodir=DIR          info documentation [DATAROOTDIR/info]
  --mandir=DIR           man documentation [DATAROOTDIR/man]
  --docdir=DIR           documentation root [DATAROOTDIR/doc/chrony]
  --localstatedir=DIR    modifiable single-machine data [/var]
  --chronyvardir=DIR     location for chrony data [LOCALSTATEDIR/lib/chrony]

Overriding system detection when cross-compiling:
  --host-system=OS       Specify system name (uname -s)
  --host-release=REL     Specify system release (uname -r)
  --host-machine=CPU     Specify machine (uname -m)

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  CPPFLAGS    C preprocessor flags, e.g. -I<include dir> if you have
              headers in a nonstandard directory <include dir>
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>

Use these variables to override the choices made by \`configure' or to help
it to find libraries and programs with nonstandard names/locations.

EOF

}
#}}}
#{{{
add_def () {
  if [ "x$2" = "x" ]; then
    echo "#define $1 1" >> config.h
  else
    echo "#define $1 $2" >> config.h
  fi
}
#}}}

# ======================================================================



OPERATINGSYSTEM=`uname -s`
VERSION=`uname -r`
MACHINE=`uname -m`

EXTRA_LIBS=""
EXTRA_CLI_LIBS=""
EXTRA_OBJECTS=""
EXTRA_DEFS=""
SYSDEFS=""

debug=0
feat_readline=1
try_readline=1
try_editline=1
try_nss=1
try_tomcrypt=1
feat_rtc=1
try_rtc=0
feat_linuxcaps=1
try_linuxcaps=0
readline_lib=""
readline_inc=""
ncurses_lib=""
feat_ipv6=1
feat_phc=1
try_phc=0
feat_pps=1
try_setsched=0
try_lockmem=0
feat_asyncdns=1
feat_forcednsretry=1
default_user="root"
mail_program="/usr/lib/sendmail"

for option
do
    case "$option" in
    --enable-debug )
      debug=1
    ;;
    --disable-readline )
      feat_readline=0
    ;;
    --without-readline )
      try_readline=0
    ;;
    --without-editline )
      try_editline=0
    ;;
    --with-readline-library=* )
      readline_lib=-L`echo $option | sed -e 's/^.*=//;'`
    ;;
    --with-readline-includes=* )
      readline_inc=-I`echo $option | sed -e 's/^.*=//;'`
    ;;
    --with-ncurses-library=* )
      ncurses_lib=-L`echo $option | sed -e 's/^.*=//;'`
    ;;
    --prefix=* | --install_prefix=* )
      SETPREFIX=`echo $option | sed -e 's/[^=]*=//;'`
    ;;
    --exec-prefix=* )
      SETEPREFIX=`echo $option | sed -e 's/[^=]*=//;'`
    ;;
    --sysconfdir=* )
      SETSYSCONFDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --bindir=* )
      SETBINDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --sbindir=* )
      SETSBINDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --datarootdir=* )
      SETDATAROOTDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --infodir=* )
      SETINFODIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --mandir=* )
      SETMANDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --docdir=* )
      SETDOCDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --localstatedir=* )
      SETLOCALSTATEDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --chronyvardir=* )
      SETCHRONYVARDIR=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --disable-rtc)
      feat_rtc=0
    ;;
    --disable-ipv6)
      feat_ipv6=0
    ;;
    --disable-phc)
      feat_phc=0
    ;;
    --disable-pps)
      feat_pps=0
    ;;
    --disable-linuxcaps)
      feat_linuxcaps=0
    ;;
    --disable-asyncdns)
      feat_asyncdns=0
    ;;
    --disable-forcednsretry)
      feat_forcednsretry=0
    ;;
    --with-user=* )
      default_user=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --with-sendmail=* )
      mail_program=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --without-nss )
      try_nss=0
    ;;
    --without-tomcrypt )
      try_tomcrypt=0
    ;;
    --host-system=* )
      OPERATINGSYSTEM=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --host-release=* )
      VERSION=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --host-machine=* )
      MACHINE=`echo $option | sed -e 's/^.*=//;'`
    ;;
    --help | -h )
      usage
      exit 0
    ;;
    * )
    echo "Unrecognized option : " $option
    esac
done

SYSTEM=${OPERATINGSYSTEM}-${MACHINE}

case $SYSTEM in
    SunOS-sun4* )
    case $VERSION in
        4.* )
            EXTRA_OBJECTS="sys_sunos.o strerror.o"
            EXTRA_LIBS="-lkvm"
            add_def SUNOS
            echo "Configuring for SunOS (" $SYSTEM "version" $VERSION ")"
        ;;
        5.* )
            EXTRA_OBJECTS="sys_solaris.o"
            EXTRA_LIBS="-lsocket -lnsl -lkvm -lelf"
            EXTRA_CLI_LIBS="-lsocket -lnsl"
            add_def SOLARIS
            echo "Configuring for Solaris (" $SYSTEM "SunOS version" $VERSION ")"
        ;;
    esac
    ;;
    Linux* )
        EXTRA_OBJECTS="sys_generic.o sys_linux.o wrap_adjtimex.o"
        try_linuxcaps=1
        try_rtc=1
        try_setsched=1
        try_lockmem=1
        try_phc=1
        add_def LINUX
        echo "Configuring for " $SYSTEM
        if [ "${MACHINE}" = "alpha" ]; then
           echo "Enabling -mieee"
           # FIXME: Should really test for GCC
           MYCFLAGS="$MYCFLAGS -mieee"
        fi
    ;;

    BSD/386-i[3456]86|FreeBSD-i386|FreeBSD-amd64 )
        # Antti Jrvinen <costello@iki.fi> reported that this system can
        # be supported with the SunOS 4.x driver files.
        EXTRA_OBJECTS="sys_sunos.o strerror.o"
        EXTRA_LIBS="-lkvm"
        add_def SUNOS
        echo "Configuring for $SYSTEM (using SunOS driver)"
    ;;
    NetBSD-* )
        EXTRA_OBJECTS="sys_netbsd.o"
        EXTRA_LIBS="-lkvm"
        SYSDEFS=""
        echo "Configuring for $SYSTEM"
    ;;
    SunOS-i86pc* )                                          
        # Doug Woodward <dougw@whistler.com> reported that this configuration
        # works for Solaris 2.8 / SunOS 5.8 on x86 platforms
        EXTRA_OBJECTS="sys_solaris.o"                
        EXTRA_LIBS="-lsocket -lnsl -lkvm -lelf"      
        EXTRA_CLI_LIBS="-lsocket -lnsl"                              
        add_def SOLARIS
        echo "Configuring for Solaris (" $SYSTEM "SunOS version" $VERSION ")" 
    ;;                                                                        
    CYGWIN32_NT-i[3456]86 )
        EXTRA_OBJECTS="sys_winnt.o"
        EXTRA_LIBS=""
        add_def WINNT
        echo "Configuring for Windows NT (Cygwin32)"
    ;;
    * )
        echo "Sorry, I don't know how to build this software on your system."
        exit 1
    ;;
esac

MATHCODE='return (int) pow(2.0, log(sqrt((double)argc)));'
if test_code 'math' 'math.h' '' '' "$MATHCODE"; then
  LIBS=""
else
  if test_code 'math in -lm' 'math.h' '' '-lm' "$MATHCODE"; then
    LIBS="-lm"
  else
    echo "Can't compile/link a program which uses sqrt(), log(), pow(), bailing out"
    exit 1
  fi
fi
  
if test_code '<stdint.h>' 'stdint.h' '' '' ''; then
  add_def HAS_STDINT_H
fi

if test_code '<inttypes.h>' 'inttypes.h' '' '' ''; then
  add_def HAS_INTTYPES_H
fi

if [ $feat_ipv6 = "1" ] && \
  test_code 'IPv6 support' 'arpa/inet.h sys/socket.h netinet/in.h' '' '' '
    struct sockaddr_in6 n;
    char p[100];
    n.sin6_addr = in6addr_any;
    return !inet_ntop(AF_INET6, &n.sin6_addr.s6_addr, p, sizeof(p));'
then
  add_def HAVE_IPV6
  if test_code 'in6_pktinfo' 'sys/socket.h netinet/in.h' '' '' '
    return sizeof(struct in6_pktinfo);'
  then
    add_def HAVE_IN6_PKTINFO
  else
    if test_code 'in6_pktinfo with _GNU_SOURCE' 'sys/socket.h netinet/in.h' \
      '-D_GNU_SOURCE' '' 'return sizeof(struct in6_pktinfo);'
    then
      add_def _GNU_SOURCE
      add_def HAVE_IN6_PKTINFO
    fi
  fi
fi

if test_code 'getaddrinfo()' 'sys/types.h sys/socket.h netdb.h' '' '' \
  'return getaddrinfo(0, 0, 0, 0);'
then
  add_def HAVE_GETADDRINFO
fi

if [ $feat_asyncdns = "1" ] && \
  test_code 'pthread' 'pthread.h' '-pthread' '' \
    'return pthread_create((void *)1, NULL, (void *)1, NULL);'
then
  add_def FEAT_ASYNCDNS
  add_def USE_PTHREAD_ASYNCDNS
  MYCFLAGS="$MYCFLAGS -pthread"
fi

timepps_h=""
if [ $feat_pps = "1" ]; then
  if test_code '<sys/timepps.h>' 'sys/timepps.h' '' '' ''; then
    timepps_h="sys/timepps.h"
    add_def HAVE_SYS_TIMEPPS_H
  else
    if test_code '<timepps.h>' 'timepps.h' '' '' ''; then
      timepps_h="timepps.h"
      add_def HAVE_TIMEPPS_H
    fi
  fi
fi

if [ "x$timepps_h" != "x" ] && \
  test_code 'PPSAPI' "string.h $timepps_h" '' '' '
    pps_handle_t h = 0;
    pps_info_t i;
    struct timespec ts;
    return time_pps_fetch(h, PPS_TSFMT_TSPEC, &i, &ts);'
then
  add_def HAVE_PPSAPI
fi

if [ $feat_linuxcaps = "1" ] && [ $try_linuxcaps = "1" ] && \
  test_code \
    linuxcaps \
    'sys/types.h pwd.h sys/prctl.h sys/capability.h grp.h' \
    '' '-lcap' \
    'prctl(PR_SET_KEEPCAPS, 1);cap_set_proc(cap_from_text("cap_sys_time=ep"));'
then
    add_def FEAT_LINUXCAPS
    EXTRA_LIBS="$EXTRA_LIBS -lcap"
fi

if [ $feat_rtc = "1" ] && [ $try_rtc = "1" ] && \
  test_code '<linux/rtc.h>' 'sys/ioctl.h linux/rtc.h' '' '' \
    'ioctl(1, RTC_UIE_ON&RTC_UIE_OFF&RTC_RD_TIME&RTC_SET_TIME, 0&RTC_UF);'
then
    EXTRA_OBJECTS="$EXTRA_OBJECTS rtc_linux.o"
    add_def FEAT_RTC
fi

if [ $feat_phc = "1" ] && [ $try_phc = "1" ] && \
  test_code '<linux/ptp_clock.h>' 'sys/ioctl.h linux/ptp_clock.h' '' '' \
    'ioctl(1, PTP_CLOCK_GETCAPS, 0);'
then
  if test_code 'clock_gettime()' 'time.h' '' '' 'clock_gettime(0, NULL);'; then
    add_def FEAT_PHC
  else
    if test_code 'clock_gettime() in -lrt' 'time.h' '' '-lrt' \
      'clock_gettime(0, NULL);'
    then
      EXTRA_LIBS="$EXTRA_LIBS -lrt"
      add_def FEAT_PHC
    fi
  fi
fi

if [ $try_setsched = "1" ] && \
  test_code \
    'sched_setscheduler()' \
    'sched.h' '' '' '
     struct sched_param sched;
     sched_get_priority_max(SCHED_FIFO);
     sched_setscheduler(0, SCHED_FIFO, &sched);'
then
  add_def HAVE_SCHED_SETSCHEDULER
fi

if [ $try_lockmem = "1" ] && \
  test_code \
    'mlockall()' \
    'sys/mman.h sys/resource.h' '' '' '
     struct rlimit rlim;
     setrlimit(RLIMIT_MEMLOCK, &rlim);
     mlockall(MCL_CURRENT|MCL_FUTURE);'
then
  add_def HAVE_MLOCKALL
fi

if [ $feat_forcednsretry = "1" ]
then
  add_def FORCE_DNSRETRY
fi

READLINE_COMPILE=""
READLINE_LINK=""
if [ $feat_readline = "1" ]; then
  if [ $try_editline = "1" ]; then
    if test_code editline 'stdio.h editline/readline.h' \
      "$readline_inc" "$readline_lib -ledit" \
      'add_history(readline("prompt"));'
    then
      add_def FEAT_READLINE
      add_def USE_EDITLINE
      READLINE_COMPILE="$readline_inc"
      READLINE_LINK="$readline_lib -ledit"
    fi
  fi

  if [ "x$READLINE_LINK" = "x" ] && [ $try_readline = "1" ]; then
    if test_code readline 'stdio.h readline/readline.h readline/history.h' \
      "$readline_inc" "$readline_lib -lreadline" \
      'add_history(readline("prompt"));'
    then
      add_def FEAT_READLINE
      READLINE_COMPILE="$readline_inc"
      READLINE_LINK="$readline_lib -lreadline"
    fi
  fi

  if [ "x$READLINE_LINK" = "x" ] && [ $try_readline = "1" ]; then
    if test_code 'readline with -lncurses' \
      'stdio.h readline/readline.h readline/history.h' \
      "$readline_inc" "$readline_lib $ncurses_lib -lreadline -lncurses" \
      'add_history(readline("prompt"));'
    then
      add_def FEAT_READLINE
      READLINE_COMPILE="$readline_inc"
      READLINE_LINK="$readline_lib $ncurses_lib -lreadline -lncurses"
    fi
  fi

  EXTRA_CLI_LIBS="$EXTRA_CLI_LIBS $READLINE_LINK"
fi

HASH_OBJ="hash_intmd5.o"
HASH_COMPILE=""
HASH_LINK=""

if [ $try_nss = "1" ]; then
  test_cflags="`pkg-config --cflags nss 2> /dev/null`"
  test_link="`pkg-config --libs-only-L nss 2> /dev/null` -lfreebl3"
  if test_code 'NSS' 'nss.h hasht.h nsslowhash.h' \
    "$test_cflags" "$test_link" \
    'NSSLOWHASH_Begin(NSSLOWHASH_NewContext(NSSLOW_Init(), HASH_AlgSHA512));'
  then
    HASH_OBJ="hash_nss.o"
    HASH_COMPILE="$test_cflags"
    HASH_LINK="$test_link"
    LIBS="$LIBS $HASH_LINK"
    add_def GENERATE_SHA1_KEY
  fi
fi

if [ "x$HASH_LINK" = "x" ] && [ $try_tomcrypt = "1" ]; then
  if test_code 'tomcrypt' 'tomcrypt.h' '-I/usr/include/tomcrypt' '-ltomcrypt' \
    'hash_memory_multi(find_hash("md5"), NULL, NULL, NULL, 0, NULL, 0);'
  then
    HASH_OBJ="hash_tomcrypt.o"
    HASH_COMPILE="-I/usr/include/tomcrypt"
    HASH_LINK="-ltomcrypt"
    LIBS="$LIBS $HASH_LINK"
    add_def GENERATE_SHA1_KEY
  fi
fi

SYSCONFDIR=/etc
if [ "x$SETSYSCONFDIR" != "x" ]; then
  SYSCONFDIR=$SETSYSCONFDIR
fi

PREFIX=/usr/local
if [ "x$SETPREFIX" != "x" ]; then
  PREFIX=$SETPREFIX
fi

EPREFIX=${PREFIX}
if [ "x$SETEPREFIX" != "x" ]; then
  EPREFIX=$SETEPREFIX
fi

BINDIR=${EPREFIX}/bin
if [ "x$SETBINDIR" != "x" ]; then
  BINDIR=$SETBINDIR
fi

SBINDIR=${EPREFIX}/sbin
if [ "x$SETSBINDIR" != "x" ]; then
  SBINDIR=$SETSBINDIR
fi

DATAROOTDIR=${PREFIX}/share
if [ "x$SETDATAROOTDIR" != "x" ]; then
  DATAROOTDIR=$SETDATAROOTDIR
fi

INFODIR=${DATAROOTDIR}/info
if [ "x$SETINFODIR" != "x" ]; then
  INFODIR=$SETINFODIR
fi

MANDIR=${DATAROOTDIR}/man
if [ "x$SETMANDIR" != "x" ]; then
  MANDIR=$SETMANDIR
fi

DOCDIR=${DATAROOTDIR}/doc/chrony
if [ "x$SETDOCDIR" != "x" ]; then
  DOCDIR=$SETDOCDIR
fi

LOCALSTATEDIR=/var
if [ "x$SETLOCALSTATEDIR" != "x" ]; then
  LOCALSTATEDIR=$SETLOCALSTATEDIR
fi

CHRONYVARDIR=${LOCALSTATEDIR}/lib/chrony
if [ "x$SETCHRONYVARDIR" != "x" ]; then
  CHRONYVARDIR=$SETCHRONYVARDIR
fi

add_def DEBUG $debug
add_def DEFAULT_CONF_FILE "\"$SYSCONFDIR/chrony.conf\""
add_def DEFAULT_USER "\"$default_user\""
add_def MAIL_PROGRAM "\"$mail_program\""

if [ -f version.txt ]; then
  add_def CHRONY_VERSION "\"`cat version.txt`\""
else
  add_def CHRONY_VERSION "\"DEVELOPMENT\""
fi

for f in Makefile chrony.conf.5 chrony.texi chronyc.1 chronyd.8
do
  echo Creating $f
  sed -e "s%@EXTRA_OBJECTS@%${EXTRA_OBJECTS}%;\
          s%@CC@%${MYCC}%;\
          s%@CFLAGS@%${MYCFLAGS}%;\
          s%@CPPFLAGS@%${MYCPPFLAGS}%;\
          s%@LIBS@%${LIBS}%;\
          s%@LDFLAGS@%${MYLDFLAGS}%;\
          s%@EXTRA_LIBS@%${EXTRA_LIBS}%;\
          s%@EXTRA_CLI_LIBS@%${EXTRA_CLI_LIBS}%;\
          s%@READLINE_COMPILE@%${READLINE_COMPILE}%;\
          s%@HASH_OBJ@%${HASH_OBJ}%;\
          s%@HASH_COMPILE@%${HASH_COMPILE}%;\
          s%@SYSCONFDIR@%${SYSCONFDIR}%;\
          s%@BINDIR@%${BINDIR}%;\
          s%@SBINDIR@%${SBINDIR}%;\
          s%@DOCDIR@%${DOCDIR}%;\
          s%@MANDIR@%${MANDIR}%;\
          s%@INFODIR@%${INFODIR}%;\
          s%@LOCALSTATEDIR@%${LOCALSTATEDIR}%;\
          s%@CHRONYVARDIR@%${CHRONYVARDIR}%;\
          s%@DEFAULT_USER@%${default_user}%;"\
          < ${f}.in > $f
done

# =======================================================================
# vim:et:sw=2:ht=2:sts=2:fdm=marker:cms=#%s