-
Notifications
You must be signed in to change notification settings - Fork 31
/
configure.ac
6037 lines (5735 loc) · 192 KB
/
configure.ac
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
# This file is part of libmicrohttpd.
# (C) 2006-2021 Christian Grothoff (and other contributing authors)
# (C) 2014-2024 Evgeny Grin (Karlson2k)
#
# libmicrohttpd is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your
# option) any later version.
#
# libmicrohttpd 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with libmicrohttpd; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
#
# Process this file with autoconf to produce a configure script.
#
#
AC_PREREQ([2.64])
LT_PREREQ([2.4.0])
AC_INIT([GNU libmicrohttpd],[1.0.1],[[email protected]])
AC_CONFIG_AUX_DIR([build-aux])
MHD_AUX_DIR='build-aux' # Must be set to the same value as in the previous line
AC_CONFIG_HEADERS([MHD_config.h])
AC_CONFIG_MACRO_DIR([m4])
m4_pattern_forbid([^_?MHD_[A-Z_]+_CC_])dnl
LIB_VERSION_CURRENT=74
LIB_VERSION_REVISION=1
LIB_VERSION_AGE=62
AC_SUBST([LIB_VERSION_CURRENT])
AC_SUBST([LIB_VERSION_REVISION])
AC_SUBST([LIB_VERSION_AGE])
PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
AS_VAR_ARITH([MHD_W32_DLL_SUFF],[[$LIB_VERSION_CURRENT - $LIB_VERSION_AGE]])
AC_SUBST([PACKAGE_VERSION_MAJOR])
AC_SUBST([PACKAGE_VERSION_MINOR])
AC_SUBST([PACKAGE_VERSION_SUBMINOR])
AC_SUBST([MHD_W32_DLL_SUFF])
AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc])
CONF_FINAL_WARNS=""
MHD_LIB_CPPFLAGS=""
MHD_LIB_CFLAGS=""
MHD_LIB_LDFLAGS=""
MHD_LIBDEPS=""
# for pkg-config
MHD_REQ_PRIVATE=''
MHD_LIBDEPS_PKGCFG=''
AS_IF([test -z "$CC" && test -z "$CPP"], [
AC_MSG_CHECKING([[whether z/OS special settings are required]])
AS_IF([test `uname -s` = "OS/390"],
[
# configure binaries for z/OS
AS_IF([test -z "$CC"],
[CC=`pwd`"/contrib/xcc"
chmod +x $CC || true])
AS_IF([test -z "$CPP"],
CPP="c89 -E")
AC_MSG_RESULT([[yes]])
],
[AC_MSG_RESULT([[no]])]
)
])
AC_MSG_CHECKING([for build type])
AC_ARG_ENABLE([build-type],
[AS_HELP_STRING([[--enable-build-type=TYPE]],
[enable build TYPE, a set of configuration parameters; individual settings ]
[(asserts, sanitizers, compiler and linker flags) can be overridden by ]
[additional configure parameters (debug, debugger, neutral, release, release-compact, ]
[release-hardened) [neutral]])],
[], [enable_build_type=neutral])
AS_IF([test "x${enable_build_type}" = "x"], [enable_build_type="neutral"])
AS_VAR_IF([enable_build_type], ["no"], [enable_build_type="neutral"])
AS_VAR_IF([enable_build_type], ["yes"], [AC_MSG_ERROR([[Missing TYPE for --enable-build-type=]])])
AS_CASE([${enable_build_type}],
[debug], [AC_MSG_RESULT([debug. Defaults: enable asserts, sanitizers (if any supported), debug information, compiler optimisation for debugging])],
[debugger], [AC_MSG_RESULT([debugger. Defaults: enable asserts, disable sanitizers, debug information, no compiler optimisation, static lib])],
[neutral], [AC_MSG_RESULT([neutral. Defaults: use only user-specified compiler and linker flags])],
[release], [AC_MSG_RESULT([release. Defaults: disable asserts, enable compiler optimisations])],
[release-compact], [AC_MSG_RESULT([release-compact. Defaults: disable asserts, enable compiler optimisations for size, enable compact code])],
[release-hardened], [AC_MSG_RESULT([release-hardened. Defaults: disable asserts, enable compiler optimisations, enable linker and compiler hardening])],
[AC_MSG_ERROR([[Unknown build type: ${enable_build_type}]])]
)
AS_VAR_IF([enable_build_type], ["neutral"], [:],
[
# For all non-neutral build types do not use automatic "-g -O2" for CFLAGS
AS_IF([test -z "${CFLAGS}"], [CFLAGS=""])
]
)
AS_VAR_IF([enable_build_type], ["debugger"],
[ # Build only static version unless something else is specified by the user
AS_IF([test -z "${enable_static}" || test "x${enable_static}" = "xyes"],
[
AS_IF([test -z "${enable_shared}"],
[
enable_shared="no"
enable_static="yes"
]
)
],
[
AS_CASE([${enable_static}],[*libmicrohttpd*],
[AS_IF([test -z "${enable_shared}"], [enable_shared="no"])],
)
]
)
]
)
AS_CASE([${enable_build_type}],[debug|debugger],
[ AS_IF([test -z "${enable_silent_rules}"], [ enable_silent_rules="yes" ])]
)
AM_INIT_AUTOMAKE([gnu] [check-news] [filename-length-max=99] [tar-v7] [silent-rules] [subdir-objects])
# Checks for programs.
AC_PROG_AWK
AC_PROG_GREP
AC_PROG_FGREP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_CANONICAL_HOST
m4_version_prereq([2.70],
[
# Find C compiler and compiler options to support
# the latest C standard (C11). Fallback to C99 and C89
# if later C versions are not supported.
AC_PROG_CC
],
[
# Find C compiler and compiler options to support
# the latest C standard (C99). Fallback to C89
# if later C versions are not supported.
AC_PROG_CC_STDC
]
)
# Workaround for libgcrypt
AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]])
user_CFLAGS="$CFLAGS"
user_LDFLAGS="$LDFLAGS"
user_CPPFLAGS="$CPPFLAGS"
CFLAGS_ac=""
LDFLAGS_ac=""
CPPFLAGS_ac=""
MHD_SYS_EXT([CPPFLAGS_ac])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
m4_version_prereq([2.72],
[
AC_SYS_YEAR2038
],
[
AC_SYS_LARGEFILE
]
)
AC_FUNC_FSEEKO
LT_INIT([win32-dll])
LT_LANG([Windows Resource])
lt_prog_compiler_pic_RC="$lt_prog_compiler_pic_RC -DDLL_EXPORT" # Used only on W32
AC_ARG_ENABLE([compact-code],
[AS_HELP_STRING([[--enable-compact-code]],
[enable use of a reduced size version of the code, resulting in smaller ]
[binaries with a slight performance hit [auto]])],
[], [enable_compact_code=auto])
AS_IF([test "x${enable_compact_code}" = "x"], [enable_compact_code="auto"])
AH_TEMPLATE([[MHD_FAVOR_SMALL_CODE]], [Define to '1' to use compact code version])
AH_TEMPLATE([[MHD_FAVOR_FAST_CODE]], [Define to '1' to use fast (and larger) code version])
AS_UNSET([compact_code_MSG])
AS_CASE([${enable_compact_code}], [auto],
[
# Parameter not set.
# Check preprocessor macros
AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],
[
enable_compact_code="yes"
compact_code_MSG="enabled by preprocessor macro"
],
[],[/* no includes */]
)
AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],
[
AS_VAR_IF([enable_compact_code],["yes"],
[AC_MSG_ERROR([Both MHD_FAVOR_SMALL_CODE and MHD_FAVOR_FAST_CODE macros are defined])]
)
enable_compact_code="no"
compact_code_MSG="set by preprocessor macro"
],[],[/* no includes */]
)
AS_VAR_IF([enable_compact_code], ["auto"],
[
# No preference by preprocessor macros
AC_CACHE_CHECK([whether compiler is configured to optimize for size],
[mhd_cv_cc_optim_size],
[
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM([[
#ifndef __OPTIMIZE_SIZE__
#error Looks like compiler does not optimize for size
choke me now
#endif
]],[])
],
[mhd_cv_cc_optim_size="yes"],[mhd_cv_cc_optim_size="no"]
)
]
)
AS_VAR_IF([mhd_cv_cc_optim_size], ["yes"],
[
enable_compact_code="yes"
compact_code_MSG="enabled automatically as compiler optimizes for size"
AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1])
]
)
]
)
AS_VAR_IF([enable_compact_code], ["auto"],
[
# No preference by preprocessor macros and compiler flags
AS_CASE([${enable_build_type}],[*-compact],
[
enable_compact_code="yes"
compact_code_MSG="enabled by --enable-build-type=${enable_build_type}"
AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1])
]
)
]
)
AS_VAR_IF([enable_compact_code], ["auto"],
[
# No preference
enable_compact_code="no"
compact_code_MSG="by default"
AC_DEFINE([MHD_FAVOR_FAST_CODE],[1])
]
)
],
[yes],
[
compact_code_MSG="enabled by configure parameter"
AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],
[],
[AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1])],[/* no includes */]
)
AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],
[AC_MSG_ERROR([MHD_FAVOR_FAST_CODE macro is defined, --enable-compact-code could not be used])
],
[],[/* no includes */]
)
],
[no],
[
compact_code_MSG="disabled by configure parameter"
AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],
[],
[AC_DEFINE([MHD_FAVOR_FAST_CODE],[1])],[/* no includes */]
)
AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],
[AC_MSG_ERROR([MHD_FAVOR_SMALL_CODE macro is defined, --disable-compact-code could not be used])
],
[],[/* no includes */]
)
],
[AC_MSG_ERROR([[Unknown parameter value: --enable-compact-code=${enable_compact_code}]])]
)
AC_MSG_CHECKING([whether to use a reduced size version of the code])
AC_MSG_RESULT([${enable_compact_code} (${compact_code_MSG})])
CFLAGS="${user_CFLAGS}"
# Compiler options to always enable (if supported)
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-fno-strict-aliasing], [-qnoansialias])
# '-qlonglong' is XLC option for C89, not used with C99 or later
MHD_CHECK_ADD_CC_CFLAG([-qlonglong], [CFLAGS_ac])
# Set basic optimisation flags
AS_VAR_IF([enable_build_type],["neutral"],[],
[ # Any non-neutral build types
AC_CACHE_CHECK([whether workarounds for clang or clang-based compiler are required],
[mhd_cv_cc_clang_based],
[
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if ! defined(__clang__) && ! defined(__llvm__)
#error Compiler is not clang-based
choke me now
#endif
]]
)
],
[mhd_cv_cc_clang_based="yes"],[mhd_cv_cc_clang_based="no"]
)
]
)
]
)
AS_CASE([${enable_build_type}],[debug|debugger],
[ # Debug build or build for walking with debugger
CFLAGS="${user_CFLAGS}"
AS_VAR_IF([enable_build_type],["debug"],
[
# Clang has ASAN (pointer compare) broken when '-Og' optimisations are used
AS_IF([test "x${enable_sanitizers}" != "xno" && test "x${mhd_cv_cc_clang_based}" = "xyes"],
[MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])],
[MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Og], [-O0])]
)
],
[MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
]
)
AS_CASE([${enable_build_type}],[release|release-*],
[ # All release types
AS_VAR_IF([enable_build_type],["release-compact"],
[
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
[AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
[MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_SMALL_CODE=1])],
[/* no includes */])],[/* no includes */])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${user_CFLAGS}"
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Oz], [-Os], [-O])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
],
[ # All non-compact release types
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
[AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
[MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_FAST_CODE=1])],
[/* no includes */])],[/* no includes */])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${user_CFLAGS}"
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-O2], [-O])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
]
)
]
)
AS_VAR_IF([enable_build_type],["neutral"],[],
[ # Any non-neutral build types
MHD_CHECK_ADD_CC_CFLAGS([-Wall -Wnull-dereference], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wdeclaration-after-statement -Wimplicit -Wnested-externs], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wredundant-decls -Wtrampolines -Wunsafe-loop-optimizations], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wpoison-system-directories], [CFLAGS_ac])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${user_LDFLAGS}"
MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac])
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
AS_CASE([${enable_build_type}],[debug|debugger],
[ # Debug build or build for walking with debugger
CFLAGS="${user_CFLAGS}"
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-ggdb3], [-g3], [-ggdb], [-g])
MHD_CHECK_ADD_CC_CFLAGS([-Wextra -Wdouble-promotion], [CFLAGS_ac])
MHD_FIND_ADD_CC_CFLAG_IFELSE(
[
# clang produce warning when string pointer is used as a format specifier for v*printf() function
AS_VAR_IF([mhd_cv_cc_clang_based],["yes"],[MHD_CHECK_ADD_CC_CFLAG([-Wno-format-nonliteral], [CFLAGS_ac])])
],[],
[CFLAGS_ac], [-Wformat=2], [-Wformat]
)
MHD_CHECK_ADD_CC_CFLAGS([-Wformat-overflow -Wformat-truncation -Wformat-security -Wformat-signedness], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-include-dirs -Wshift-overflow=2 -Wstringop-overflow=4 -Walloc-zero], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wshadow -Wpointer-arith], [CFLAGS_ac])
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wshadow-all], [-Wshadow])
MHD_CHECK_ADD_CC_CFLAGS([-Wbad-function-cast -Wcast-qual -Wwrite-strings -Wconversion], [CFLAGS_ac])
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wcast-align=strict], [-Wcast-align])
MHD_CHECK_ADD_CC_CFLAGS([-Wjump-misses-init -Wlogical-op -Waggregate-return -Wstrict-prototypes], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wold-style-definition -Wmissing-declarations -Wmissing-prototypes], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wuninitialized -Winit-self -Wshift-negative-value -Wswitch-enum], [CFLAGS_ac])
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wstrict-overflow=4], [-Wstrict-overflow])
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wnormalized=nfkc], [-Wnormalized])
MHD_CHECK_ADD_CC_CFLAGS([-Walloca -Wbidi-chars=any -Warray-bounds -Wpacked -Wvariadic-macros], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wundef], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wassign-enum], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wbit-int-extension -Wbitfield-enum-conversion -Wparentheses -Wbool-operation], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wcast-function-type -Wcomma -Wcomment -Wcompound-token-split], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wconditional-uninitialized -Wdeprecated], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wdocumentation-pedantic -Wempty-init-stmt -Wenum-conversion -Wexpansion-to-defined], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wflexible-array-extensions -Wloop-analysis -Wformat-pedantic], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wformat-type-confusion -Wfour-char-constants], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wgcc-compat -Wgnu-anonymous-struct -Wgnu-compound-literal-initializer], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-conditional-omitted-operand -Wgnu-designator -Wgnu-empty-initializer], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-empty-struct -Wgnu-flexible-array-initializer -Wgnu-folding-constant], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-null-pointer-arithmetic -Wgnu-pointer-arith -Wgnu-redeclared-enum], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-union-cast -Wgnu-variable-sized-type-not-at-end -Widiomatic-parentheses], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-noreturn -Wmissing-variable-declarations -Wnested-anon-types], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wnewline-eof -Wover-aligned -Wredundant-parens], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wshift-sign-overflow -Wtautological-compare -Wunaligned-access], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wunused -Wzero-as-null-pointer-constant -Wzero-length-array], [CFLAGS_ac])
MHD_CHECK_CC_CFLAG([-Wused-but-marked-unused],[CFLAGS_ac],
[
AC_CACHE_CHECK([whether $[]CC -Wused-but-marked-unused works with system headers],
[mhd_cv_wused_but_marked_unused_sys_header],
[
SAVE_ac_c_werror_flag="$ac_c_werror_flag"
ac_c_werror_flag="yes"
CFLAGS="${CFLAGS_ac} -Wused-but-marked-unused ${user_CFLAGS}"
AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE([[
#include <stdio.h>
int main(void)
{
char buf[16];
return (int) snprintf(buf, 16, "test");
}
]]
)
],
[mhd_cv_wused_but_marked_unused_sys_header="yes"],
[mhd_cv_wused_but_marked_unused_sys_header="no"]
)
ac_c_werror_flag="$SAVE_ac_c_werror_flag"
]
)
AS_VAR_IF([mhd_cv_wused_but_marked_unused_sys_header],["yes"],
[MHD_APPEND_FLAG_TO_VAR([CFLAGS_ac],[-Wused-but-marked-unused])]
)
]
)
#
# Removed flags:
#
# -Wdisabled-macro-expansion - warns about macros from system headers
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${user_LDFLAGS}"
MHD_CHECK_ADD_CC_LDFLAG([-Wl,--enable-long-section-names], [LDFLAGS_ac])
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
AS_CASE([${enable_build_type}],[release|release-*],
[ # All release types
CFLAGS="${user_CFLAGS}"
AS_VAR_IF([enable_build_type],["release-compact"],
[],
[ # All non-compact release types
MHD_CHECK_ADD_CC_CFLAGS([-fsched-pressure -fira-loop-pressure -fmerge-all-constants], [CFLAGS_ac]) # These flags may improve size, recheck with LTO and linker garbage collection
MHD_CHECK_ADD_CC_CFLAGS([-ftree-partial-pre -fgcse-after-reload -fipa-pta], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-fisolate-erroneous-paths-attribute -ffinite-loops -floop-nest-optimize], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-fpredictive-commoning -frename-registers], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-ftree-loop-distribute-patterns -fpeel-loops -fsplit-loops -ftree-vectorize], [CFLAGS_ac])
]
)
AS_VAR_IF([enable_build_type],["release-hardened"],
[
MHD_CHECK_ADD_CC_CFLAGS([-Wformat-security -Wstack-protector], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wuninitialized -Winit-self -Walloc-zero -Wbidi-chars=any], [CFLAGS_ac])
]
)
AS_VAR_IF([enable_build_type],["release"],
[ # Flags are not suitable for 'compact' and for 'hardened'
MHD_CHECK_ADD_CC_CFLAGS([-ffast-math -fno-trapping-math], [CFLAGS_ac])
]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
# W32-specific
LDFLAGS="${user_LDFLAGS}"
MHD_CHECK_ADD_CC_LDFLAG([-Wl,--disable-long-section-names], [LDFLAGS_ac])
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
# Additional flags are checked and added at the end of 'configure'
# Check for headers that are ALWAYS required
AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h errno.h limits.h fcntl.h], [],
[AC_MSG_ERROR([Compiling libmicrohttpd requires standard POSIX headers files])], [AC_INCLUDES_DEFAULT])
# Check for basic optional headers
AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h unistd.h \
sys/uio.h], [], [], [AC_INCLUDES_DEFAULT])
# Check for clock-specific optional headers
AC_CHECK_HEADERS([sys/time.h time.h], [], [], [AC_INCLUDES_DEFAULT])
# Check for system information and parameters optional headers
AC_CHECK_HEADERS([endian.h machine/endian.h sys/endian.h sys/byteorder.h \
sys/machine.h machine/param.h sys/param.h sys/isa_defs.h \
sys/ioctl.h], [], [], [AC_INCLUDES_DEFAULT])
# Check for network and sockets optional headers
AC_CHECK_HEADERS([sys/socket.h sys/select.h netinet/in_systm.h netinet/in.h \
arpa/inet.h netinet/ip.h netinet/tcp.h net/if.h \
netdb.h sockLib.h inetLib.h], [], [],
[AC_INCLUDES_DEFAULT
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif /* HAVE_SYS_SOCKET_H */
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif /* HAVE_NETINET_IN_SYSTM_H */
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */
#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif /* HAVE_NETINET_IP_H */
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif /* HAVE_NETINET_TCP_H */
]]
)
# Check for other optional headers
AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], [], [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADER([[search.h]],
[
MHD_CHECK_LINK_RUN([[for proper tsearch(), tfind() and tdelete()]],[[mhd_cv_sys_tsearch_usable]],
[
AS_CASE([$host_os],
[openbsd*],
[[ # Some OpenBSD versions have wrong return value for tdelete()
mhd_cv_sys_tsearch_usable='assuming no'
]],
[netbsd*],
[[ # NetBSD had leaked root node for years
mhd_cv_sys_tsearch_usable='assuming no'
]],
[[mhd_cv_sys_tsearch_usable='assuming yes']]
)
],
[
AC_LANG_SOURCE(
[[
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif /* HAVE_STDDEF_H */
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#include <stdio.h>
#include <search.h>
static int cmp_func(const void *p1, const void *p2)
{
return (*((const int *)p1)) - (*((const int *)p2));
}
int main(void)
{
int ret = 0;
void *root_ptr = NULL;
int element1 = 1;
int **element_ptr_ptr1;
int **element_ptr_ptr2;
element_ptr_ptr1 =
(int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
if (NULL == element_ptr_ptr1)
{
fprintf (stderr, "NULL pointer has been returned when tsearch() called for the first time.\n");
return ++ret;
}
if (*element_ptr_ptr1 != &element1)
{
fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the first time.\n");
return ++ret;
}
if (NULL == root_ptr)
{
fprintf (stderr, "Root pointer has not been set by tsearch().\n");
return ++ret;
}
element_ptr_ptr2 =
(int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
if (NULL == element_ptr_ptr2)
{
fprintf (stderr, "NULL pointer has been returned when tsearch() called for the second time.\n");
return ++ret;
}
if (*element_ptr_ptr2 != &element1)
{
fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the second time.\n");
++ret;
}
if (element_ptr_ptr2 != element_ptr_ptr1)
{
fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
++ret;
}
element_ptr_ptr2 =
(int **) tfind ((void*) &element1, &root_ptr, &cmp_func);
if (NULL == element_ptr_ptr2)
{
fprintf (stderr, "NULL pointer has been returned by tfind().\n");
++ret;
}
if (*element_ptr_ptr2 != &element1)
{
fprintf (stderr, "Wrong pointer has been returned when by tfind().\n");
++ret;
}
if (element_ptr_ptr2 != element_ptr_ptr1)
{
fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
++ret;
}
element_ptr_ptr1 =
(int **) tdelete ((void*) &element1, &root_ptr, &cmp_func);
if (NULL == element_ptr_ptr1)
{
fprintf (stderr, "NULL pointer has been returned by tdelete().\n");
++ret;
}
if (NULL != root_ptr)
{
fprintf (stderr, "Root pointer has not been set to NULL by tdelete().\n");
++ret;
}
return ret;
}
]]
)
],
[AC_DEFINE([[MHD_USE_SYS_TSEARCH]], [[1]], [Define to 1 if you have properly working tsearch(), tfind() and tdelete() functions.])]
)
],
[], [AC_INCLUDES_DEFAULT]
)
AM_CONDITIONAL([MHD_USE_SYS_TSEARCH], [[test "x$mhd_cv_sys_tsearch_usable" = "xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes"]])
# Optional headers used for tests
AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [],
[[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif /* HAVE_SYS_SYSCTL_H */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif /* HAVE_SYS_SOCKET_H */
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif /* HAVE_NETINET_IN_SYSTM_H */
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */
#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif /* HAVE_NETINET_IP_H */
#ifdef HAVE_NETINET_IP_ICMP_H
#include <netinet/ip_icmp.h>
#endif /* HAVE_NETINET_IP_ICMP_H */
]]
)
AC_ARG_ENABLE([compiler-hardening],
[AS_HELP_STRING([--enable-compiler-hardening], [enable compiler security checks])],
[],
[AS_CASE([${enable_build_type}],[*-hardened],
[enable_compiler_hardening='yes'],[enable_compiler_hardening='no'])]
)
AS_VAR_IF([enable_compiler_hardening],["yes"],
[
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
AC_CHECK_DECL([_FORTIFY_SOURCE],
[MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-U_FORTIFY_SOURCE])],
[],[/* no includes */])
MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-D_FORTIFY_SOURCE=2])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${user_CFLAGS}"
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-fstack-protector-strong],[-fstack-protector-all],[-fstack-protector])
MHD_CHECK_ADD_CC_CFLAGS([-fstack-clash-protection],[CFLAGS_ac])
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-ftrivial-auto-var-init=pattern],[-ftrivial-auto-var-init=zero])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
AS_IF([test "x${enable_static}" = "xyes" && test "x${pic_mode}" != "xyes"],
[
# PIE static lib can be used within non-PIE application, but
# PIE static lib cannot be used in non-PIE shared lib. Let's assume
# that static lib will not be used in shared lib
# All "pie" flags will be used automatically by libtool only
# for static library objects.
CFLAGS="${user_CFLAGS}"
# Perform tests here with "-pie" enabled
LDFLAGS="${LDFLAGS_ac} -pie ${user_LDFLAGS}"
MHD_CHECK_ADD_CC_CFLAG([-fPIE],[CFLAGS_ac],
[
MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie])
],
[
MHD_CHECK_ADD_CC_CFLAG([-fpie],[CFLAGS_ac],
[
MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie])
]
)
]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
# Linker hardening options
# Currently these options are ELF specific, they don't work on Darwin and W32
AC_ARG_ENABLE([linker-hardening],
[AS_HELP_STRING([--enable-linker-hardening], [enable linker security fixups])],
[],
[AS_CASE([${enable_build_type}],[*-hardened],
[enable_linker_hardening='yes'],[enable_linker_hardening='no'])]
)
AS_VAR_IF([enable_linker_hardening],["yes"],
[
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${user_LDFLAGS}"
MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,relro],[LDFLAGS_ac],
[MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,now],[LDFLAGS_ac])])
# Actually should be "noexec" by default, but let's try to enforce it.
MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,noexecstack],[LDFLAGS_ac])
# W32-specific. Some are enabled by default, but they will be enfored to be sure.
MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--large-address-aware -Wl,--enable-auto-image-base],[LDFLAGS_ac])
MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va],[LDFLAGS_ac])
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
MHD_BOOL
AC_C_INLINE
AS_UNSET([errattr_CFLAGS])
CFLAGS="${user_CFLAGS}"
MHD_CHECK_CC_CFLAG([-Werror=attributes],[CFLAGS_ac],
[
AC_CACHE_CHECK([whether -Werror=attributes actually works],[mhd_cv_cflag_werror_attr_works],
[
CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[[__attribute__((non_existing_attrb_dummy)) static int SimpleFunc(void) {return 3;}]],
[[int r = SimpleFunc(); if (r) return r;]]
)
],
[mhd_cv_cflag_werror_attr_works="no"],
[mhd_cv_cflag_werror_attr_works="yes"]
)
]
)
AS_VAR_IF([mhd_cv_cflag_werror_attr_works],["yes"],
[errattr_CFLAGS="-Werror=attributes"]
)
]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
AS_IF([test "x$ac_cv_c_inline" != "xno"],
[
AC_DEFINE([HAVE_INLINE_FUNCS],[1],[Define to 1 if your C compiler supports inline functions.])
AC_CACHE_CHECK([for function force inline keywords supported by $CC],[mhd_cv_cc_kwd_forceinline],
[
MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
ac_c_werror_flag=yes
mhd_cv_cc_kwd_forceinline="none"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS} $errattr_CFLAGS"
for keyword_chk in "inline __attribute__((always_inline))" __forceinline
do
AS_CASE([${keyword_chk}],
[*attribute*],
[AS_IF([test "x$errattr_CFLAGS" = "x"],[continue])]
)
AC_LINK_IFELSE([
AC_LANG_SOURCE([[
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif
static ${keyword_chk} bool cmpfn(int x, int y)
{ return x > y; }
static ${keyword_chk} int sumfn(int x, int y)
{ return x + y; }
int main(void)
{
int a = 1, b = 100, c;
if (cmpfn(a, b))
c = sumfn(a, b);
else
c = 0 - sumfn(a, b);
return (cmpfn(0, c) ? 0 : 5);
}
]]
)
],
[mhd_cv_cc_kwd_forceinline="${keyword_chk}"]
)
test "x${mhd_cv_cc_kwd_forceinline}" != "xnone" && break
done
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
AS_UNSET([MHD_SAVED_ac_c_werror_flag])
]
)
]
)
AS_IF([test "x$ac_cv_c_inline" != "xno" && test "x${mhd_cv_cc_kwd_forceinline}" != "xnone"],
[AC_DEFINE_UNQUOTED([_MHD_static_inline],[static $mhd_cv_cc_kwd_forceinline],[Define to prefix which will be used with MHD static inline functions.])]
,
[AC_DEFINE([_MHD_static_inline],[static inline],[Define to prefix which will be used with MHD static inline functions.])]
)
AC_CHECK_HEADERS([stdalign.h], [], [], [AC_INCLUDES_DEFAULT])
AC_CACHE_CHECK([[for C11 'alignof()' support]], [[mhd_cv_c_alignof]],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDALIGN_H
#include <stdalign.h>
#endif
]], [[
int var1[(alignof(int) >= 2) ? 1 : -1];
int var2[alignof(unsigned int) - 1];
int var3[(alignof(char) > 0) ? 1 : -1];
int var4[(alignof(long) >= 4) ? 1 : -1];
/* Mute compiler warnings */
var1[0] = var2[0] = var3[0] = 0;
var4[0] = 1;
if (var1[0] + var2[0] + var3[0] == var4[0])
return 1;
]])
], [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDALIGN_H
#include <stdalign.h>
#endif
]], [[
/* Should fail if 'alignof()' works */
int var1[alignof(nonexisting_type) - 1];
/* Mute compiler warnings */
var1[0] = 1;
if (var1[0] + 1 == 1)
return 1;
]])
], [[mhd_cv_c_alignof='no']], [[mhd_cv_c_alignof='yes']])
], [[mhd_cv_c_alignof='no']])
])
AS_VAR_IF([mhd_cv_c_alignof], ["yes"],
[AC_DEFINE([[HAVE_C_ALIGNOF]], [1], [Define to 1 if your compiler supports 'alignof()'])])
# Check system type
AC_MSG_CHECKING([[for target host OS]])
os_is_windows="no"
os_is_native_w32="no"
AS_CASE(["$host_os"],
[*darwin* | *rhapsody* | *macosx*],
[AC_DEFINE([OSX],[1],[This is an OS X system])
mhd_host_os='Darwin'
AC_MSG_RESULT([[$mhd_host_os]])],
[kfreebsd*-gnu],
[AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
AC_DEFINE([FREEBSD],[1],[This is a FreeBSD system])
mhd_host_os='FreeBSD kernel with GNU userland'
AC_MSG_RESULT([[$mhd_host_os]])],
[freebsd*],
[AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
AC_DEFINE([FREEBSD],[1],[This is a FreeBSD system])
mhd_host_os='FreeBSD'
AC_MSG_RESULT([[$mhd_host_os]])],
[openbsd*],
[AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
AC_DEFINE([OPENBSD],[1],[This is an OpenBSD system])
mhd_host_os='OpenBSD'
AC_MSG_RESULT([[$mhd_host_os]])],
[netbsd*],
[AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
AC_DEFINE([NETBSD],[1],[This is a NetBSD system])
mhd_host_os='NetBSD'
AC_MSG_RESULT([[$mhd_host_os]])],
[*solaris*],
[AC_DEFINE([SOLARIS],[1],[This is a Solaris system])
AC_DEFINE([_REENTRANT],[1],[Need with solaris or errno does not work])
mhd_host_os='Solaris'
AC_MSG_RESULT([[$mhd_host_os]])],
[linux-gnu],
[AC_DEFINE([LINUX],[1],[This is a Linux kernel])
mhd_host_os='GNU/Linux'
AC_MSG_RESULT([[$mhd_host_os]])],
[linux-android*],
[AC_DEFINE([LINUX],[1],[This is a Linux kernel])
mhd_host_os='Android'
AC_MSG_RESULT([[$mhd_host_os]])],
[*linux*],
[AC_DEFINE([LINUX],[1],[This is a Linux kernel])
mhd_host_os='Linux'
AC_MSG_RESULT([[$mhd_host_os]])],
[*cygwin*],
[AC_DEFINE([CYGWIN],[1],[This is a Cygwin system])
mhd_host_os='Windows/Cygwin'
AC_MSG_RESULT([[$mhd_host_os]])
os_is_windows="yes"],
[*mingw*],
[
AC_DEFINE([MINGW],[1],[This is a MinGW system])
AC_DEFINE([WINDOWS],[1],[This is a Windows system])
mhd_host_os='Windows/MinGW'
AC_MSG_RESULT([[$mhd_host_os]])
AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT])
AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
[mslibcheck=`lib 2>&1`
AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null],
[ac_cv_use_ms_lib_tool=yes],
[ac_cv_use_ms_lib_tool=no])
])
AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes"],
[AC_SUBST([MS_LIB_TOOL], [[lib]])])
AC_SUBST([lt_cv_objdir])
os_is_windows="yes"
os_is_native_w32="yes"
],
[*openedition*],
[AC_DEFINE([OS390],[1],[This is a OS/390 system])
mhd_host_os='OS/390'
AC_MSG_RESULT([[$mhd_host_os]])],
[gnu*],
[AC_DEFINE([[GNU_HURD]], [[1]], [Define to `1' if host machine runs on GNU Hurd.])
mhd_host_os='GNU Hurd'
AC_MSG_RESULT([[$mhd_host_os]])
],
[
AC_MSG_RESULT([unrecognised OS])
mhd_host_os="${host_os}"
AC_MSG_WARN([Unrecognised OS $host_os])
AC_DEFINE([OTHEROS],1,[Some strange OS])
])
AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" = "xyes" && \
test "x${os_is_native_w32}" != "xyes"]])
AS_VAR_IF([os_is_windows], ["yes"],
[
AC_MSG_CHECKING([[whether target W32 version is specified by precompiler defines]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
/* Note: check logic is reversed for easy log reading */
#ifdef WINVER
#error WINVER is defined
choke me now;
#endif
#ifdef _WIN32_WINNT
#error _WIN32_WINNT is defined
choke me now;
#endif
#ifdef NTDDI
#error NTDDI is defined
choke me now;
#endif
]],[[(void)0]])
], [[mhd_w32_ver_preselect=no]], [[mhd_w32_ver_preselect=yes]]
)
AC_MSG_RESULT([[${mhd_w32_ver_preselect}]])
AC_CHECK_HEADERS([windows.h sdkddkver.h], [], [], [AC_INCLUDES_DEFAULT])
AS_VAR_IF([mhd_w32_ver_preselect],["yes"],
[