Automatically detect if libm is needed to support floordiv
This commit is contained in:
parent
f09f62e441
commit
e26391bc2f
4
Makefile
4
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
|
||||
|
8
tools/can-floor-without-libm.sh
Executable file
8
tools/can-floor-without-libm.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user