diff options
Diffstat (limited to 'config-figure-this-out-for-me.mk')
-rw-r--r-- | config-figure-this-out-for-me.mk | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/config-figure-this-out-for-me.mk b/config-figure-this-out-for-me.mk index 60a24de..0ba409e 100644 --- a/config-figure-this-out-for-me.mk +++ b/config-figure-this-out-for-me.mk @@ -12,7 +12,7 @@ BASECONFIG !=\ if test "$$testscript" = "util/what-architecture-am-i-using"; then \ continue; \ fi; \ - os="$$(printf '%s\n' "$$testscript" | cut -d / -f 1 | tr '[a-z]' '[A-Z]')"; \ + os="$$(dirname -- "$$testscript" | tr '[a-z]' '[A-Z]')"; \ support="$${os}_SUPPORT"; \ q=\'; \ printf '%s_ != test -z "$$(%s_)" || printf %s%%s\\n%s "$$(%s)"\n' \ @@ -30,13 +30,33 @@ BASECONFIG !=\ printf '\t\tif test $$$$? -lt 2; then printf %syes\\n%s; else printf %sno\\n%s; fi; \\\n' \ $$q $$q $$q $$q; \ printf '\tfi\n'; \ - done \ + done; \ ) > .config.mk.tmp; \ printf '%s\n' .config.mk.tmp; \ fi; include $(BASECONFIG) +HAVE_BUILTIN_FFSLL !=\ + testmk=.a-$$$$.tmp; \ + testbin=.b-$$$$.tmp; \ + testsrc=.c-$$$$.tmp.c; \ + printf 'int main() {return !(1' > $$testsrc; \ + printf ' && __builtin_ffsll(%s) == %s' 0 0 1 1 2 2 4 3 0x58 4 >> $$testsrc; \ + printf ');}\n' >> $$testsrc; \ + (set -e; \ + printf '.POSIX:\n'; \ + cat -- $(BASECONFIG); \ + printf '\nall:\n'; \ + printf '\t$$(CC) -o %s %s\n' "$$testbin" "$$testsrc"; \ + ) > $$testmk; \ + if (make -f $$testmk all && ./$$testbin) 2>/dev/null >/dev/null; then \ + printf '%s\n' -DHAVE_BUILTIN_FFSLL; \ + fi; \ + rm -f -- $$testmk $$testbin $$testsrc; + +CPPFLAGS += $(HAVE_BUILTIN_FFSLL) + DOWNLOAD !=\ if test -n "$(DOWNLOAD)"; then printf '%s\n' "$(DOWNLOAD)"; \ elif curl --version >/dev/null 2>&1; then printf 'curl --\n'; \ |