添加操作系统和检测和区分处理 添加去除重复路径时call增加的换行问题导致Linux下编译异常

添加操作系统和检测和区分处理
添加去除重复路径时call增加的换行问题导致Linux下编译异常
This commit is contained in:
impressionyang 2024-01-27 15:51:09 +08:00 committed by GitHub
parent 6e583b4a0a
commit b5d4ff64a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,17 +1,34 @@
# lazy build C project Makefiles by impressionyang
# user config values
CC="E:\\impressionyang\\scoop\\apps\\mingw\\12.2.0\\bin\\gcc.exe"
CC="/usr/bin/gcc"
# CC="E:\\impressionyang\\scoop\\apps\\mingw\\12.2.0\\bin\\gcc.exe"
PROJECT=test
# check operating system type
ifeq ($(OS), Windows_NT)
OS_TYPE := WINDOWS
SHELL := cmd
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS_TYPE := LINUX
endif
ifeq ($(UNAME_S),Darwin)
OS_TYPE := OSX
endif
endif
$(info OS type = $(OS_TYPE))
# patern config
FILES_PATH := ./
SRC_FILES_SUFFIX := %.c
HDR_FILES_SUFFIX := %.h
# define func to remove_same_str
# define func to remove_same_str for debug: $(info get seen ${seen})
define remove_same_str =
$(eval seen :=)
$(foreach _,$1,$(if $(filter $_,${seen}),,$(eval seen += $_)))
$(foreach _,$1,$(if $(filter $_,${seen}),,$(if $_, $(eval seen += $_))))
${seen}
endef
@ -27,7 +44,9 @@ HEADERS := $(HEADERS:$(LOCAL_PATH)/%=%)
# fillter out all include path
FIND_ALL_FILES_DIR := $(dir $(foreach files_path,$(FILES_PATH), $(call rwildcard,$(files_path),*/) ) )
INC_DIRS := $(call remove_same_str,$(FIND_ALL_FILES_DIR))
GET_INC_DIRS := $(call remove_same_str,$(FIND_ALL_FILES_DIR))
INC_DIRS :=
INC_DIRS += $(foreach v, $(GET_INC_DIRS), $(if $(filter %/,$v) , $(eval INC_DIRS+=$v), ))
INC_DIRS := $(subst ./, -I./, $(INC_DIRS))
INC_DIRS := $(wordlist 1, $(words $(INC_DIRS)), $(INC_DIRS))
@ -46,5 +65,13 @@ all :
# virtual clean job
.PHONY : clean
clean:
$(warning "remove some files but it may not exist because the OS different")
rm $(PROJECT).exe $(PROJECT)
ifeq ($(OS_TYPE), WINDOWS)
del $(PROJECT).exe
endif
ifeq ($(OS_TYPE), LINUX)
rm $(PROJECT)
endif
ifeq ($(OS_TYPE), OSX)
rm $(PROJECT)
endif