|
| 1 | +# is debug? |
| 2 | +debug :=n |
| 3 | +verbose:= |
| 4 | + |
| 5 | +#debug :=y |
| 6 | +#verbose:=-v |
| 7 | + |
| 8 | +# prefix |
| 9 | +prefix:=$(if $(prefix),$(prefix),$(if $(findstring /usr/local/bin,$(PATH)),/usr/local,/usr)) |
| 10 | + |
| 11 | +# platform |
| 12 | +PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i linux},linux,)) |
| 13 | +PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i darwin},macosx,)) |
| 14 | +PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i cygwin},cygwin,)) |
| 15 | +PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i mingw},mingw,)) |
| 16 | +PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i windows},windows,)) |
| 17 | +PLAT :=$(if $(PLAT),$(PLAT),linux) |
| 18 | + |
| 19 | +# architecture |
| 20 | +ifeq ($(ARCH),) |
| 21 | + |
| 22 | +ARCH :=$(if $(findstring windows,$(PLAT)),x86,$(ARCH)) |
| 23 | +ARCH :=$(if $(findstring mingw,$(PLAT)),x86,$(ARCH)) |
| 24 | +ARCH :=$(if $(findstring macosx,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH)) |
| 25 | +ARCH :=$(if $(findstring linux,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH)) |
| 26 | +ARCH :=$(if $(findstring x32,$(ARCH)),i386,$(ARCH)) |
| 27 | +ARCH :=$(if $(findstring x64,$(ARCH)),x86_64,$(ARCH)) |
| 28 | +ARCH :=$(if $(findstring iphoneos,$(PLAT)),armv7,$(ARCH)) |
| 29 | +ARCH :=$(if $(findstring android,$(PLAT)),armv7,$(ARCH)) |
| 30 | + |
| 31 | +endif |
| 32 | + |
| 33 | +xmake_dir_install :=$(prefix)/share/xmake |
| 34 | +xmake_core :=./core/bin/demo.pkg/bin/$(PLAT)/$(ARCH)/demo.b |
| 35 | +xmake_core_install :=$(xmake_dir_install)/xmake |
| 36 | +xmake_loader :=/tmp/xmake_loader |
| 37 | +xmake_loader_install:=$(prefix)/bin/xmake |
| 38 | + |
| 39 | +tip: |
| 40 | + @echo '$(MAKE) build; sudo $(MAKE) install' |
| 41 | + |
| 42 | +build: |
| 43 | + @echo compiling xmake-core ... |
| 44 | + @if [ -f core/.config.mak ]; then rm core/.config.mak; fi |
| 45 | + @$(MAKE) -C core --no-print-directory f DEBUG=$(debug) |
| 46 | + @$(MAKE) -C core --no-print-directory c |
| 47 | + @$(MAKE) -C core --no-print-directory |
| 48 | + |
| 49 | +install: |
| 50 | + @echo installing to $(prefix) ... |
| 51 | + @echo plat: $(PLAT) |
| 52 | + @echo arch: $(ARCH) |
| 53 | + @# create the xmake install directory |
| 54 | + @$(MAKE) -C core --no-print-directory i |
| 55 | + @if [ -d $(xmake_dir_install) ]; then rm -rf $(xmake_dir_install); fi |
| 56 | + @if [ ! -d $(xmake_dir_install) ]; then mkdir -p $(xmake_dir_install); fi |
| 57 | + @# install the xmake core file |
| 58 | + @cp $(xmake_core) $(xmake_core_install) |
| 59 | + @chmod 777 $(xmake_core_install) |
| 60 | + @# install the xmake directory |
| 61 | + @cp -r xmake/* $(xmake_dir_install) |
| 62 | + @# make the xmake loader |
| 63 | + @echo '#!/bin/bash' > $(xmake_loader) |
| 64 | + @echo 'export XMAKE_PROGRAM_DIR=$(xmake_dir_install)' >> $(xmake_loader) |
| 65 | + @echo '$(xmake_core_install) $(verbose) "$$@"' >> $(xmake_loader) |
| 66 | + @# install the xmake loader |
| 67 | + @if [ ! -d $(prefix)/bin ]; then mkdir -p $(prefix)/bin; fi |
| 68 | + @mv $(xmake_loader) $(xmake_loader_install) |
| 69 | + @chmod 777 $(xmake_loader_install) |
| 70 | + @# tip |
| 71 | + @$(if $(findstring $(prefix)/bin,$(PATH)),,echo 'please export PATH=$$PATH:$(prefix)/bin') |
| 72 | + @# remove xmake.out |
| 73 | + @if [ -f '/tmp/xmake.out' ]; then rm /tmp/xmake.out; fi |
| 74 | + @# ok |
| 75 | + @echo ok! |
| 76 | + |
| 77 | +.PHONY: tip build install |
0 commit comments