ObjFW  Diff

Differences From Artifact [63f2b5a434]:

  • File configure.ac — part of check-in [c615b62ed8] at 2024-04-16 23:50:40 on branch trunk — Don't use readdir_r

    readdir_r can easily lead to stack overflows if the path is longer than
    the space reserved for d_name in dirent. While some OSes use a length of
    MAXNAMLEN + 1, others use just 1. This could be worked around by always
    allocating a buffer of sizeof(struct dirent) + MAXNAMLEN (which would
    work only in case MAXNAMLEN is actually the longest readdir_r can
    return), but is probably not worth the risk, especially as glibc has
    entirely deprecated readdir_r and it is expected to be removed from
    POSIX. (user: js, size: 60786) [annotate] [blame] [check-ins using]

To Artifact [b5a3719683]:


1

2
3
4
5
6
7

8
9

10
11
12
13
14
15
16

1
2
3
4
5
6

7


8
9
10
11
12
13
14
15
-
+





-
+
-
-
+







AC_INIT(ObjFW, 1.2dev, js@nil.im, objfw, https://objfw.nil.im/)
AC_INIT(ObjFW, 1.1.7, js@nil.im, objfw, https://objfw.nil.im/)
AC_CONFIG_SRCDIR(src)
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_MACRO_DIR(build-aux/m4)

AC_DEFINE(OBJFW_VERSION_MAJOR, 1, [The major version of ObjFW])
AC_DEFINE(OBJFW_VERSION_MINOR, 2, [The minor version of ObjFW])
AC_DEFINE(OBJFW_VERSION_MINOR, 1, [The minor version of ObjFW])
dnl This may only be set to 1.2 once 1.2 is released
AC_SUBST(BUNDLE_VERSION, 1.1.0)
AC_SUBST(BUNDLE_VERSION, 1.1.7)
AC_SUBST(BUNDLE_SHORT_VERSION, 1.1)

for i in configure.ac build-aux/m4/*; do
	AS_IF([test $i -nt configure], [
		AC_MSG_ERROR([$i is newer than configure! Run ./autogen.sh!])
	])
done
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
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







+












+

+







arm-*-riscos*)
	AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"])
	flags="-mfloat-abi=softfp -mfpu=vfp -mlibscl"
	ASFLAGS="$ASFLAGS -mfloat-abi=softfp -mfpu=vfp"
	OBJCFLAGS="$OBJCFLAGS $flags"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
	LDFLAGS="$LDFLAGS $flags"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS $flags"

	enable_shared="no"
	enable_threads="no"
	enable_sockets="no"
	enable_files="no"
	;;
m68k-*-amigaos*)
	AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O0 -g"])
	OBJCFLAGS="$OBJCFLAGS -noixemul"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
	CPPFLAGS="$CPPFLAGS -D__NO_NET_API"
	LDFLAGS="$LDFLAGS -noixemul"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -noixemul"
	LIBS="$LIBS -ldebug"
	OBJFW_LIBS="$OBJFW_LIBS -ldebug"

	enable_files="yes"	# Required for reading ENV:
	enable_shared="no"
	with_tls="no"

	AC_SUBST(LIBBASES_M, libbases.m)
	;;
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
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







+

+













+

+













+
-
-
-
-
+
+
+
+
+
+




















+







	AC_SUBST(LIBBASES_M, libbases.m)
	;;
*-morphos*)
	AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"])
	OBJCFLAGS="$OBJCFLAGS -noixemul"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
	LDFLAGS="$LDFLAGS -noixemul"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -noixemul"
	LIBS="$LIBS -ldebug"
	OBJFW_LIBS="$OBJFW_LIBS -ldebug"

	enable_files="yes"	# Required for reading ENV:
	enable_shared="no"

	AC_SUBST(LIBBASES_M, libbases.m)
	;;
*-msdosdjgpp*)
	enable_shared="no"
	enable_threads="no"
	enable_sockets="no"
	;;
*-*-mingw*)
	LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -Wl,--allow-multiple-definition"
	LIBS="$LIBS -lversion"
	OBJFW_LIBS="$OBJFW_LIBS -lversion"

	AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}')
	;;
*-psp-*)
	AS_IF([test x"$DEVKITPSP" = x""], [
		AC_MSG_ERROR([DEVKITPSP is not set! Please set DEVKITPSP.])
	])

	AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"])
	OBJCFLAGS="$OBJCFLAGS -G0"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -G0"
	CPPFLAGS="$CPPFLAGS -I$DEVKITPSP/psp/sdk/include"
	LDFLAGS="$LDFLAGS -G0"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -G0"
	LIBS="$LIBS -L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay"
	LIBS="$LIBS -lpspge -lpspctrl -lpspsdk -lc -lpspnet"
	LIBS="$LIBS -lpspnet_inet -lpspnet_apctl -lpspnet_resolver"
	LIBS="$LIBS -lpsputility -lpspuser -lpspkernel -lgcc -lpsplibc"
	tmp="-L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay -lpspge -lpspctrl"
	tmp="$tmp -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl"
	tmp="$tmp -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lgcc"
	tmp="$tmp -lpsplibc"
	LIBS="$LIBS $tmp"
	OBJFW_LIBS="$OBJFW_LIBS $tmp"
	enable_shared="no"
	enable_threads="no"	# TODO
	enable_sockets="no"	# TODO
	check_pedantic="no"

	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
	;;
hppa*-*-hpux*)
	dnl Don't default to -g: It creates errors from the assembler and breaks
	dnl exceptions.
	AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"])
	dnl HP-UX 11.11's inttypes.h defines UINTPTR_MAX etc. to nothing. GCC's
	dnl stdint.h defines those correctly, but if inttypes.h gets included
	dnl after something included stdint.h, it gets broken again. Therefore,
	dnl always include inttypes.h as the very first thing.
	dnl We need to put this into OBJCFLAGS and not CPPFLAGS as CPPFLAGS are
	dnl also used for .S files.
	OBJCFLAGS="$OBJCFLAGS -include inttypes.h"
	dnl We need -latomic for GCC's atomics to work.
	LIBS="$LIBS -latomic"
	OBJFW_LIBS="$OBJFW_LIBS -latomic"
	;;
*-*-mint*)
	enable_shared="no"
	enable_threads="no"	# TODO
	with_tls="no"
	;;
*-apple-macos*)
167
168
169
170
171
172
173

174

175
176
177
178
179
180
181
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193







+

+








	flags="-mrvl -mcpu=750 -meabi -mhard-float"
	OBJCFLAGS="$OBJCFLAGS $flags"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
	CPPFLAGS="$CPPFLAGS -DGEKKO -I$DEVKITPRO/libogc/include"
	OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include"
	LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
	LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc"
	OBJFW_LIBS="$OBJFW_LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc"
	TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte"
	enable_shared="no"
	enable_threads="no"	# TODO
	with_tls="no"

	AC_DEFINE(OF_WII, 1, [Whether we are compiling for Wii])
	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
190
191
192
193
194
195
196
197
198





199
200
201
202
203
204
205
202
203
204
205
206
207
208


209
210
211
212
213
214
215
216
217
218
219
220







-
-
+
+
+
+
+








	flags="-mcpu=750 -meabi -mhard-float"
	OBJCFLAGS="$OBJCFLAGS $flags"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
	CPPFLAGS="-isystem $DEVKITPRO/wut/include -D__WIIU__ -D__WUT__"
	OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -isystem \$DEVKITPRO/wut/include"
	OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -D__WIIU__ -D__WUT__"
	LDFLAGS="-specs=$DEVKITPRO/wut/share/wut.specs"
	LIBS="-L$DEVKITPRO/wut/lib -L$DEVKITPRO/wut/lib/stubs -lwut"
	LDFLAGS="$LDFLAGS -specs=$DEVKITPRO/wut/share/wut.specs"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -specs=$DEVKITPRO/wut/share/wut.specs"
	tmp="-L$DEVKITPRO/wut/lib -L$DEVKITPRO/wut/lib/stubs -lwut"
	LIBS="$LIBS $tmp"
	OBJFW_LIBS="$OBJFW_LIBS $tmp"
	enable_files="no"	# TODO
	enable_shared="no"	# TODO
	enable_threads="no"	# TODO
	enable_sockets="no"	# TODO

	AC_DEFINE(OF_WII_U, 1, [Whether we are compiling for Wii U])
	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
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







+
-
+
+
+







	flags="-march=armv5te -mtune=arm946e-s -mthumb -mthumb-interwork"
	OBJCFLAGS="$OBJCFLAGS $flags"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
	CPPFLAGS="$CPPFLAGS -DARM9 -I$DEVKITPRO/libnds/include"
	OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM9 -I\$DEVKITPRO/libnds/include"
	ASFLAGS="$ASFLAGS -march=armv5te"
	LDFLAGS="$LDFLAGS -specs=ds_arm9.specs"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -specs=ds_arm9.specs"
	LIBS="$LIBS -L$DEVKITPRO/libnds/lib -lfilesystem -lfat -lnds9"
	tmp="-L$DEVKITPRO/libnds/lib -lfilesystem -lfat -lnds9"
	LIBS="$LIBS $tmp"
	OBJFW_LIBS="$OBJFW_LIBS $tmp"
	enable_shared="no"
	enable_threads="no"	# TODO
	enable_sockets="no"	# TODO
	check_pedantic="no"

	AC_DEFINE(OF_NINTENDO_DS, 1, [Whether we are compiling for Nintendo DS])
	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
245
246
247
248
249
250
251
252
253




254

255
256
257
258
259
260
261
263
264
265
266
267
268
269


270
271
272
273
274
275
276
277
278
279
280
281
282







-
-
+
+
+
+

+







	flags="-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft"
	flags="$flags -mword-relocations"
	OBJCFLAGS="$OBJCFLAGS $flags"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
	CPPFLAGS="$CPPFLAGS -DARM11 -I$DEVKITPRO/libctru/include"
	OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM11 -I\$DEVKITPRO/libctru/include"
	ASFLAGS="$ASFLAGS -march=armv6k"
	LDFLAGS="$LDFLAGS -specs=3dsx.specs -march=armv6k -mtune=mpcore"
	LDFLAGS="$LDFLAGS -mfloat-abi=hard -mtp=soft -mword-relocations"
	tmp="-specs=3dsx.specs -march=armv6k -mtune=mpcore -mfloat-abi=hard"
	tmp="$tmp -mtp=soft -mword-relocations"
	LDFLAGS="$LDFLAGS $tmp"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS $tmp"
	LIBS="$LIBS -L$DEVKITPRO/libctru/lib -lctru"
	OBJFW_LIBS="$OBJFW_LIBS -L$DEVKITPRO/libctru/lib -lctru"
	enable_shared="no"
	enable_threads="no"	# TODO
	with_tls="no"
	check_pedantic="no"

	AC_DEFINE(OF_NINTENDO_3DS, 1,
		[Whether we are compiling for Nintendo 3DS])
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
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







+
+

+


















+










+







	flags="-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE"
	OBJCFLAGS="$OBJCFLAGS $flags"
	OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
	CPPFLAGS="$CPPFLAGS -D__SWITCH__ -I$DEVKITPRO/libnx/include"
	OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -D__SWITCH__ -I$DEVKITPRO/libnx/include"
	ASFLAGS="$ASFLAGS $flags"
	LDFLAGS="$LDFLAGS -specs=$DEVKITPRO/libnx/switch.specs $flags"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS -specs=$DEVKITPRO/libnx/switch.specs"
	OBJFW_LDFLAGS="$OBJFW_LDFLAGS $flags"
	LIBS="$LIBS -L$DEVKITPRO/libnx/lib -lnx"
	OBJFW_LIBS="$OBJFW_LIBS -L$DEVKITPRO/libnx/lib -lnx"
	enable_shared="no"
	enable_threads="yes"
	enable_sockets="no"	# TODO
	check_pedantic="no"

	AC_DEFINE(OF_NINTENDO_SWITCH, 1,
		[Whether we are compiling for Nintendo Switch])
])

CPP="$OBJCPP"
CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS -DOF_COMPILING_OBJFW"
flags="-fexceptions -fobjc-exceptions -funwind-tables"
flags="$flags -fconstant-string-class=OFConstantString"
OBJCFLAGS="$OBJCFLAGS -Wall $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
dnl amiga-gcc requires -fexceptions in LDFLAGS in order to link in the glue code
dnl for registering the frames.
LDFLAGS="$LDFLAGS -fexceptions"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -fexceptions"

case "$OBJC" in
*clang*)
	case "$host" in
	mips*-*-*)
		dnl Clang generates MIPS assembly not accepted by GNU as,
		dnl however, Clang's integrated assembler doesn't accept
		dnl everything used in ObjFW's assembly files. Therefore, use
		dnl the integrated assembler for ObjC files, but not for
		dnl assembly files.
		ASFLAGS="$ASFLAGS -no-integrated-as"
		OBJCFLAGS="$OBJCFLAGS -integrated-as"
		OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -integrated-as"
		;;
	i?86-*-darwin* | x86_64-*-darwin*)
		dnl Don't use -no-integrated-as on Darwin. It breaks building
		dnl for the iOS simulator.
		;;
638
639
640
641
642
643
644
645




646
647
648
649
650
651
652
664
665
666
667
668
669
670

671
672
673
674
675
676
677
678
679
680
681







-
+
+
+
+







	], [
		AC_MSG_RESULT(exceptions unavailable!)
		AC_MSG_ERROR([Exceptions not accepted by compiler!])
	])

	AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc unwind], [
		dnl c++abi requires pthread on OpenBSD
		AS_IF([test x"$ac_lib" = x"c++abi"], [LIBS="$LIBS -lpthread"])
		AS_IF([test x"$ac_lib" = x"c++abi"], [
			LIBS="$LIBS -lpthread"
			OBJFW_LIBS="$OBJFW_LIBS -lpthread"
		])
	], [
		AC_MSG_ERROR([$raise_exception missing!])
	], [-lpthread])

	AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase)
	;;
"Apple runtime")
691
692
693
694
695
696
697

698
699
700
701

702


703
704

705


706
707
708
709
710
711
712
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







+




+
-
+
+


+
-
+
+







case "$host_os" in
darwin*)
	AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])
	AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
		AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjc"])
		AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK, ["-Wl,-reexport-lobjc"])
		LDFLAGS="$LDFLAGS -Wl,-U,_NSFoundationVersionNumber"
		OBJFW_LDFLAGS="$OBJFW_LDFLAGS -Wl,-U,_NSFoundationVersionNumber"
	])

	AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [
		AS_IF([test x"$exception_type" = x"DWARF"], [
			tmp="-Wl,-U,___gxx_personality_v0"
			LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_v0"
			LDFLAGS="$LDFLAGS $tmp"
			OBJFW_LDFLAGS="$OBJFW_LDFLAGS $tmp"
		])
		AS_IF([test x"$exception_type" = x"SjLj"], [
			tmp="-Wl,-U,___gxx_personality_sj0"
			LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_sj0"
			LDFLAGS="$LDFLAGS $tmp"
			OBJFW_LDFLAGS="$OBJFW_LDFLAGS $tmp"
		])
		AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjfwrt"])
		AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK,
			["-Wl,-reexport_framework,ObjFWRT"])
	])

	AC_CHECK_HEADERS(sysdir.h)
837
838
839
840
841
842
843

















844
845
846
847
848
849
850
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







AC_MSG_RESULT($fp_endianess)
AS_IF([test x"$fp_endianess" = x"unknown"], [
	AC_MSG_ERROR(
		[Floating point implementation does not conform to IEEE 754!])])

case "$host_cpu" in
arm* | earm*)
	AC_MSG_CHECKING(for blx)
	AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([], [
			#if !defined(__arm64__) && !defined(__arch64__) && \
			    !defined(__ARM64_ARCH_8__)
			__asm__ __volatile__ (
				"blx	r12"
			);
			#endif
		])
	], [
		AC_DEFINE(HAVE_BLX, 1, [Whether we have blx])
		AC_MSG_RESULT(yes)
	], [
		AC_MSG_RESULT(no)
	])

	AC_MSG_CHECKING(for VFP2 or above)
	AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([], [
			#if !defined(__arm64__) && !defined(__aarch64__) && \
			    !defined(__ARM64_ARCH_8__)
			__asm__ __volatile__ (
			    "vstmdb	sp!, {d0-d7}"
872
873
874
875
876
877
878
879




880
881
882
883
884
885
886
923
924
925
926
927
928
929

930
931
932
933
934
935
936
937
938
939
940







-
+
+
+
+







	])
	;;
i?86 | x86_64)
	AC_CHECK_HEADERS(cet.h)
	;;
esac

AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
AC_CHECK_LIB(m, fmod, [
	LIBS="$LIBS -lm"
	OBJFW_LIBS="$OBJFW_LIBS -lm"
])
AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex")

AC_CHECK_FUNCS(strtof truncf)

AC_CHECK_FUNC(asprintf, [
	case "$host" in
	*-*-mint*)
944
945
946
947
948
949
950
951




952
953
954
955
956
957
958
998
999
1000
1001
1002
1003
1004

1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015







-
+
+
+
+







AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
	AC_SUBST(ENCODINGS_A, "encodings.a")
])

AC_CHECK_FUNCS(arc4random arc4random_buf getrandom random, break)

AS_IF([test x"$host_os" != x"morphos"], [
	AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl")
	AC_CHECK_LIB(dl, dlopen, [
		LIBS="$LIBS -ldl"
		OBJFW_LIBS="$OBJFW_LIBS -ldl"
	])
])
AC_CHECK_HEADERS_ONCE(dlfcn.h)
case "$host_os" in
netbsd*)
	dnl dladdr exists on NetBSD, but it is completely broken.
	dnl When using it with code that uses __thread, it freezes the process
	dnl so that it has to be killed using SIGKILL.
986
987
988
989
990
991
992
993




994
995
996
997
998
999
1000
1043
1044
1045
1046
1047
1048
1049

1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060







-
+
+
+
+







		dnl Use -Wp, as we only use it for the preprocessor.
		AX_CHECK_COMPILER_FLAGS([-Wp,-pthread], [
			CPPFLAGS="$CPPFLAGS -Wp,-pthread"
		], [
			CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
		])

		AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
		AC_CHECK_LIB(pthread, main, [
			LIBS="$LIBS -lpthread"
			OBJFW_LIBS="$OBJFW_LIBS -lpthread"
		])

		AC_LINK_IFELSE([
			AC_LANG_PROGRAM([
				#include <pthread.h>
			], [
				pthread_create(NULL, NULL, NULL, NULL);
			])
1372
1373
1374
1375
1376
1377
1378

1379
1380
1381

1382
1383
1384




1385
1386
1387
1388
1389
1390
1391
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445

1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456







+



+


-
+
+
+
+







	AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}')

	case "$host_os" in
	amigaos* | morphos*)
		;;
	haiku*)
		LIBS="$LIBS -lnetwork"
		OBJFW_LIBS="$OBJFW_LIBS -lnetwork"
		;;
	mingw*)
		LIBS="$LIBS -lws2_32 -liphlpapi"
		OBJFW_LIBS="$OBJFW_LIBS -lws2_32 -liphlpapi"
		;;
	*)
		AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
		AC_CHECK_LIB(socket, socket, [
			LIBS="$LIBS -lsocket"
			OBJFW_LIBS="$OBJFW_LIBS -lsocket"
		])
		;;
	esac

	AC_CHECK_HEADER(sys/socket.h, [
		AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1,
			[Whether we have sys/socket.h])
	])
2040
2041
2042
2043
2044
2045
2046
2047

2048
2049
2050
2051
2052
2053
2054
2105
2106
2107
2108
2109
2110
2111

2112
2113
2114
2115
2116
2117
2118
2119







-
+







])

AS_IF([test x"$GOBJC" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith"

	AC_ARG_ENABLE(werror,
		AS_HELP_STRING([--disable-werror], [do not build with -Werror]))
	AS_IF([test x"$enable_werror" != x"no"], [
	AS_IF([test x"$enable_werror" = x"yes"], [
		OBJCFLAGS="$OBJCFLAGS -Werror"
	])

	old_OBJCFLAGS="$OBJCFLAGS"
	OBJCFLAGS="$OBJCFLAGS -Werror"
	AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
	AC_COMPILE_IFELSE([
2371
2372
2373
2374
2375
2376
2377


2378
2379
2380
2381
2382
2383
2384
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451







+
+







dnl We use the ObjC compiler as our assembler
AC_SUBST(AS, $OBJC)
AC_SUBST(ASFLAGS)
AC_SUBST(DEP_ASFLAGS, '${DEP_OBJCFLAGS}')

AC_SUBST(OBJFW_CPPFLAGS)
AC_SUBST(OBJFW_OBJCFLAGS)
AC_SUBST(OBJFW_LDFLAGS)
AC_SUBST(OBJFW_LIBS)

AC_SUBST(TESTS_LIBS)

AC_CONFIG_FILES([
	buildsys.mk
	extra.mk
	src/Info.plist