From d79a34b32746a264104a7f28eb82444805cc0ad9 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sun, 3 Jul 2022 19:21:32 +0200 Subject: [PATCH] restore build on ancient Mac OS X (re: 22e044c3) For some reason that I can't be bothered to investigate, gcc 3.3 on my museum-grade PowerMac G5 running Mac OS X 10.3 doesn't like -lm when compiling the output{...}end blocks in features/pty and features/dll. The compilation fails silently. But some other systems require the -lm for it to work. Thankfully iffe has a syntax for trying a test repeatedly with different flags (a.k.a. prerequisites). From 'iffe --man': - Prereq grouping mark; prereqs before the first - are passed to all feature tests. Subsequent groups are attempted in left-to-right order until the first successful group is found. src/cmd/builtin/features/pty, src/lib/libdll/features/dll: - Try compiling the output{...}end block once with -lm and, if that fails, try once without -lm before erroring out. --- src/cmd/builtin/features/pty | 10 +++++++--- src/lib/libdll/features/dll | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cmd/builtin/features/pty b/src/cmd/builtin/features/pty index 317816c2c..ac3467f0f 100644 --- a/src/cmd/builtin/features/pty +++ b/src/cmd/builtin/features/pty @@ -11,7 +11,8 @@ lib openpty,_getpty,ptsname -lutil lib grantpt,unlockpt,posix_openpt stdlib.h lib cfmakeraw termios.h -tst - -lm output{ +# try once with -lm, once without +tst - -lm - - output{ #include #if _lib_ptsname #include @@ -50,8 +51,11 @@ tst - -lm output{ return 0; } }end fail{ - echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2 - exit 1 + case ${_features_pty_TRIEDONCE-no} in + no) _features_pty_TRIEDONCE=yes ;; + *) echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2 + exit 1 ;; + esac }end extern _getpty char* (int*, int, mode_t, int) diff --git a/src/lib/libdll/features/dll b/src/lib/libdll/features/dll index 525d7d1c0..b9751325d 100644 --- a/src/lib/libdll/features/dll +++ b/src/lib/libdll/features/dll @@ -73,7 +73,9 @@ tst run{ esac echo "#define _DLL_NEXT_PATH \"$lib\"" }end -tst - -lm output{ + +# try once with -lm, once without +tst - -lm - - output{ #include #if defined(__MVS__) && !defined(__SUSV3) #define __SUSV3 1 @@ -261,6 +263,9 @@ tst - -lm output{ return 0; } }end fail{ - echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2 - exit 1 + case ${_features_dll_TRIEDONCE-no} in + no) _features_dll_TRIEDONCE=yes ;; + *) echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2 + exit 1 ;; + esac }end