-
-
Save klange/4f712b43273344e85a78c0b4fecd8a2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile b/Makefile | |
index b23bf18..3fc2adc 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -21,6 +21,10 @@ KRKMODS = $(wildcard modules/*.krk modules/*/*.krk modules/*/*/*.krk) | |
all: ${TARGET} ${MODULES} ${TOOLS} ${GENMODS} | |
+ifneq ($(shell tools/can-floor-without-libm.sh $(CC)),yes) | |
+ LDLIBS += -lm | |
+endif | |
+ | |
ifeq (,$(findstring mingw,$(CC))) | |
CFLAGS += -pthread | |
LDLIBS += -ldl -lpthread | |
diff --git a/tools/can-floor-without-libm.sh b/tools/can-floor-without-libm.sh | |
new file mode 100755 | |
index 0000000..fc989da | |
--- /dev/null | |
+++ b/tools/can-floor-without-libm.sh | |
@@ -0,0 +1,8 @@ | |
+#!/bin/sh | |
+($1 -o /dev/null -x c - 2>/dev/null && echo "yes" || echo "no") <<END | |
+#include <stdio.h> | |
+#include <stdlib.h> | |
+int main(int argc, char * argv[]) { | |
+ return printf("%f", __builtin_floor(strtod(argv[1],NULL))); | |
+} | |
+END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment