summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-20 00:42:05 +0800
committerruki <[email protected]>2017-05-20 00:42:05 +0800
commitce27b8d4dfae08a01f473e7a5cfbb94f6e79c967 (patch)
tree76cb0f63a16787f920c3dac016ad7b6f5c2d7250 /makefile
parentc6876982657c8bf65b7e2a05fc1206b3aacc0ff8 (diff)
improve test script
Diffstat (limited to 'makefile')
-rw-r--r--makefile88
1 files changed, 88 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 000000000..d8cd01cf3
--- /dev/null
+++ b/makefile
@@ -0,0 +1,88 @@
+# is debug?
+debug :=n
+verbose:=
+
+#debug :=y
+#verbose:=-v
+
+# prefix
+prefix:=$(if $(prefix),$(prefix),$(if $(findstring /usr/local/bin,$(PATH)),/usr/local,/usr))
+
+# platform
+PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i linux},linux,))
+PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i darwin},macosx,))
+PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i cygwin},cygwin,))
+PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i mingw},mingw,))
+PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i windows},windows,))
+PLAT :=$(if $(PLAT),$(PLAT),linux)
+
+# architecture
+ifeq ($(ARCH),)
+
+ARCH :=$(if $(findstring windows,$(PLAT)),x86,$(ARCH))
+ARCH :=$(if $(findstring mingw,$(PLAT)),x86,$(ARCH))
+ARCH :=$(if $(findstring macosx,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH))
+ARCH :=$(if $(findstring linux,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH))
+ARCH :=$(if $(findstring x32,$(ARCH)),i386,$(ARCH))
+ARCH :=$(if $(findstring x64,$(ARCH)),x86_64,$(ARCH))
+ARCH :=$(if $(findstring iphoneos,$(PLAT)),armv7,$(ARCH))
+ARCH :=$(if $(findstring android,$(PLAT)),armv7,$(ARCH))
+
+endif
+
+xmake_dir_install :=$(prefix)/share/xmake
+xmake_core :=./core/src/demo/demo.b
+xmake_core_install :=$(xmake_dir_install)/xmake
+xmake_loader :=/tmp/xmake_loader
+xmake_loader_install:=$(prefix)/bin/xmake
+
+tip:
+ @echo 'Usage: '
+ @echo ' $ make build'
+ @echo ' $ sudo make install [prefix=/usr/local]'
+
+build:
+ @echo compiling xmake-core ...
+ @if [ -f core/.config.mak ]; then rm core/.config.mak; fi
+ @$(MAKE) -C core --no-print-directory f DEBUG=$(debug)
+ @$(MAKE) -C core --no-print-directory c
+ @$(MAKE) -C core --no-print-directory
+
+install:
+ @echo installing to $(prefix) ...
+ @echo plat: $(PLAT)
+ @echo arch: $(ARCH)
+ @# create the xmake install directory
+ @if [ -d $(xmake_dir_install) ]; then rm -rf $(xmake_dir_install); fi
+ @if [ ! -d $(xmake_dir_install) ]; then mkdir -p $(xmake_dir_install); fi
+ @# install the xmake core file
+ @cp $(xmake_core) $(xmake_core_install)
+ @chmod 777 $(xmake_core_install)
+ @# install the xmake directory
+ @cp -r xmake/* $(xmake_dir_install)
+ @# make the xmake loader
+ @echo '#!/bin/bash' > $(xmake_loader)
+ @echo 'export XMAKE_PROGRAM_DIR=$(xmake_dir_install)' >> $(xmake_loader)
+ @echo '$(xmake_core_install) $(verbose) "$$@"' >> $(xmake_loader)
+ @# install the xmake loader
+ @if [ ! -d $(prefix)/bin ]; then mkdir -p $(prefix)/bin; fi
+ @mv $(xmake_loader) $(xmake_loader_install)
+ @chmod 777 $(xmake_loader_install)
+ @# tip
+ @$(if $(findstring $(prefix)/bin,$(PATH)),,echo 'please export PATH=$$PATH:$(prefix)/bin')
+ @# remove xmake.out
+ @if [ -f '/tmp/xmake.out' ]; then rm /tmp/xmake.out; fi
+ @# ok
+ @echo ok!
+
+uninstall:
+ @echo uninstalling from $(prefix) ...
+ @if [ -f $(prefix)/bin/xmake ]; then rm $(prefix)/bin/xmake; fi
+ @if [ -d $(prefix)/share/xmake ]; then rm -rf $(prefix)/share/xmake; fi
+ @echo ok!
+
+test:
+ @xmake lua tests/test.lua $(name)
+ @echo ok!
+
+.PHONY: tip build install uninstall