qmk build system
This commit is contained in:
8
qmk/arch-pack/ap.linux.posix.gcc
Normal file
8
qmk/arch-pack/ap.linux.posix.gcc
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
CFGFLAGS += -I${QTOP}/arch/linux/common/include/
|
||||
CFGFLAGS += -I${QTOP}/arch/linux/posix/gcc
|
||||
|
||||
|
||||
|
||||
ARCH_LSCRS = $(wildcard ${QTOP}/arch/linux/posix/gcc/*.c)
|
||||
ARCH_LSCRS += $(wildcard ${QTOP}/arch/linux/common/*.c)
|
0
qmk/arch-pack/apconfig
Normal file
0
qmk/arch-pack/apconfig
Normal file
37
qmk/board-pack/bp.Linux_Posix
Normal file
37
qmk/board-pack/bp.Linux_Posix
Normal file
@@ -0,0 +1,37 @@
|
||||
# toolchain
|
||||
uname := $(shell uname -s)
|
||||
ifeq ($(filter-out Linux Darwin,$(uname)),)
|
||||
ifeq ($(shell uname -m),x86_64)
|
||||
CROSS_COMPILE =
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
ARFLAGS = -rc
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
else
|
||||
CROSS_COMPILE =
|
||||
CC = $(CROSS_COMPILE)gcc -m32
|
||||
CXX = $(CROSS_COMPILE)g++ -m32
|
||||
LD = $(CROSS_COMPILE)ld -melf_i386
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
ARFLAGS = -rc
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
endif
|
||||
endif
|
||||
|
||||
include ${QTOP}/qmk/arch-pack/ap.linux.posix.gcc
|
||||
|
||||
CFGFLAGS += -O0 -Wall -g2 -ggdb
|
||||
|
||||
CFGFLAGS += -I${QTOP}/board/Linux_Posix/hello_world/inc
|
||||
CFGFLAGS += -I${QTOP}/osal/cmsis_os
|
||||
CFGFLAGS += -I${QTOP}/kernel/core/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/evtdrv/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/hal/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/pm/include
|
||||
|
||||
|
||||
|
40
qmk/board-pack/bp.Linux_Posix.helloworld
Normal file
40
qmk/board-pack/bp.Linux_Posix.helloworld
Normal file
@@ -0,0 +1,40 @@
|
||||
# toolchain
|
||||
uname := $(shell uname -s)
|
||||
ifeq ($(filter-out Linux Darwin,$(uname)),)
|
||||
ifeq ($(shell uname -m),x86_64)
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
ARFLAGS = -rc
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
else
|
||||
CROSS_COMPILE =
|
||||
CC = $(CROSS_COMPILE)gcc -m32
|
||||
CXX = $(CROSS_COMPILE)g++ -m32
|
||||
LD = $(CROSS_COMPILE)ld -melf_i386
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
ARFLAGS = -rc
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
endif
|
||||
endif
|
||||
|
||||
CFGFLAGS += -O0 -Wall -g2 -ggdb
|
||||
|
||||
CFGFLAGS += -I${QTOP}/board/Linux_Posix/hello_world/inc
|
||||
CFGFLAGS += -I${QTOP}/osal/cmsis_os
|
||||
CFGFLAGS += -I${QTOP}/kernel/core/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/evtdrv/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/hal/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/pm/include
|
||||
CFGFLAGS += -I${QTOP}/arch/linux/common/include
|
||||
CFGFLAGS += -I${QTOP}/arch/linux/posix/gcc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
qmk/board-pack/bp.native
Normal file
42
qmk/board-pack/bp.native
Normal file
@@ -0,0 +1,42 @@
|
||||
# toolchain
|
||||
uname := $(shell uname -s)
|
||||
ifeq ($(filter-out Linux Darwin,$(uname)),)
|
||||
ifeq ($(shell uname -m),x86_64)
|
||||
CROSS_COMPILE =
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
ARFLAGS = -rc
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
else
|
||||
CROSS_COMPILE =
|
||||
CC = $(CROSS_COMPILE)gcc -m32
|
||||
CXX = $(CROSS_COMPILE)g++ -m32
|
||||
LD = $(CROSS_COMPILE)ld -melf_i386
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
ARFLAGS = -rc
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
CFGFLAGS += -O0 -Wall -g2 -ggdb
|
||||
|
||||
CFGFLAGS += -I${QTOP}/board/Linux_Posix/hello_world/inc
|
||||
CFGFLAGS += -I${QTOP}/osal/cmsis_os
|
||||
CFGFLAGS += -I${QTOP}/kernel/core/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/evtdrv/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/hal/include
|
||||
CFGFLAGS += -I${QTOP}/kernel/pm/include
|
||||
CFGFLAGS += -I${QTOP}/arch/linux/common/include
|
||||
CFGFLAGS += -I${QTOP}/arch/linux/posix/gcc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
50
qmk/generic/Make.debug
Normal file
50
qmk/generic/Make.debug
Normal file
@@ -0,0 +1,50 @@
|
||||
# QMK for TencentOS
|
||||
# @author Jimmin.huang jimmin@163.com
|
||||
# Makefile template
|
||||
# aim for debug makefile
|
||||
########################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
|
||||
|
||||
# Standard definitions for true and false. true is any non-empty
|
||||
# string, false is an empty string. These are intended for use with
|
||||
# $(if).
|
||||
|
||||
true := T
|
||||
false :=
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Function: not
|
||||
# Arguments: 1: A boolean value
|
||||
# Returns: Returns the opposite of the arg. (true -> false, false -> true)
|
||||
# ----------------------------------------------------------------------------
|
||||
not = $(if $1,$(false),$(true))
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Function: seq
|
||||
# Arguments: 1: A string to compare against...
|
||||
# 2: ...this string
|
||||
# Returns: Returns $(true) if the two strings are identical
|
||||
# ----------------------------------------------------------------------------
|
||||
seq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),$(false),$(true))
|
||||
|
||||
ifeq (dm,$(findstring dm,$(MAKECMDGOALS)))
|
||||
$(info ###################All pre-defined and user-defined variable's Key:)
|
||||
$(info $(shell echo -e '\e[1;33m $(sort $(.VARIABLES)) \e[m'))
|
||||
|
||||
$(info ###################All user-defined Variables:)
|
||||
$(foreach v, $(sort $(.VARIABLES)),$(if $(call seq,$(origin ${v}),file), $(eval VV:=$(value ${v})) $(info $(shell echo -e '\e[1;33m ${v} \e[m = "$(VV)"' ))))
|
||||
dm:
|
||||
@true
|
||||
endif
|
||||
|
||||
|
||||
|
||||
PHONY: dm
|
||||
|
||||
endif
|
46
qmk/generic/Make.depend
Normal file
46
qmk/generic/Make.depend
Normal file
@@ -0,0 +1,46 @@
|
||||
# QMK for TencentOS
|
||||
# @author Jimmin.huang jimmin@163.com
|
||||
# Makefile template
|
||||
########################################################################
|
||||
|
||||
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
|
||||
ifneq (help,$(findstring help,$(MAKECMDGOALS)))
|
||||
|
||||
all::
|
||||
@true
|
||||
#
|
||||
# Attempt to build the depend files. If it fails, the depend file is
|
||||
# removed so that it is not included in later builds.
|
||||
#
|
||||
#${BLDDIR}/%.P : %.c ${BLDDIR}/.tree
|
||||
# @$(ECHO) "[$(BP)] DEP ${LOCALDIR}/$<"
|
||||
|
||||
#${BLDDIR}/%.P : %.cc ${BLDDIR}/.tree
|
||||
# @$(ECHO) "[$(BP)] DEP ${LOCALDIR}/$<"
|
||||
|
||||
|
||||
#
|
||||
# If there are C or C++ files in this directory, include the
|
||||
# depend files for them.
|
||||
#
|
||||
ifeq ($(findstring _COMPILER,$(MAKECMDGOALS))$(findstring variable,$(MAKECMDGOALS)),)
|
||||
ifneq ($(strip ${LSRCS}),)
|
||||
ifneq (,$(findstring .o,$(MAKECMDGOALS)))
|
||||
-include $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.P)) $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.sig))
|
||||
else
|
||||
-include $(addprefix ${BLDDIR}/,$(addsuffix .P,$(basename $(LSRCS))))
|
||||
-include $(addprefix ${BLDDIR}/,$(addsuffix .sig,$(basename $(LSRCS))))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
endif # help
|
||||
endif # !CLEANING
|
||||
|
||||
clean_d::
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHO) "[$(BP)] CLEAN DEPS ${LOCALDIR}"
|
||||
endif
|
||||
$Q$(RM) $(BOBJS:.o=.P)
|
||||
|
||||
clean:: clean_d
|
56
qmk/generic/Make.exec
Normal file
56
qmk/generic/Make.exec
Normal file
@@ -0,0 +1,56 @@
|
||||
# QMK for TencentOS
|
||||
# @author Jimmin.huang jimmin@163.com
|
||||
########################################################################
|
||||
|
||||
# Make rules/targets for handling user application
|
||||
|
||||
.SECONDARY:: ${LD_O_FILES}
|
||||
|
||||
ifeq (,$(strip $(exec)))
|
||||
exec = $(shell basename $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))
|
||||
endif
|
||||
|
||||
OUTDIR = ${BLDDIR}/out
|
||||
|
||||
targetexec = ${OUTDIR}/${exec}
|
||||
|
||||
all:: ${OUTDIR}/.tree ${targetexec}
|
||||
|
||||
$(info $(wildcard $(LIBDIR)/%.a) )
|
||||
|
||||
ifeq (,$(LD_O_FILES))
|
||||
LD_O_FILES = $(sort $(BOBJS))
|
||||
endif
|
||||
ifeq (2,$(V))
|
||||
LD_INFO_OPTS := -Wl,--warn-common -Wl,--verbose
|
||||
endif
|
||||
ifeq (3,$(V))
|
||||
LD_INFO_OPTS := -Wl,--warn-common -Wl,-Map,${OUTDIR}/${exec}.map -Wl,--verbose
|
||||
endif
|
||||
|
||||
_LD_START_GROUP := -Wl,--start-group
|
||||
_LD_END_GROUP := -Wl,--end-group
|
||||
|
||||
$(targetexec): $(OUTDIR)/strip/.tree ${LD_O_FILES}
|
||||
@rm -f $@ # Prevent core dump if currently running
|
||||
@$(ECHO) "[$(BP)] LINK $@" # This is needed for error parsing
|
||||
$(Q)/bin/ls $(LIBDIR)
|
||||
$(Q)$(CC) \
|
||||
-o $@ \
|
||||
-L${LIBDIR} \
|
||||
$(_LD_START_GROUP) $(LD_O_FILES) $(LD_A_FILES) $(LD_L_LISTS) $(LDFLAGS) $(_LD_END_GROUP) \
|
||||
$(LD_INFO_OPTS)
|
||||
$(CP) $@ $(QTOP)
|
||||
$(Q)$(STRIP) --strip-debug $@ -o $(OUTDIR)/strip/$(notdir $@)
|
||||
|
||||
|
||||
install:: all
|
||||
|
||||
clean::
|
||||
$(Q)$(RM) ${BOBJS}
|
||||
$(Q)$(RM) $(filter %.a ,$(LD_A_FILES))
|
||||
$(Q)$(RM) ${bldroot_exec}
|
||||
|
||||
distclean:: clean
|
||||
|
||||
.PHONY: $(targetexec)
|
52
qmk/generic/Make.lib
Normal file
52
qmk/generic/Make.lib
Normal file
@@ -0,0 +1,52 @@
|
||||
# QMK for TencentOS
|
||||
# @author Jimmin.huang jimmin@163.com
|
||||
# Makefile template
|
||||
########################################################################
|
||||
|
||||
.SECONDARY:: ${BOBJS}
|
||||
|
||||
ifndef lib
|
||||
lib = lib$(shell basename ${LOCALDIR})
|
||||
endif
|
||||
targetlib = ${LIBDIR}/${lib}.a
|
||||
|
||||
|
||||
${LIBDIR}/%.a: ${BOBJS}
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHO) "[$(BP)] ARLIB $(subst $(QTOP)/,,$@)"
|
||||
endif
|
||||
$Q$(RM) $@
|
||||
$Q$(AR) ${ARFLAGS} $@ $(sort ${BOBJS})
|
||||
|
||||
# if objs is not empty, let make .a
|
||||
ifneq (,$(strip ${BOBJS}))
|
||||
all:: ${BLDDIR}/.tree ${targetlib}
|
||||
|
||||
$(targetlib): ${BOBJS}
|
||||
ifneq (,${BOBJS})
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHOE) "[$(BP)] ARLIB \e[1;32m$(subst $(QTOP)/,,$@) \e[m"
|
||||
endif
|
||||
$Q$(RM) $@
|
||||
$Q$(AR) ${ARFLAGS} $@ $(sort ${BOBJS})
|
||||
endif
|
||||
|
||||
install:: all
|
||||
clean::
|
||||
ifeq (@,$(Q))
|
||||
$Q$(ECHO) "[$(BP)] ClEAN OBJS ${LOCALDIR}"
|
||||
endif
|
||||
$Q$(RM) ${BOBJS}
|
||||
ifdef EEEE
|
||||
$Q$(RM) ${BOBJS:.o=.i}
|
||||
endif
|
||||
$Q$(RM) ${targetlib}
|
||||
|
||||
distclean:: clean
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
39
qmk/generic/Make.subdirs
Normal file
39
qmk/generic/Make.subdirs
Normal file
@@ -0,0 +1,39 @@
|
||||
# QMK for TencentOS
|
||||
# @author Jimmin.huang jimmin@163.com
|
||||
# Makefile template
|
||||
########################################################################
|
||||
|
||||
|
||||
|
||||
.PHONY: ${subdirs}
|
||||
|
||||
|
||||
|
||||
# only not treelib will do recursive subdir make
|
||||
ifneq (,$(filter n no NO 0,$(TREE_LIB_ENABLE))) # no
|
||||
# only have subdir, will do recursive subdir make
|
||||
ifeq (,$(strip $(subdirs)))
|
||||
subdirs = $(sort $(dir $(wildcard */Makefile)))
|
||||
endif
|
||||
|
||||
ifneq (,$(strip ${subdirs}))
|
||||
# target
|
||||
all:: ${subdirs}
|
||||
@true
|
||||
|
||||
${subdirs}::
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHO) "[$(BP)] SUBDIR $(LOCALDIR)/$@ "
|
||||
endif
|
||||
$Q$(MAKE) -C $@ BP=${BP}
|
||||
|
||||
|
||||
# target
|
||||
clean clean_d install::
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHO) "[$(BP)] $@ $(LOCALDIR)"
|
||||
endif
|
||||
@(for name in $(subdirs); do $(MAKE) -C $$name $@; done)
|
||||
|
||||
endif
|
||||
endif
|
63
qmk/generic/Make.tools
Normal file
63
qmk/generic/Make.tools
Normal file
@@ -0,0 +1,63 @@
|
||||
# QMK for TencentOS
|
||||
# @author Jimmin.huang jimmin@163.com
|
||||
# Makefile template
|
||||
########################################################################
|
||||
|
||||
SYSOK = 0
|
||||
ifneq "$(SYSNAME)" ""
|
||||
SYSOK = 1 # already set from environment
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# unix or unix-type type hosts
|
||||
ifeq "$(SYSOK)" "0"
|
||||
SYSNAME := $(shell uname -s)
|
||||
|
||||
ifeq "$(SYSNAME)" "Linux"
|
||||
SYSOK = 1
|
||||
SED = /bin/sed
|
||||
COMPRESS = /usr/bin/compress
|
||||
GZIP = /usr/bin/gzip
|
||||
TEST = /usr/bin/test
|
||||
PERL = $(shell which perl)
|
||||
LN = /bin/ln
|
||||
TOUCH = /bin/touch
|
||||
endif
|
||||
|
||||
|
||||
ifeq "$(SYSNAME)" "Darwin"
|
||||
SYSOK = 1
|
||||
SED = /usr/bin/sed
|
||||
COMPRESS = /usr/bin/compress
|
||||
GZIP = /usr/bin/gzip
|
||||
LZMA = LZMA_NOT_DEFINED
|
||||
TEST = /bin/test
|
||||
PERL = $(shell which perl)
|
||||
LN = /bin/ln
|
||||
TOUCH = /usr/bin/touch
|
||||
endif
|
||||
|
||||
ifeq (MSYS_NT,$(findstring MSYS_NT,$(SYSNAME)))
|
||||
SYSOK = 1
|
||||
SED = /usr/bin/sed
|
||||
COMPRESS = /usr/bin/compress
|
||||
GZIP = /usr/bin/gzip
|
||||
LZMA = LZMA_NOT_DEFINED
|
||||
TEST = /bin/test
|
||||
PERL = $(shell which perl)
|
||||
LN = /bin/ln
|
||||
TOUCH = /usr/bin/touch
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# Platform Independent
|
||||
#
|
||||
RM = /bin/rm -rf
|
||||
CP = /bin/cp
|
||||
MKDIR = /bin/mkdir -p
|
||||
MAKEDEP = /bin/echo
|
||||
ECHO = /bin/echo -e
|
||||
ECHOE = /bin/echo -e
|
357
qmk/generic/Make.tpl
Normal file
357
qmk/generic/Make.tpl
Normal file
@@ -0,0 +1,357 @@
|
||||
# QMK for TencentOS
|
||||
# @author Jimmin.huang jimmin@163.com
|
||||
# Makefile template
|
||||
########################################################################
|
||||
|
||||
export QTOP
|
||||
ALOWED_MAKE_VERSIONS :=3.82
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
ifeq ($(filter $(ALOWED_MAKE_VERSIONS),$(MAKE_VERSION)),)
|
||||
#$(info Make $(MAKE_VERSION) not be tested, use one of $(ALOWED_MAKE_VERSIONS))
|
||||
$(info QMK for TOS)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
ifeq (help,$(findstring help,$(MAKECMDGOALS)))
|
||||
NO_QMK_DEPS=1
|
||||
endif
|
||||
endif
|
||||
# the top Makefile node that include this file
|
||||
CUR_MK_NODE_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Set a default BP if one is not set.
|
||||
|
||||
|
||||
SUPPORT-BP := $(sort $(subst $(QTOP)/qmk/board-pack/bp.,, $(wildcard $(QTOP)/qmk/board-pack/bp.*)))
|
||||
|
||||
|
||||
ifndef BP
|
||||
uname := $(shell uname -s)
|
||||
ifeq ($(filter-out Linux Darwin,$(uname)),)
|
||||
BP=Linux_Posix
|
||||
endif
|
||||
ifndef BP
|
||||
BP=native
|
||||
$(info Can't determine BP, `make help` see usage )
|
||||
endif
|
||||
$(info assume default BP=${BP} )
|
||||
endif
|
||||
|
||||
BP := ${BP}
|
||||
export BP
|
||||
|
||||
|
||||
#
|
||||
# By default, turn off the "changing directory" message.
|
||||
#
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
#
|
||||
# Use gmake by default
|
||||
#
|
||||
include ${QTOP}/qmk/generic/Make.tools
|
||||
|
||||
include ${QTOP}/qmk/board-pack/bp.${BP}
|
||||
|
||||
|
||||
|
||||
########################################################################
|
||||
|
||||
INCFLAGS = -I${QTOP}/arch/header -I${CUR_MK_NODE_DIR} -I${CUR_MK_NODE_DIR}/include -I${CUR_MK_NODE_DIR}/inc
|
||||
INCFLAGS += -DBP=\"$(BP)\" -DFILE_NAME=\"$(subst $(dir $<),,$<)\"
|
||||
|
||||
CFGFLAGS += ${INCFLAGS}
|
||||
# STD_{C|CXX}FLAGS - Standard flags used by ALL compilations
|
||||
# CFGFLAGS - Configuration flags used by ALL compilations
|
||||
|
||||
CFLAGS += ${STD_CFLAGS} ${CFGFLAGS} $(ADD_CFLAGS) $(GLOBAL_CFLAGS)
|
||||
CXXFLAGS += ${STD_CXXFLAGS} ${CFGFLAGS} $(ADD_CFLAGS) $(GLOBAL_CFLAGS)
|
||||
LDFLAGS += ${STD_LDFLAGS} ${CFGLDFLAGS} $(ADD_LDFLAGS) $(GLOBAL_LDFLAGS)
|
||||
|
||||
|
||||
|
||||
|
||||
V ?= 0
|
||||
# use to control printing of compilation lines
|
||||
ifeq (0,$(V))
|
||||
#no VERBOSE
|
||||
Q:=@
|
||||
else
|
||||
# VERBOSE
|
||||
Q:=
|
||||
endif
|
||||
|
||||
#
|
||||
# Default location to place binaries and make depend files for building
|
||||
# purposes.
|
||||
#
|
||||
|
||||
ifndef QTOPBUILD
|
||||
QTOPBUILD :=build
|
||||
endif
|
||||
ifeq (,$(BLD_SUFFIX))
|
||||
BLD_SUFFIX := .tos
|
||||
endif
|
||||
|
||||
BLDROOT = ${QTOP}/${QTOPBUILD}/$(if ${BLDCONFIG},${BLDCONFIG}/)${BP}.$(notdir $(firstword $(CC)))${BLD_SUFFIX}
|
||||
#$(info BLDROOT=$(BLDROOT))
|
||||
|
||||
|
||||
ifdef LOCALDIR
|
||||
BLDDIR = ${BLDROOT}/${LOCALDIR}
|
||||
else
|
||||
BLDDIR = ${BLDROOT}
|
||||
endif
|
||||
|
||||
LIBDIR = ${BLDROOT}
|
||||
OUTDIR = ${BLDROOT}/out
|
||||
|
||||
|
||||
#
|
||||
# In each directory, build a list of local sources, objects, and headers
|
||||
#
|
||||
|
||||
ifeq (,$(strip ${LSRCS})) # LSRCS
|
||||
ifeq (,$(filter n no NO 0,$(TREE_LIB_ENABLE))) # TREE_LIB_ENABLE yes
|
||||
|
||||
ifeq (,$(strip ${LSRCS_DIRS})) # LSRCS_DIRS
|
||||
LSRCS_ALL = $(patsubst ./%,%, $(sort $(shell find . -name "*.c" -o -name "*.cpp" -o -name "*.s" -o -name "*.cc")))
|
||||
else
|
||||
LSRCS_ALL = $(patsubst ./%,%, $(sort $(shell find ${LSRCS_DIRS} -name "*.c" -o -name "*.cpp" -o -name "*.s" -o -name "*.cc")))
|
||||
endif # LSRCS_DIRS
|
||||
|
||||
else # TREE_LIB_ENABLE
|
||||
LSRCS_ALL = $(patsubst ./%,%,$(sort $(wildcard *.c *.cpp *.s *.cc *.C))) # only include src in this dir.
|
||||
endif # TREE_LIB_ENABLE
|
||||
|
||||
endif # LSRCS
|
||||
|
||||
ifneq (,$(strip ${LSRCS_EXCLUDE_FILES}))
|
||||
$(info "ignore LSRCS_EXCLUDE_FILES source files: ${LSRCS_EXCLUDE_FILES}")
|
||||
endif
|
||||
|
||||
LSRCS = $(filter-out $(patsubst ./%,%,${LSRCS_EXCLUDE_FILES}),${LSRCS_ALL})
|
||||
LOBJS = $(addsuffix .o, $(basename ${LSRCS}))
|
||||
BOBJS = $(addprefix ${BLDDIR}/,${LOBJS})
|
||||
|
||||
#
|
||||
# Rule to create object file (build) directory
|
||||
#
|
||||
|
||||
.PHONY: all install clean
|
||||
|
||||
.PRECIOUS: ${BLDDIR}/.tree $(EXECDIR)
|
||||
|
||||
%/.tree:
|
||||
@$(ECHO) "[$(BP)] MKDIR $(dir $@)"
|
||||
$Q($(MKDIR) $(dir $@); $(TOUCH) $@)
|
||||
|
||||
# Rule allowing build through CPP only, creates .i file from .c file.
|
||||
|
||||
%.i: %.c
|
||||
@$Q$(ECHO) "EEEE ${LOCALDIR}/$<"
|
||||
$Q$(CC) -E ${CFLAGS} $< | $(SED) -e '/^ *$$/d' -e p -e d > $@
|
||||
|
||||
# Rule allowing build through source only, creates .s file from .c file.
|
||||
|
||||
%.s: %.c
|
||||
$Q$(CC) -S ${CFLAGS} $<
|
||||
|
||||
|
||||
NO_QMK_DEPS = 1
|
||||
|
||||
# allow disabling of dependency file generation
|
||||
# enable partial recompilation through use of included
|
||||
# dependency makefiles
|
||||
#
|
||||
ifndef NO_QMK_DEPS
|
||||
# take the compiler generated .d file and reparse it
|
||||
# to generate a dependency graph rule for this object
|
||||
# file
|
||||
# the two steps generate:
|
||||
# file.o: file.c \
|
||||
# file.h ...
|
||||
#
|
||||
# file.h:
|
||||
# header.h:
|
||||
# some compilers will generate errors without the latter
|
||||
# part of the list
|
||||
|
||||
.PHONY: .phony
|
||||
|
||||
zDEPS_SED = \
|
||||
$(CP) $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp;\
|
||||
$(ECHO) >> $(BLDDIR)/$*.tmp;\
|
||||
$(SED) -e 's/\#.*//' -e 's/^[^:]*: *//' \
|
||||
-e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' \
|
||||
-e '/^ .$$/d' \
|
||||
< $(BLDDIR)/$*.d >> $(BLDDIR)/$*.tmp; \
|
||||
$(SED) -e 's|^\([^\/ ].*\.o\):|'$(BLDDIR)/'\1:|g' \
|
||||
-e 's|.*?/\(.*\.o\):|'$(BLDDIR)/'\1:|g' \
|
||||
< $(BLDDIR)/$*.tmp > $(BLDDIR)/$*.P; \
|
||||
$(RM) -f $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp
|
||||
zDEPS_CMD = $(zDEPS_SED)
|
||||
|
||||
|
||||
# newer gnu-based compilers allow -MD -MF
|
||||
zDEPS_OPT = -MD -MF $(BLDDIR)/$*.d
|
||||
zDEPS_CMD = $(zDEPS_SED)
|
||||
|
||||
|
||||
# From gmsl
|
||||
|
||||
# Standard definitions for true and false. true is any non-empty
|
||||
# string, false is an empty string. These are intended for use with
|
||||
# $(if).
|
||||
|
||||
true := T
|
||||
false :=
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Function: not
|
||||
# Arguments: 1: A boolean value
|
||||
# Returns: Returns the opposite of the arg. (true -> false, false -> true)
|
||||
# ----------------------------------------------------------------------------
|
||||
not = $(if $1,$(false),$(true))
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Function: map
|
||||
# Arguments: 1: Name of function to $(call) for each element of list
|
||||
# 2: List to iterate over calling the function in 1
|
||||
# Returns: The list after calling the function on each element
|
||||
# ----------------------------------------------------------------------------
|
||||
map = $(strip $(foreach a,$2,$(call $1,$a)))
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Function: seq
|
||||
# Arguments: 1: A string to compare against...
|
||||
# 2: ...this string
|
||||
# Returns: Returns $(true) if the two strings are identical
|
||||
# ----------------------------------------------------------------------------
|
||||
seq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),$(false),$(true))
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Function: sne
|
||||
# Arguments: 1: A string to compare against...
|
||||
# 2: ...this string
|
||||
# Returns: Returns $(true) if the two strings are not the same
|
||||
# ----------------------------------------------------------------------------
|
||||
sne = $(call not,$(call seq,$1,$2))
|
||||
|
||||
# End from gmsl
|
||||
|
||||
# Define comma symbol so we can repace it with a variable
|
||||
comma :=,
|
||||
|
||||
# Signature
|
||||
last_target :=
|
||||
|
||||
adump_var = $$(eval $1 := $($1))
|
||||
|
||||
define new_rule
|
||||
@echo '$(call map,adump_var,@ < *)' > $S
|
||||
@$(if $(wildcard $F),,touch $F)
|
||||
@echo $@: $F >> $S
|
||||
endef
|
||||
|
||||
define zdo
|
||||
$(eval S := $(BLDDIR)/$*.sig)$(eval F := $(BLDDIR)/$*.force)$(eval C := $1)
|
||||
$(if $(call sne,$@,$(last_target)),$(call new_rule),$(eval last_target := $@))
|
||||
@echo '$$(if $$(call sne,$$(sort $1),$(sort $(subst $(comma),$$(comma),$C))),$$(shell touch $F))' >> $S
|
||||
$Q$C
|
||||
endef
|
||||
|
||||
# end of Signature
|
||||
|
||||
|
||||
else # ifndef NO_QMK_DEPS
|
||||
# No dependency files, faster compile times
|
||||
# no partial compile support
|
||||
zDEPS_SED =
|
||||
zDEPS_OPT =
|
||||
zDEPS_CPY =
|
||||
zDEPS_CMD = /bin/true
|
||||
|
||||
define zdo
|
||||
$(eval C := $1)
|
||||
$Q$C
|
||||
endef
|
||||
|
||||
endif # ifndef NO_QMK_DEPS
|
||||
|
||||
#
|
||||
# Default Build rules for .c --> .o, leaving the binary in BLDDIR/X.o,
|
||||
# even if file not built from directory of source.
|
||||
#
|
||||
|
||||
${BLDDIR}/%.o: %.c
|
||||
ifdef EEEE
|
||||
@$Q$(ECHO) "EEEE ${LOCALDIR}/$<"
|
||||
$Q$(CC) -E ${CFLAGS} $(EXTRA_CFLAGS) $< | $(SED) -e '/^ *$$/d' -e p -e d > $(@:.o=.i)
|
||||
endif
|
||||
# echo Compiling needed to properly process errors
|
||||
$Q$(MKDIR) $(BLDDIR)/
|
||||
$Q$(MKDIR) $(dir $@)
|
||||
$Q$(RM) -f $@
|
||||
@$Q$(ECHO) "[$(BP)] CCCC ${LOCALDIR}/$<"
|
||||
$Q$(call zdo,$$(CC) $$(zDEPS_OPT) $$(CFLAGS) $$(EXTRA_CFLAGS) -o $$@ -c $$(realpath $$<)) && ($(zDEPS_CMD))
|
||||
|
||||
${BLDDIR}/%.o: %.s
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHO) ASAS ${LOCALDIR}/$<
|
||||
endif
|
||||
$Q$(CC) ${CFLAGS} ${EXTRA_CFLAGS} -o $@ -c $(realpath $<)
|
||||
|
||||
${BLDDIR}/%.o: %.cpp
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHO) "[$(BP)] CCCC ${LOCALDIR}/$<"
|
||||
endif
|
||||
$Q$(CXX) ${CXXFLAGS} -o $@ -c $(realpath $<)
|
||||
|
||||
${BLDDIR}/%.o: %.cc ${BLDDIR}/.tree
|
||||
ifeq (@,$(Q))
|
||||
@$(ECHO) "[$(BP)] CCCC ${LOCALDIR}/$<"
|
||||
endif
|
||||
$Q$(CXX) ${CXXFLAGS} -o $@ -c $(realpath $<)
|
||||
|
||||
#
|
||||
# Cause "make foo.o" in any subdirectory to put the object in the build
|
||||
# directory instead of the local directory.
|
||||
#
|
||||
%.o: ${BLDDIR}/%.o
|
||||
@
|
||||
|
||||
#
|
||||
# Targets for build
|
||||
#
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
ifeq (help,$(findstring help,$(MAKECMDGOALS)))
|
||||
.PHONY: help
|
||||
help:
|
||||
$Q$(ECHO) "Usage:"
|
||||
$Q$(ECHO) -e "\t make help"
|
||||
$Q$(ECHO) -e "make for specified board-pack"
|
||||
$Q$(foreach v, $(SUPPORT-BP), $(call zdo, $$(ECHO) -e "\t make BP=$$(v)") )
|
||||
$Q$(ECHO) -e "\t BP dir are: $(QTOP)/qmk/board-pack/"
|
||||
$Q$(ECHO) -e "Clean build"
|
||||
$Q$(ECHO) -e "\t make clean all"
|
||||
$Q$(ECHO) -e "Debug build, verbose print, generate preprocess .i for .c"
|
||||
$Q$(ECHO) -e "\t make V=1 "
|
||||
$Q$(ECHO) -e "\t make EEEE=1 "
|
||||
$Q$(ECHO) -e "Debug Makefile"
|
||||
$Q$(ECHO) -e "\t make dm"
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
include ${QTOP}/qmk/generic/Make.lib
|
||||
include ${QTOP}/qmk/generic/Make.subdirs
|
||||
include ${QTOP}/qmk/generic/Make.depend
|
||||
|
||||
|
||||
include ${QTOP}/qmk/generic/Make.debug
|
||||
|
||||
|
Reference in New Issue
Block a user