-
Notifications
You must be signed in to change notification settings - Fork 104
/
zproject_autotools.gsl
2879 lines (2598 loc) · 97.6 KB
/
zproject_autotools.gsl
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
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Generate autoconf files for project
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/zeromq/gsl for details.
#
# Copyright (c) the Contributors as noted in the AUTHORS file.
# This file is part of zproject.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
register_target ("autotools", "GNU build system")
.macro generate_autoconf_files
.output "autogen.sh"
#!/usr/bin/env sh
$(project.GENERATED_WARNING_HEADER:)
# Script to generate all required files from fresh git checkout.
if [ ! -f src/Makemodule-local.am ] ; then
echo "autogen.sh: generating a dummy src/Makemodule-local.am to fulfill dependencies." 1>&2
touch src/Makemodule-local.am
fi
# Debian and Ubuntu do not shipt libtool anymore, but OSX does not ship libtoolize.
command -v libtoolize >/dev/null 2>&1
if [ $? -ne 0 ]; then
command -v libtool >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "autogen.sh: error: could not find libtool. libtool is required to run autogen.sh." 1>&2
exit 1
fi
fi
command -v autoreconf >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "autogen.sh: error: could not find autoreconf. autoconf and automake are required to run autogen.sh." 1>&2
exit 1
fi
command -v pkg-config >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "autogen.sh: error: could not find pkg-config. pkg-config is required to run autogen.sh." 1>&2
exit 1
fi
mkdir -p ./config
if [ $? -ne 0 ]; then
echo "autogen.sh: error: could not create directory: ./config." 1>&2
exit 1
fi
autoreconf --install --force --verbose -I config
status=$?
if [ $status -ne 0 ]; then
echo "autogen.sh: error: autoreconf exited with status $status" 1>&2
exit 1
fi
$(project.GENERATED_WARNING_HEADER:)
.chmod_x ("autogen.sh")
.if file.exists ("version.sh")
. echo "WARNING: Your workspace has a 'version.sh' - note that zproject no longer generates this, and its presence may confuse your builds; you may want to remove it (or bump manually for project version '$(project->version.major).$(project->version.minor).$(project->version.patch)')"
.endif
.# Generate infrastructure for services
.# This need to be done prior to configure.ac, otherwise service files
.# will not be listed in AC_CONFIG_FILES directive
.for project.main where ( defined(main.service) & main.service > 0 )
.if ( main.service ?= 1 | main.service ?= 3 )
. if !file.exists ("src/$(main.name).service.in")
. output "src/$(main.name).service.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=$(main.name) service
After=network.target
# Requires=network.target
# Conflicts=shutdown.target
# PartOf=$(project.name).target
[Service]
Type=simple
# User=@uid@
Environment="prefix=@prefix@"
Environment='SYSTEMD_UNIT_FULLNAME=%n'
. if ( !defined(main.no_config) | main.no_config ?= 0 )
ExecStart=@prefix@/bin/$(main.name) @sysconfdir@/@PACKAGE@/$(main.name).cfg
. else
ExecStart=@prefix@/bin/$(main.name)
. endif
Restart=always
[Install]
WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(main.name).service.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.if ( main.service ?= 2 | main.service ?= 3 )
. if !file.exists ("src/$(main.name)@.service.in")
. output "src/$(main.name)@.service.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=$(main.name) service for %I
After=network.target
# Requires=network.target
# Conflicts=shutdown.target
# PartOf=$(project.name).target
[Service]
Type=simple
# User=@uid@
Environment="prefix=@prefix@"
Environment='SYSTEMD_UNIT_FULLNAME=%n'
. if ( !defined(main.no_config) | main.no_config ?= 0 )
ExecStart=@prefix@/bin/$(main.name) @sysconfdir@/@PACKAGE@/$(main.name)@%i.cfg
. else
ExecStart=@prefix@/bin/$(main.name) %i
. endif
Restart=always
[Install]
WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(main.name)@.service.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.endfor
.#
.#
.#
.# Prepare timer units, assuming they restart the corresponding service units
.for project.main where ( defined(main.timer) & main.timer > 0 )
.if ( main.timer ?= 1 | main.timer ?= 3 )
. if !file.exists ("src/$(main.name).timer.in")
. output "src/$(main.name).timer.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=Timer to regularly trigger the job done by $(main.name) service
PartOf=timers.target
# PartOf=multi-user.target
# PartOf=$(project.name).target
[Timer]
# Time to wait after booting before we run first time
OnBootSec=30
# Regular re-runs
OnUnitActiveSec=1min
### Run every night
OnCalendar=*-*-* 04:20:00
# Run instantly if last run was skipped (e.g. system powered off)
Persistent=true
# Do not record last-execution times
Persistent=false
# Which unit to trigger (defaults to same basename):
Unit=$(main.name).service
[Install]
WantedBy=timers.target
# WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(main.name).timer.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.#
.#
.#
.if ( main.timer ?= 2 | main.timer ?= 3 )
. if !file.exists ("src/$(main.name)@.timer.in")
. output "src/$(main.name)@.timer.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=Timer to regularly trigger the job done by $(main.name) service for %I
PartOf=timers.target
# PartOf=multi-user.target
# PartOf=$(project.name).target
[Timer]
# Time to wait after booting before we run first time
OnBootSec=30
# Regular re-runs
OnUnitActiveSec=1min
### Run every night
OnCalendar=*-*-* 04:20:00
# Run instantly if last run was skipped (e.g. system powered off)
Persistent=true
# Do not record last-execution times
Persistent=false
# Which unit to trigger (defaults to same basename):
Unit=$(main.name)@%i.service
[Install]
WantedBy=timers.target
# WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(main.name)@.timer.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.endfor
.#
.#
.#
.# Generate services for non-main (accompanying bins)
.for project.bin where ( defined(bin.service) & bin.service > 0 )
.if ( bin.service ?= 1 | bin.service ?= 3 )
. if !file.exists ("src/$(bin.name).service.in")
. output "src/$(bin.name).service.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=$(bin.name) service
After=network.target
# Requires=network.target
# Conflicts=shutdown.target
# PartOf=$(project.name).target
[Service]
Type=simple
# User=@uid@
Environment="prefix=@prefix@"
Environment='SYSTEMD_UNIT_FULLNAME=%n'
. if ( !defined(bin.no_config) | bin.no_config ?= 0 )
ExecStart=@prefix@/bin/$(bin.name) @sysconfdir@/@PACKAGE@/$(bin.name).cfg
. else
ExecStart=@prefix@/bin/$(bin.name)
. endif
Restart=always
[Install]
WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(bin.name).service.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.#
.#
.#
.if ( bin.service ?= 2 | bin.service ?= 3 )
. if !file.exists ("src/$(bin.name)@.service.in")
. output "src/$(bin.name)@.service.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=$(bin.name) service for %I
After=network.target
# Requires=network.target
# Conflicts=shutdown.target
# PartOf=$(project.name).target
[Service]
Type=simple
# User=@uid@
Environment="prefix=@prefix@"
Environment='SYSTEMD_UNIT_FULLNAME=%n'
. if ( !defined(bin.no_config) | bin.no_config ?= 0 )
ExecStart=@prefix@/bin/$(bin.name) @sysconfdir@/@PACKAGE@/$(bin.name)@%i.cfg
. else
ExecStart=@prefix@/bin/$(bin.name) %i
. endif
Restart=always
[Install]
WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(bin.name)@.service.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.endfor
.#
.#
.#
.# Prepare timer units, assuming they restart the corresponding service units
.for project.bin where ( defined(bin.timer) & bin.timer > 0 )
.if ( bin.timer ?= 1 | bin.timer ?= 3 )
. if !file.exists ("src/$(bin.name).timer.in")
. output "src/$(bin.name).timer.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=Timer to regularly trigger the job done by $(bin.name) service
PartOf=timers.target
# PartOf=multi-user.target
# PartOf=$(project.name).target
[Timer]
# Time to wait after booting before we run first time
OnBootSec=30
# Regular re-runs
OnUnitActiveSec=1min
### Run every night
OnCalendar=*-*-* 04:20:00
# Run instantly if last run was skipped (e.g. system powered off)
Persistent=true
# Do not record last-execution times
Persistent=false
# Which unit to trigger (defaults to same basename):
Unit=$(bin.name).service
[Install]
WantedBy=timers.target
# WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(bin.name).timer.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.#
.#
.#
.if ( bin.timer ?= 2 | bin.timer ?= 3 )
. if !file.exists ("src/$(bin.name)@.timer.in")
. output "src/$(bin.name)@.timer.in"
# This is a skeleton created by zproject.
# You can add hand-written code here.
[Unit]
Description=Timer to regularly trigger the job done by $(bin.name) service for %I
PartOf=timers.target
# PartOf=multi-user.target
# PartOf=$(project.name).target
[Timer]
# Time to wait after booting before we run first time
OnBootSec=30
# Regular re-runs
OnUnitActiveSec=1min
### Run every night
OnCalendar=*-*-* 04:20:00
# Run instantly if last run was skipped (e.g. system powered off)
Persistent=true
# Do not record last-execution times
Persistent=false
# Which unit to trigger (defaults to same basename):
Unit=$(bin.name)@%i.service
[Install]
WantedBy=timers.target
# WantedBy=multi-user.target
# WantedBy=$(project.name).target
. close
. else
. echo "NOT regenerating an existing src/$(bin.name)@.timer.in file; you might want to move yours out of the way and re-generate the project again to get updated settings"
. endif
.endif
.endfor
.if !file.exists (".clang-format")
. output ".clang-format"
# This is a skeleton created by zproject.
# You can add hand-written code here.
BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Never
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: false
IndentBraces: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: true
BinPackArguments: true
BinPackParameters: false
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AlwaysBreakTemplateDeclarations: false
ColumnLimit: 80
MaxEmptyLinesToKeep: 2
KeepEmptyLinesAtTheStartOfBlocks: false
ContinuationIndentWidth: 2
PointerAlignment: Right
ReflowComments: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Always
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
SortIncludes: false
FixNamespaceComments: false
BreakBeforeBinaryOperators: NonAssignment
SpaceAfterTemplateKeyword: true
AlignAfterOpenBracket: Align
AlignOperands: true
BreakConstructorInitializers: AfterColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
SpaceAfterCStyleCast: true
BreakBeforeTernaryOperators: true
.else
. echo "NOT regenerating an existing .clang-format file; you might want to move yours out of the way and re-generate the project again to get updated settings"
.endif
.output "configure.ac"
$(project.GENERATED_WARNING_HEADER:)
# Note: if your project needs a customized configure script (compared to
# the code below 100% generated by zproject), please check first if your
# use-case can be handled by acinclude.m4 support in zproject_autotools.gsl
# (to AC_DEFUN an AX_PROJECT_LOCAL_HOOK, AX_PROJECT_LOCAL_HOOK_CONFIGVARS
# and/or AX_PROJECT_LOCAL_HOOK_FINAL) so you can avoid changing this file
# which would complicate re-generation of your project in the future.
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
#
AC_INIT([$(project.name)],[$(->version.major).$(->version.minor).$(->version.patch)],[$(project.email)])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
AC_CONFIG_HEADERS([src/platform.h])
AM_INIT_AUTOMAKE([subdir-objects tar-ustar dist-zip foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# This defines PACKAGE_VERSION_... in src/platform.h
PV_MAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
PV_MINOR=`echo $PACKAGE_VERSION | cut -d . -f 2`
PV_PATCH=`echo $PACKAGE_VERSION | cut -d . -f 3`
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],[$PV_MAJOR],
[$(PROJECT.PREFIX) major version])
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],[$PV_MINOR],
[$(PROJECT.PREFIX) minor version])
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCH],[$PV_PATCH],
[$(PROJECT.PREFIX) patchlevel])
# This lets us use PACKAGE_VERSION in Makefiles
AC_SUBST(PACKAGE_VERSION)
#
# Libtool -version-info (ABI version)
#
.if defined (project->abi)
# Currently $(project->abi.current):$(project->abi.revision):$(project->abi.age) ("stable"). Don't change this unless you
.else
# Currently 0:0:0 ("stable"). Don't change this unless you
.endif
# know exactly what you're doing and have read and understand
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
#
# $(project.libname) -version-info
.if defined (project->abi)
LTVER="$(project->abi.current):$(project->abi.revision):$(project->abi.age)"
.else
LTVER="0:0:0"
.endif
AC_SUBST(LTVER)
# building in a subdirectory?
AM_CONDITIONAL([USING_VPATH], [test "x${srcdir}" != "x."])
# Capture c flags
$(PROJECT.PREFIX)_ORIG_CFLAGS="${CFLAGS:-none}"
# Checks for programs
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
.if project.use_cxx
AC_PROG_CXX
AC_PROG_CXX_C_O
.endif
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_PROG_SED
AC_PROG_AWK
PKG_PROG_PKG_CONFIG
# Check endianess of the system
AC_C_BIGENDIAN
.if file.exists ("acinclude.m4")
# Optional project-local hook (acinclude.m4, add AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [whatever]) )
ifdef([AX_PROJECT_LOCAL_HOOK],
[AX_PROJECT_LOCAL_HOOK])
.endif
# See if cppcheck is in PATH; this variable unblocks the "cppcheck" recipe
# (note that "make cppcheck.xml" can be used - and perhaps fail - regardless)
AC_CHECK_PROG([WITH_CPPCHECK], [cppcheck], [true], [false])
AM_CONDITIONAL(WITH_CPPCHECK, $WITH_CPPCHECK)
# Code coverage
AC_MSG_CHECKING([whether to enable GCov])
AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no],
[With GCC Code Coverage reporting])],
[$(PROJECT.PREFIX)_GCOV="$withval"])
if test "x${$(PROJECT.PREFIX)_GCOV}" == "xyes"; then
CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
if test "x${$(PROJECT.PREFIX)_ORIG_CFLAGS}" != "xnone"; then
CFLAGS="${CFLAGS} ${$(PROJECT.PREFIX)_ORIG_CFLAGS}"
fi
AM_CONDITIONAL(WITH_GCOV, true)
AC_MSG_RESULT([yes])
else
AM_CONDITIONAL(WITH_GCOV, false)
AC_MSG_RESULT([no])
fi
# Memory mis-use detection
AC_MSG_CHECKING([whether to enable ASan])
AC_ARG_ENABLE(address-sanitizer, [AS_HELP_STRING([--enable-address-sanitizer=yes/no],
[Build with GCC Address Sanitizer instrumentation])],
[$(PROJECT.PREFIX)_ASAN="$enableval"])
if test "x${$(PROJECT.PREFIX)_ASAN}" == "xyes"; then
CFLAGS="${CFLAGS} -fsanitize=address"
CXXFLAGS="${CXXFLAGS} -fsanitize=address"
AM_CONDITIONAL(ENABLE_ASAN, true)
AC_MSG_RESULT([yes])
else
AM_CONDITIONAL(ENABLE_ASAN, false)
AC_MSG_RESULT([no])
fi
# Install Python Bindings
AC_MSG_CHECKING([whether to install Python bindings])
AC_ARG_ENABLE([bindings-python],
AS_HELP_STRING([--enable-bindings-python=yes/no],
[Install Python Bindings [default=no]]),
[ZPROJECT_BINDINGS_PYTHON=$enableval],
[ZPROJECT_BINDINGS_PYTHON=no])
if test "x$ZPROJECT_BINDINGS_PYTHON" == "xyes"; then
AM_CONDITIONAL(ENABLE_BINDINGS_PYTHON, true)
AC_MSG_RESULT([yes])
else
AM_CONDITIONAL(ENABLE_BINDINGS_PYTHON, false)
AC_MSG_RESULT([no])
fi
# See if clang-format is in PATH; the result unblocks the relevant recipes
WITH_CLANG_FORMAT=""
AS_IF([test x"$CLANG_FORMAT" = x],
[AC_PATH_PROG([CLANG_FORMAT], [clang-format], [])],
[AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [fail])])
AS_IF([test x"$CLANG_FORMAT" != x && test x"$WITH_CLANG_FORMAT" = x],
[AS_IF([test -x "$CLANG_FORMAT"],
[WITH_CLANG_FORMAT=true],
[AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [false])])])
AS_IF([test "$WITH_CLANG_FORMAT" = fail],
[AC_MSG_ERROR([Caller explicitly referenced CLANG_FORMAT=$CLANG_FORMAT which was not found])])
AM_CONDITIONAL([WITH_CLANG_FORMAT], [$WITH_CLANG_FORMAT])
# Set pkgconfigdir
AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
[Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]),
[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])
# Use the provided pkgconfigdir not only to write our pkg-config data,
# but also as an additional location to look for other packages metadata.
AS_IF([test -n "${pkgconfigdir}" -a -d "${pkgconfigdir}"],
[AS_IF([test -z "${PKG_CONFIG_PATH}"],
[PKG_CONFIG_PATH="${pkgconfigdir}"],
[PKG_CONFIG_PATH="${pkgconfigdir}:${PKG_CONFIG_PATH}"])
export PKG_CONFIG_PATH
])
# Will be used to add flags to pkg-config useful when apps want to statically link
PKGCFG_LIBS_PRIVATE=""
PKGCFG_NAMES_PRIVATE=""
# Archive user supplied flags
PREVIOUS_CFLAGS="${CFLAGS}"
PREVIOUS_LIBS="${LIBS}"
.for use where !(implied & private)
.# Far below, if the dependency search was not for a library, it will be done
.# for a program.
.# Debugging for using either a list of variants or a single name per legacy
.# (or simpler use-case) setup. Note that despite the same apparent name for
.# addressing, the variable and list contexts are different and separate.
.# Far below, if the dependency search was not for a library, it will be done
.# for a program.
.###echo "PROJECT: $(use.project) : '$(use.libname)' '$(use.pkgconfig)' '$(count(use.pkgconfig))' '$(count(use.linkname))'"
. if use.libname ?<> "" | use.pkgconfig ?<> "" | count(use.pkgconfig) > 0 | count(use.linkname) > 0
was_$(use.project:c)_check_lib_detected=no
. if optional
search_$(use.libname:c)="no"
. else
search_$(use.libname:c)="yes"
. endif
.# TOTHINK: Should this still be libname or ...
.# (loop over variants of libname, projname, linkname, pkgconfig?..)
AC_ARG_WITH([$(use.libname)],
[
AS_HELP_STRING([--with-$(use.libname)],
.# TODO: Should an explicit path win over pkgconfig?
[yes or no. Optionally specify $(use.libname) prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first])
],
[
search_$(use.libname:c)="yes"
],
[
search_$(use.libname:c)="yes"
])
AS_CASE([x"${with_$(use.libname:c)}"],
[xyes], [search_$(use.libname:c)="yes"],
[xno], [search_$(use.libname:c)="no"])
. if !optional
dnl We do not abort right now, because the maintainer/developer may have
dnl something particular in mind, e.g. to build just parts of a project.
AS_IF([test x"${search_$(use.libname:c)}" = xno],
[AC_MSG_WARN([Required dependency on $(use.project:c) was explicitly disabled during configuration by '--with-$(use.libname)=no'; subsequent full build of $(project.name) may fail])])
. endif
AS_IF([test x"${search_$(use.libname:c)}" = xyes], [
# Archive previously detected and supplied flags
PRE_SEARCH_CFLAGS="${CFLAGS}"
PRE_SEARCH_LIBS="${LIBS}"
found_pkgconfig=""
. if use.pkgconfig ?<> ""
PKG_CHECK_MODULES([$(use.project:c)], [$(use.pkgconfig) >= $(use.min_version)\
. if defined(use.max_version)
$(use.pkgconfig) <= $(use.max_version)\
. endif
. if defined(use.next_incompatible_version)
$(use.pkgconfig) < $(use.next_incompatible_version)\
. endif
],
[
. if optional
AC_DEFINE(HAVE_$(USE.AM_LIB_MACRO), 1, [The optional\
.# At least one of these values is available, per check above
. if use.pkgconfig ?<> "" & use.pkgconfig ?<> use.libname
$(use.pkgconfig) pkg-config metadata\
. endif
. if use.libname ?<> ""
$(use.libname) library\
. endif
is to be used])
. endif
was_$(use.project:c)_check_lib_detected=pkgcfg
found_pkgconfig="$(use.pkgconfig)"
],
[
. endif
.# The alternate variants can be fallbacks to main pkgconfig (if defined)
.# or standalone (if only the list is provided)
. if count(use.pkgconfig) > 0
. for use.pkgconfig as pkgconfig_variant
AC_MSG_NOTICE([Retry by looking at another variant of pkg-config metadata: $(pkgconfig_variant)])
PKG_CHECK_MODULES([$(use.project:c)], [$(pkgconfig_variant) >= $(use.min_version)\
. if defined(use.max_version)
$(pkgconfig_variant) <= $(use.max_version)\
. endif
. if defined(use.next_incompatible_version)
$(pkgconfig_variant) < $(use.next_incompatible_version)\
. endif
],
[
. if optional
AC_DEFINE(HAVE_$(USE.AM_LIB_MACRO), 1, [The\
.# At least one of these values is available, per check above
. if use.pkgconfig ?<> "" & use.pkgconfig ?<> use.libname
$(pkgconfig_variant) pkg-config metadata\
. endif
. if use.libname ?<> ""
$(use.libname) library\
. endif
is to be used])
. endif
was_$(use.project:c)_check_lib_detected=pkgcfg
found_pkgconfig="$(pkgconfig_variant)"
],
[
. endfor
. endif
.# Code below is either fallback for failed pkgconfig search(es)
.# (if string and/or list was not empty) or a standalone linkability test
. if defined(use.test) & use.libname ?<> "" & ( use.linkname ?<> "" | count(use.linkname) > 0 )
. if use.pkgconfig ?<> "" | count(use.pkgconfig) > 0
AC_MSG_NOTICE([Package\
. if ( use.pkgconfig ?<> "" & count(use.pkgconfig) > 0 ) | count(use.pkgconfig) > 1
s\
. endif
. if use.pkgconfig ?<> ""
$(use.pkgconfig)\
. endif
. if count(use.pkgconfig) > 0
. for use.pkgconfig as pkgconfig_variant
$(pkgconfig_variant)\
. endfor
. endif
not found\
. if !(use.min_version = '0.0.0') | defined(use.max_version) |defined(use.next_incompatible_version)
with needed constraints\
. endif
; falling back to defined compilability tests])
. endif
.# TODO: loop for alternate linknames - all zproject infrastructure is here
$(use.project:c)_synthetic_cflags=""
$(use.project:c)_synthetic_libs="-l$(use.linkname)"
if test -n "${with_$(use.libname:c)}" && test x"${with_$(use.libname:c)}" != xyes && test x"${with_$(use.libname:c)}" != xno; then
if test -r "${with_$(use.libname:c)}/include/$(use.header:)"; then
$(use.project:c)_synthetic_cflags="-I${with_$(use.libname:c)}/include"
$(use.project:c)_synthetic_libs="-L${with_$(use.libname:c)}/lib -l$(use.linkname)"
else
. if optional
AC_MSG_WARN([\
. else
AC_MSG_ERROR([\
. endif
Header file ${with_$(use.libname)}/include/$(use.header:) was not found. Please check $(use.libname) prefix])
fi
else
AC_CHECK_HEADER([$(use.header:)], [],
. if optional
AC_MSG_WARN([\
. else
AC_MSG_ERROR([\
. endif
Header file $(use.header:) was not found in default search paths])
)
fi
.# TODO: I doubt this really finds libraries in non-default paths (including
.# our --with-... argument above); verify and perhaps set temporary LIBS and
.# CFLAGS values with added tested location for header and library files
.# using the PRE_SEARCH_LIBS and PRE_SEARCH_CFLAGS defined above just for
.# such sort of use-cases.
AC_CHECK_LIB([$(use.prefix)], [$(use.test:)],
[
was_$(use.project:c)_check_lib_detected=yes
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -l$(use.linkname)"
. if optional
AC_DEFINE(HAVE_$(USE.AM_LIB_MACRO), 1, [The optional $(use.libname) library is to be used (as -l$(use.linkname))])
],
[])
. else
],
[AC_MSG_ERROR([cannot link with -l$(use.linkname), install $(use.libname)])])
. endif
. else
AC_MSG_WARN([Attribute 'test' is not set on zproject dependency '$(use.project)' - please ensure it is set])
. endif
.# if count of list of alternates is nonzero, close those fallback clauses too
.if count(use.pkgconfig) > 0
. for use.pkgconfig
])
. endfor
.endif
.if use.pkgconfig ?<> ""
.# if string was empty, code above was a standalone linkability test
])
.endif
dnl END of PKG_CHECK_MODULES and/or direct tests for $(use.libname:c)
AS_CASE(["x${was_$(use.project:c)_check_lib_detected}"],
[xpkgcfg], [
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE ${found_pkgconfig}\
. if (use.min_version <> '0.0.0')
>= $(use.min_version)\
. endif
. if defined(use.max_version) | defined(use.next_incompatible_version)
. if (use.min_version = '0.0.0')
>= 0.0.0
. endif
. if defined(use.max_version)
$(use.libname) <= $(use.max_version)\
. endif
. if defined(use.next_incompatible_version)
$(use.libname) < $(use.next_incompatible_version)\
. endif
. endif
"
CFLAGS="${$(use.project:c)_CFLAGS} ${CFLAGS}"
LIBS="${$(use.project:c)_LIBS} ${LIBS}"
],
[xyes], [
CFLAGS="${$(use.project:c)_synthetic_cflags} ${CFLAGS}"
LDFLAGS="${$(use.project:c)_synthetic_libs} ${LDFLAGS}"
LIBS="${$(use.project:c)_synthetic_libs} ${LIBS}"
AC_SUBST([$(use.project:c)_CFLAGS],[${$(use.project:c)_synthetic_cflags}])
AC_SUBST([$(use.project:c)_LIBS],[${$(use.project:c)_synthetic_libs}])
],
[xno], [
.# No data defined to use a linkability test, or test failed
. if optional
AC_MSG_WARN([\
. else
AC_MSG_ERROR([\
. endif
Cannot find\
. if use.pkgconfig ?<> "" | count(use.pkgconfig) > 0
pkg-config metadata for $(use.libname)\
. if defined(use.max_version) | defined(use.next_incompatible_version)
>= $(use.min_version)\
. if defined(use.max_version)
and <= $(use.max_version)\
. endif
. if defined(use.next_incompatible_version)
and < $(use.next_incompatible_version)\
. endif
. else
$(use.min_version) or higher\
. endif
. endif
.# NOTE: No excessive looping tests for list of names below...
.# it is possible, but not worth the effort for cosmetics...
. if use.libname ?<> "" & use.pkgconfig ?<> use.libname
library $(use.libname)\
. endif
. if !(defined(use.test) | use.libname ?<> "")
, and no compilability tests were defined either\
. endif
])
])
])
dnl END of enabled attempts to search for $(use.libname:c)
. else
.# TODO: Extend with support for 'optional'
.# TODO: Extend with support for '--with-...=path/to/prog' and '--without-...'
AC_CHECK_PROG(HAVE_$(USE.PROJECT:C), $(use.project:c), yes)
if test x"$HAVE_$(USE.PROJECT:C)" != x"yes" ; then
AC_MSG_ERROR([Cannot find $(use.project)])
fi
. endif
.endfor
.# Restore user supplied flags
CFLAGS="${PREVIOUS_CFLAGS}"
LIBS="${PREVIOUS_LIBS}"
AC_SUBST(pkg_config_libs_private, $PKGCFG_LIBS_PRIVATE)
AC_SUBST(pkg_config_names_private, $PKGCFG_NAMES_PRIVATE)
# Platform specific checks
$(project.name:c)_on_mingw32="no"
$(project.name:c)_on_cygwin="no"
$(project.name:c)_on_android="no"
$(project.name:c)_on_linux="no"
$(project.name:c)_on_gnu="no"
# Host specific checks
AC_CANONICAL_HOST
# Man pages are built/installed if asciidoc and xmlto are present
# --with-docs=no overrides this
AC_ARG_WITH([docs],
AS_HELP_STRING([--with-docs],
[Build and install man pages [default=yes]]),
[with_docs=$withval])
if test "x$with_docs" = "xno"; then
$(project.name:c)_build_doc="no"
$(project.name:c)_install_man="no"
else
# Determine whether or not documentation should be built and installed.
$(project.name:c)_build_doc="yes"
$(project.name:c)_install_man="yes"
# Check for asciidoc and xmlto and don't build the docs if these are not installed.
AC_CHECK_PROG($(project.name:c)_have_asciidoc, asciidoc, yes, no)
AC_CHECK_PROG($(project.name:c)_have_xmlto, xmlto, yes, no)
if test "x$$(project.name:c)_have_asciidoc" = "xno" -o "x$$(project.name:c)_have_xmlto" = "xno"; then
if test "x$with_docs" = "xyes" ; then
AC_MSG_ERROR([Build with docs was explicitly requested, but tools are not available])
fi
$(project.name:c)_build_doc="no"
# Tarballs built with 'make dist' ship with prebuilt documentation.
if ! test -f doc/$(project.name).7; then
$(project.name:c)_install_man="no"
AC_MSG_WARN([You are building an unreleased version of $(PROJECT.NAME) and asciidoc or xmlto are not installed.])
AC_MSG_WARN([Documentation will not be built and manual pages will not be installed.])
fi
fi
fi
AC_MSG_CHECKING([whether to build documentation])
AC_MSG_RESULT([$$(project.name:c)_build_doc])
AC_MSG_CHECKING([whether to install manpages])
AC_MSG_RESULT([$$(project.name:c)_install_man])
# Set some default features required by $(project.libname) code.
CPPFLAGS="-D$(PROJECT.PREFIX)_INTERNAL_BUILD -D_REENTRANT -D_THREAD_SAFE $CPPFLAGS"
# OS-specific tests
case "${host_os}" in
*linux*)
# Define on Linux to enable all library features
CPPFLAGS="-D_GNU_SOURCE -DLINUX $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_LINUX, 1, [Have Linux OS])
$(project.name:c)_on_linux="yes"
case "${host_os}" in
*android*)
AC_DEFINE($(PROJECT.PREFIX)_HAVE_ANDROID, 1, [Have Android OS])
$(project.name:c)_on_android="yes"
;;
esac
;;
*solaris*)
# Define on Solaris to enable all library features
CPPFLAGS="-D_PTHREADS $CPPFLAGS"
# Allow definitions of common OS-provided functions that are not in old standards
CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_SOLARIS, 1, [Have Solaris OS])
CFLAGS="${CFLAGS} -lsocket -lssp"
;;
*freebsd*)
# Define on FreeBSD to enable all library features
CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_FREEBSD, 1, [Have FreeBSD OS])
;;
*darwin*)
# Define on Darwin to enable all library features
CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_OSX, 1, [Have DarwinOSX OS])
;;
*netbsd*)
# Define on NetBSD to enable all library features
CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_NETBSD, 1, [Have NetBSD OS])
;;
*openbsd*)
# Define on OpenBSD to enable all library features
CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_OPENBSD, 1, [Have OpenBSD OS])
;;
*nto-qnx*)
AC_DEFINE($(PROJECT.PREFIX)_HAVE_QNXNTO, 1, [Have QNX Neutrino OS])
;;
*aix*)
AC_DEFINE($(PROJECT.PREFIX)_HAVE_AIX, 1, [Have AIX OS])
;;
*hpux*)
# Define on HP-UX to enable all library features
CPPFLAGS="-D_POSIX_C_SOURCE=200112L"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_HPUX, 1, [Have HPUX OS])
;;
*mingw32*)
# Disable format error due to incomplete ANSI C
CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS"
CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_WINDOWS, 1, [Have Windows OS])
AC_DEFINE($(PROJECT.PREFIX)_HAVE_MINGW32, 1, [Have MinGW32])
AC_CHECK_HEADERS(windows.h)
$(project.name:c)_on_mingw32="yes"
$(project.name:c)_install_man="no"
;;
*mingw64*)
# Define on MINGW64 to enable all libeary features
# Disable format error due to incomplete ANSI C
CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS"
CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS"
AC_DEFINE($(PROJECT.PREFIX)_HAVE_WINDOWS, 1, [Have Windows OS])
AC_DEFINE($(PROJECT.PREFIX)_HAVE_MINGW32, 1, [Have MinGW32])
AC_CHECK_HEADERS(windows.h)
$(project.name:c)_on_mingw32="yes"
$(project.name:c)_install_man="no"