X-Git-Url: https://rtime.felk.cvut.cz/gitweb/arc.git/blobdiff_plain/4b43f5fe98c0c504df2b2d4fa373d6575e80db68..HEAD:/makefile diff --git a/makefile b/makefile index f3b2a710..6b64781e 100644 --- a/makefile +++ b/makefile @@ -1,33 +1,34 @@ - # build with: -# make subdir1 - build the subdir1 -# make subdir1/subdir2 - build subdir2 -# -# clean: -# Removed all generated files +# $ make BOARDDIR= BDIR=[,] CROSS_COMPILE= all|clean|clean_all +# +# TARGETS +# all: Target when building +# clean: Remove generatated files for a board +# clean_all: Remove all generated files +# help: Print some help # -# BOARDDIR= +# VARIABLES: +# BOARDDIR= # Select what board to build for - -# BOARDDIR= -# Select what board to build for -# -# Q=[(@)/empty] +# BDIR=[,] +# Select what directories to build. The kernel is always built. +# CROSS_COMPILE +# Specify the compiler to use. +# Q=[(@)/empty] # If Q=@ cmd's will not be echoed. -# -# Build -# >make BOARDDIR=mpc551xsim BDIR=system/kernel,examples/simple all -# Clean -# >make BOARDDIR=mpc551xsim BDIR=system/kernel,examples/simple clean +# +# EXAMPLES +# Clean all +# $ make clean_all +# +# Clean for a specific board +# $ make BDIR=mpc551xsim clean +# +# Build the simple example (assuming CROSS_COMPILE set) +# $ make BOARDDIR= mpc551xsim BDIR=examples/simple all # - -#-include board_config.mk -#export ARCH -#export ARCH_FAM -#export BOARDDIR - export UNAME:=$(shell uname) ifneq ($(findstring Darwin,$(UNAME)),) @@ -37,136 +38,151 @@ else export SED=sed endif -USE_DBG_PRINTF?=y +ifeq ($(VERBOSE),y) +export Q?= +else +export Q?=@ +endif -Q?=@ -export Q export TOPDIR = $(CURDIR) -export RELEASE = n export PATH -#ifeq (${BDIR},) -# -include saved_config.mk -#endif +# Select default console +# RAMLOG | TTY_T32 | TTY_WINIDEA +export SELECT_OS_CONSOLE +export SELECT_CONSOLE +export USE_DEBUG_PRINTF +export SELECT_OPT ifneq ($(filter clean_all,$(MAKECMDGOALS)),clean_all) - ifeq (${BOARDDIR},) - $(error BOARDDIR is empty) + ifeq ($(BOARDDIR),) + $(error BOARDDIR is empty) + endif + ifeq ($(BDIR),) + $(error BDIR is empty) endif endif USE_T32_SIM?=n export USE_T32_SIM -export BUILD_TREE=y -export RELEASE_TREE=n - -override BDIR := system/kernel ${BDIR} -#BDIR += system/kernel/testsystem - -# Misc -#subdir-y += ecum -# Drivers - - # Tools # Ugly thing to make things work under cmd.exe PATH := /usr/bin/:$(PATH) -find := $(shell which find) +FIND := $(shell which find) export objdir = obj_$(BOARDDIR) - -#comma = , -#empty = -#space = $(empty) $(empty) - -.PHONY: clean -.PHONY: release - -.PHONY: help -help: - @echo "Make kernel and a simple example" - @echo " > make BOARDDIR=mpc551xsim CROSS_COMPILE=/opt/powerpc-eabi/bin/powerpc-eabi- BDIR=system/kernel,examples/simple all" - @echo "" - @echo "Save the config (CROSS_COMPILE and BDIR)" - @echo " > make BOARDDIR=mpc551xsim CROSS_COMPILE=/opt/powerpc-eabi/bin/powerpc-eabi- BDIR=system/kernel,examples/simple save" - @echo "" - @echo "Clean" - @echo " > make clean" - @echo "" - @echo "Present config:" - @echo " ARCH=$(ARCH)" - @echo " ARCH_FAM=$(ARCH_FAM)" - @echo " BOARDDIR =$(BOARDDIR)" - @echo " CROSS_COMPILE =$(CROSS_COMPILE)" - @echo "" - -def-$(USE_T32_SIM) += USE_T32_SIM -def-$(USE_DBG_PRINTF) += USE_DBG_PRINTF - - export CFG_MCU export CFG_CPU export MCU export def-y+=$(CFG_ARCH_$(ARCH)) $(CFG_MCU) $(CFG_CPU) -BASEDIR = $(TOPDIR)/$(MOD) - # We descend into the object directories and build the. That way it's easier to build # multi-arch support and we don't have to use objdir everywhere. # ROOTDIR - The top-most directory # SUBDIR - The current subdirectory it's building. -test: - make embUnit/textui embunit/embUnit drivers/test all - comma:= , +empty:= +space:= $(empty) $(empty) split = $(subst $(comma), ,$(1)) - - -#dir_cmd_goals := $(filter-out %_config config testa all install uninstall clean test save,$(MAKECMDGOALS)) dir_cmd_goals := $(call split,$(BDIR)) +cmd_cmd_goals := $(filter all clean config,$(MAKECMDGOALS)) -cmd_cmd_goals := $(filter clean all install,$(MAKECMDGOALS)) +# Check for CROSS_COMPILE +ifneq ($(cmd_cmd_goals),) -#$(error $(dir_cmd_goals) $(MAKECMDGOALS)) +# Check that the board actually exist +ifdef BOARDDIR + all_boards := $(subst boards/,,$(shell $(FIND) boards/ -maxdepth 1 -type d)) + all_boards_print := $(subst $(space),$(comma)$(space),$(strip $(all_boards))) + ifeq ($(filter $(BOARDDIR),$(all_boards)),) + $(error no such board: $(BOARDDIR), valid boards are: $(all_boards_print)) + endif +endif + +# Check BDIR +endif libs: mkdir -p $@ +.PHONY all: + all: libs $(dir_cmd_goals) +.PHONY: clean +.PHONY: release + +.PHONY: help +help: + @echo "Build a simple example" + @echo " > make BOARDDIR=mpc551xsim CROSS_COMPILE=/opt/powerpc-eabi/bin/powerpc-eabi- BDIR=examples/simple all" + @echo "" + @echo "Clean" + @echo " > make clean" + @echo "" + @echo "Present config:" + @echo " BDIR = ${BDIR}" + @echo " BOARDDIR = $(BOARDDIR)" + @echo " CROSS_COMPILE = $(CROSS_COMPILE)" + @echo " CURDIR = $(CURDIR)" + @echo "" + + +test: + @echo $(all_boards) + show_build: - @echo Building for $(dir_cmd_goals) - @echo BOARDDIR: $(BOARDDIR) - @echo ARCH_FAM/ARCH: $(ARCH_FAM)/$(ARCH) + @echo "" + @echo "==========[ BUILD INFO ]===========" + @echo " BDIR: $(BDIR) [$(origin BDIR)]" + @echo " BOARDDIR: $(BOARDDIR) [$(origin BOARDDIR)]" + @echo " COMPILER: $(COMPILER) [$(origin COMPILER)]" +ifeq ($(COMPILER),cw) + @echo " CW_COMPILE: $(CW_COMPILE) [$(origin CW_COMPILE)]" +else + @echo " CROSS_COMPILE: $(CROSS_COMPILE) [$(origin CROSS_COMPILE)]" +endif + @echo " CURDIR: $(CURDIR)" + @echo " SELECT_CONSOLE: $(SELECT_CONSOLE) [$(origin SELECT_CONSOLE)]" + + - $(dir_cmd_goals) :: show_build FORCE - @echo ==========[ $@ ]=========== + @echo "" + @echo ==========[ ${abspath $@} ]=========== + @if [ ! -d $@ ]; then echo "No such directory: \"$@\" quitting"; exit 1; fi +@[ -d $@/$(objdir) ] || mkdir -p $@/$(objdir) @chmod 777 $@/$(objdir) $(Q)$(MAKE) -r -C $@/$(objdir) -f $(CURDIR)/scripts/rules.mk ROOTDIR=$(CURDIR) SUBDIR=$@ $(cmd_cmd_goals) - - -# --no-print-directory - .PHONY: test FORCE: +.PHONY: boards +boards: + @find . -type d -name * + clean_all: - @find . -type d -name obj_* | xargs rm -rf - @find . -type f -name *.a | xargs rm -rf - echo Done! + $(Q)find . -type d -name obj_* | xargs rm -rf + $(Q)find . -type f -name *.a | xargs rm -rf + @echo + @echo " >>>>>>>>> DONE <<<<<<<<<" + @echo + +config: $(dir_cmd_goals) +.PHONY clean: clean: $(dir_cmd_goals) - @echo "Clean:" - @echo " Removing objectfiles and libs for ARCH=$(ARCH)" - @find . -type d -name $(objdir) | xargs rm -rf - @find . -type f -name *.a| xargs rm -rf - @rm -rf libs/* - @echo Done! + @echo + @echo " >> Cleaning MAIN $(CURDIR)" +# $(Q)find . -type d -name $(objdir) | xargs rm -rf +# $(Q)find . -type f -name *.a | xargs rm -rf +# $(Q)rm -rf libs/* + @echo + @echo " >>>>>>>>> DONE <<<<<<<<<" + @echo