diff options
| author | ruki <[email protected]> | 2021-06-29 23:00:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-06-29 23:00:43 +0800 |
| commit | cb649335c48292c2b496b00357d6b65b1920da13 (patch) | |
| tree | ddc17f0e298dcee3c816adf5b619d1353738b662 | |
| parent | 8f2b7f27a75d33fed60e9d7037f895bfb7d6434e (diff) | |
improve makefile
| -rw-r--r-- | core/detect/luajit.c | 7 | ||||
| -rw-r--r-- | core/makefile | 1 | ||||
| -rw-r--r-- | core/src/demo/makefile | 16 | ||||
| -rw-r--r-- | core/src/luajit/makefile | 13 |
4 files changed, 18 insertions, 19 deletions
diff --git a/core/detect/luajit.c b/core/detect/luajit.c new file mode 100644 index 000000000..96e8c0ccc --- /dev/null +++ b/core/detect/luajit.c @@ -0,0 +1,7 @@ +#include <luajit.h> + +int main() +{ + lua_pcall(0, 0, 0, 0); + return 0; +} diff --git a/core/makefile b/core/makefile index 47893a3bc..f51e0f735 100644 --- a/core/makefile +++ b/core/makefile @@ -278,6 +278,7 @@ base_LIBNAMES := base_LIBNAMES += $(shell if { cat detect/curses.c | $(CC) -xc - -lcurses -ltinfo -o /dev/null 2>/dev/null; }; then echo curses tinfo; fi ) base_LIBNAMES += $(shell if { cat detect/readline.c | $(CC) -xc - -lreadline -o /dev/null 2>/dev/null; }; then echo readline; fi ) base_LIBNAMES += $(shell if { cat detect/tbox.c | $(CC) -xc - -ltbox -o /dev/null 2>/dev/null; }; then echo tbox; fi ) +base_LIBNAMES += $(shell if { cat detect/luajit.c | $(CC) -xc - $(shell pkg-config --libs --cflags luajit) -o /dev/null 2>/dev/null; }; then echo luajit-5.1; fi ) ifneq ($(TERMUX_ARCH),) # on termux/ci? base_LIBNAMES += m dl else diff --git a/core/src/demo/makefile b/core/src/demo/makefile index 4ee62ff81..63c6abcef 100644 --- a/core/src/demo/makefile +++ b/core/src/demo/makefile @@ -20,18 +20,10 @@ demo_INC_DIRS += ../ ../tbox/tbox/src ../tbox/inc/$(PLAT) demo_LIB_DIRS += ../tbox # luajit -ifndef LUAJIT_LIBS -LUAJIT_LIBS := luajit$(DTYPE) -endif -ifndef LUAJIT_INC_DIRS -LUAJIT_INC_DIRS := ../luajit/luajit/src -endif -ifndef LUAJIT_LIB_DIRS -LUAJIT_LIB_DIRS := ../luajit -endif -demo_LIBS += $(LUAJIT_LIBS) -demo_INC_DIRS += $(LUAJIT_INC_DIRS) -demo_LIB_DIRS += $(LUAJIT_LIB_DIRS) +luajit_LIBS := $(if $(findstring luajit,$(base_LIBNAMES)),,luajit$(DTYPE)) +demo_LIBS += $(luajit_LIBS) +demo_INC_DIRS += ../luajit/luajit/src +demo_LIB_DIRS += ../luajit # sv ifndef SV_LIBS diff --git a/core/src/luajit/makefile b/core/src/luajit/makefile index 2fbfe89b9..f2a2563bf 100644 --- a/core/src/luajit/makefile +++ b/core/src/luajit/makefile @@ -137,13 +137,12 @@ luajit_CXFLAGS += -fPIE endif endif -# use given luajit library? -ifdef LUAJIT_LIBS -luajit_C_FILES := -luajit_ASM_FILES := -luajit_INC_FILES := -luajit_OBJ_FILES := -endif +# use given system library? +luajit_C_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_C_FILES)) +luajit_ASM_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_ASM_FILES)) +luajit_INC_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_INC_FILES)) +luajit_OBJ_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_OBJ_FILES)) + # suffix include $(PRO_DIR)/suffix.mak |
