qmk build system

This commit is contained in:
huangjimin
2020-07-14 16:06:01 +08:00
parent 3f3b4f1566
commit 25f293d49a
10 changed files with 375 additions and 18 deletions

View File

@@ -6,13 +6,15 @@
.SECONDARY:: ${LD_O_FILES}
include $(QTOP)/qmk/generic/Make.tpl
ifeq (,$(strip $(exec)))
exec = $(shell basename $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))
endif
OUTDIR = ${BLDDIR}/out
targetexec = ${OUTDIR}/${exec}
targetexec = ${OUTDIR}/${exec}.elf
all:: ${OUTDIR}/.tree ${targetexec}
@@ -31,8 +33,12 @@ 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
ifeq (,$(strip ${OBJCOPY}))
OBJCOPY=$(subst strip,objcopy,$(STRIP))
endif
$(targetexec): $(OUTDIR)/.tree ${LD_O_FILES}
@/bin/rm -f $@ # Prevent core dump if currently running
@$(ECHO) "[$(BP)] LINK $@" # This is needed for error parsing
$(Q)/bin/ls $(LIBDIR)
$(Q)$(CC) \
@@ -40,17 +46,23 @@ $(targetexec): $(OUTDIR)/strip/.tree ${LD_O_FILES}
-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 $@)
$(Q)$(STRIP) --strip-debug $@ -o $(OUTDIR)/$(basename $(notdir $@)).strip
$(Q)$(OBJCOPY) -O binary -S $@ $(OUTDIR)/$(basename $(notdir $@)).bin
$(Q)$(OBJCOPY) -O ihex $@ $(OUTDIR)/$(basename $(notdir $@)).hex
$(CP) $(OUTDIR)/$(basename $(notdir $@)).* $(LIBDIR)/
@$(ECHO) -e "[$(BP)] INFO [$(BP)] INFO \e[1;32mLINK OK,OK,OK!!!\e[m"
@$(ECHO) -e "\e[1;32m$$(/bin/ls $(LIBDIR)/$(basename $(notdir $@)).*)\e[m"
install:: all
clean::
$(Q)$(RM) ${BOBJS}
$(Q)$(RM) $(filter %.a ,$(LD_A_FILES))
$(Q)$(RM) ${bldroot_exec}
$(Q)$(RM) $(OUTDIR)/$(basename $(notdir ${targetexec})).*
$(Q)$(RM) $(LIBDIR)/$(basename $(notdir ${targetexec})).*
distclean:: clean
.PHONY: $(targetexec)

View File

@@ -96,7 +96,6 @@ BLD_SUFFIX := .tos
endif
BLDROOT = ${QTOP}/${QTOPBUILD}/$(if ${BLDCONFIG},${BLDCONFIG}/)${BP}.$(notdir $(firstword $(CC)))${BLD_SUFFIX}
#$(info BLDROOT=$(BLDROOT))
ifdef LOCALDIR
@@ -106,13 +105,12 @@ 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
@@ -132,7 +130,12 @@ ifneq (,$(strip ${LSRCS_EXCLUDE_FILES}))
$(info "ignore LSRCS_EXCLUDE_FILES source files: ${LSRCS_EXCLUDE_FILES}")
endif
ifndef LSRCS
LSRCS = $(filter-out $(patsubst ./%,%,${LSRCS_EXCLUDE_FILES}),${LSRCS_ALL})
else
$(info $(shell echo -e "[$(BP)] INFO LSRCS is defined by users, LSRCS=$(LSRCS)"))
endif
LOBJS = $(addsuffix .o, $(basename ${LSRCS}))
BOBJS = $(addprefix ${BLDDIR}/,${LOBJS})