diff options
| author | ruki <[email protected]> | 2019-07-28 20:09:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-07-28 20:10:39 +0800 |
| commit | 1bb412afcd5d416bec002ea882b797499e60417c (patch) | |
| tree | 6690846fdf737a4bfa93396820d498686852b8ef | |
| parent | 29552afd90275c4a1cafc58cd39463afafe830f8 (diff) | |
improve makefile
| -rw-r--r-- | core/makefile | 16 | ||||
| -rw-r--r-- | core/prefix.mak | 3 | ||||
| -rw-r--r-- | core/suffix.mak | 20 | ||||
| -rw-r--r-- | makefile | 9 |
4 files changed, 28 insertions, 20 deletions
diff --git a/core/makefile b/core/makefile index cf14faee7..bf865c66f 100644 --- a/core/makefile +++ b/core/makefile @@ -36,9 +36,9 @@ endif # make all all : .null - @echo "" > /tmp/$(PRO_NAME).out + @echo "" > $(TMP_DIR)/$(PRO_NAME).out @echo make $(PRO_NAME) - @$(MAKE) --no-print-directory -C $(SRC_DIR) || cat /tmp/$(PRO_NAME).out + @$(MAKE) --no-print-directory -C $(SRC_DIR) || cat $(TMP_DIR)/$(PRO_NAME).out # make rebuild rebuild : .null @@ -48,7 +48,7 @@ rebuild : .null # make install install : .null - @echo "" > /tmp/$(PRO_NAME).out + @echo "" > $(TMP_DIR)/$(PRO_NAME).out @echo install $(PRO_NAME) @$(MAKE) --no-print-directory -C $(SRC_DIR) @$(MAKE) --no-print-directory -C $(SRC_DIR) install @@ -59,13 +59,13 @@ lipo : .null # make clean clean : .null - @echo "" > /tmp/$(PRO_NAME).out + @echo "" > $(TMP_DIR)/$(PRO_NAME).out @echo clean $(PRO_NAME) @$(MAKE) --no-print-directory -C $(SRC_DIR) clean # make update update : .null - @echo "" > /tmp/$(PRO_NAME).out + @echo "" > $(TMP_DIR)/$(PRO_NAME).out @echo update $(PRO_NAME) @$(MAKE) --no-print-directory -C $(SRC_DIR) update @$(MAKE) --no-print-directory -C $(SRC_DIR) @@ -74,17 +74,17 @@ update : .null # make output output : .null @echo output $(PRO_NAME) - @cat /tmp/$(PRO_NAME).out + @cat $(TMP_DIR)/$(PRO_NAME).out # make error error : .null @echo error $(PRO_NAME) - @cat /tmp/$(PRO_NAME).out | egrep -i "error|undefined|cannot|错误" | cat + @cat $(TMP_DIR)/$(PRO_NAME).out | egrep -i "error|undefined|cannot|错误" | cat # make warning warning : .null @echo warning $(PRO_NAME) - @cat /tmp/$(PRO_NAME).out | egrep warning + @cat $(TMP_DIR)/$(PRO_NAME).out | egrep warning # make doc doc : .null diff --git a/core/prefix.mak b/core/prefix.mak index b7b9469c4..ce68486b9 100644 --- a/core/prefix.mak +++ b/core/prefix.mak @@ -3,6 +3,9 @@ # include project include $(PRO_DIR)/project.mak +# the temporary directory +TMP_DIR :=$(if $(TMP_DIR),$(TMP_DIR),/tmp) + # the source directory SRC_DIR = $(PRO_DIR)/src diff --git a/core/suffix.mak b/core/suffix.mak index b84c19ff3..0e08152bc 100644 --- a/core/suffix.mak +++ b/core/suffix.mak @@ -206,43 +206,43 @@ $(foreach name, $(NAMES), $(eval $(call MAKE_OBJS_AND_SRCS_FILES,$(name)))) define MAKE_OBJ_C $(1)$(OBJ_SUFFIX) : $(1).c @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).c - @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).c $(OUT) /tmp/$(PRO_NAME).out + @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).c $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_CC $(1)$(OBJ_SUFFIX) : $(1).cc @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).cc - @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cc $(OUT) /tmp/$(PRO_NAME).out + @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cc $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_CPP $(1)$(OBJ_SUFFIX) : $(1).cpp @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).cpp - @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cpp $(OUT) /tmp/$(PRO_NAME).out + @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cpp $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_M $(1)$(OBJ_SUFFIX) : $(1).m @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).m - @$(MM) -x objective-c $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).m $(OUT) /tmp/$(PRO_NAME).out + @$(MM) -x objective-c $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).m $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_MM $(1)$(OBJ_SUFFIX) : $(1).mm @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).mm - @$(MM) -x objective-c++ $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).mm $(OUT) /tmp/$(PRO_NAME).out + @$(MM) -x objective-c++ $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).mm $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_ASM_WITH_CC $(1)$(OBJ_SUFFIX) : $(1)$(ASM_SUFFIX) @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1)$(ASM_SUFFIX) - @$(CC) $(2) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1)$(ASM_SUFFIX) $(OUT) /tmp/$(PRO_NAME).out + @$(CC) $(2) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1)$(ASM_SUFFIX) $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_ASM_WITH_AS $(1)$(OBJ_SUFFIX) : $(1)$(ASM_SUFFIX) @echo compile.$(DTYPE) $(1)$(ASM_SUFFIX) - @$(AS) $(2) $(ASFLAGS-o)$(1)$(OBJ_SUFFIX) $(1)$(ASM_SUFFIX) $(OUT) /tmp/$(PRO_NAME).out + @$(AS) $(2) $(ASFLAGS-o)$(1)$(OBJ_SUFFIX) $(1)$(ASM_SUFFIX) $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_ALL @@ -268,18 +268,18 @@ $(if $(AS) $(BIN_PREFIX)$(1)$(BIN_SUFFIX): $($(1)_OBJS) $(addsuffix $(OBJ_SUFFIX), $($(1)_OBJ_FILES)) @echo link $$@ -@$(RM) $$@ - @$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_LDFLAGS) $(OUT) /tmp/$(PRO_NAME).out + @$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_LDFLAGS) $(OUT) $(TMP_DIR)/$(PRO_NAME).out $(LIB_PREFIX)$(1)$(LIB_SUFFIX): $($(1)_OBJS) $(addsuffix $(OBJ_SUFFIX), $($(1)_OBJ_FILES)) @echo link $$@ -@$(RM) $$@ - @$(AR) $($(1)_ARFLAGS) $(ARFLAGS-o)$$@ $$^ $(OUT) /tmp/$(PRO_NAME).out + @$(AR) $($(1)_ARFLAGS) $(ARFLAGS-o)$$@ $$^ $(OUT) $(TMP_DIR)/$(PRO_NAME).out $(if $(RANLIB),@$(RANLIB) $$@,) $(DLL_PREFIX)$(1)$(DLL_SUFFIX): $($(1)_OBJS) $(addsuffix $(OBJ_SUFFIX), $($(1)_OBJ_FILES)) @echo link $$@ -@$(RM) $$@ - @$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_SHFLAGS) $(OUT) /tmp/$(PRO_NAME).out + @$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_SHFLAGS) $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef @@ -8,6 +8,10 @@ verbose:= # prefix prefix:=$(if $(prefix),$(prefix),$(if $(findstring /usr/local/bin,$(PATH)),/usr/local,/usr)) + +# the temporary directory +TMP_DIR :=$(if $(TMP_DIR),$(TMP_DIR),/tmp) + # platform PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i linux},linux,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i darwin},macosx,)) @@ -50,7 +54,7 @@ ARCH :=$(if $(findstring amd64,$(ARCH)),x86_64,$(ARCH)) 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 :=$(TMP_DIR)/xmake_loader xmake_loader_install:=$(prefix)/bin/xmake tip: @@ -62,6 +66,7 @@ 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: @@ -85,7 +90,7 @@ install: @mv $(xmake_loader) $(xmake_loader_install) @chmod 777 $(xmake_loader_install) @# remove xmake.out - @if [ -f '/tmp/xmake.out' ]; then rm /tmp/xmake.out; fi + @if [ -f "$(TMP_DIR)/xmake.out" ]; then rm $(TMP_DIR)/xmake.out; fi @# ok @echo ok! |
