Automatically detect if libm is needed to support floordiv

This commit is contained in:
K. Lange 2023-03-27 09:11:40 +09:00
parent f09f62e441
commit e26391bc2f
2 changed files with 12 additions and 0 deletions

View File

@ -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

View 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