From e493c6bfe90fe56b78ed71a227f3930767a1a40a Mon Sep 17 00:00:00 2001 From: Thanassis Tsiodras Date: Thu, 7 Apr 2016 17:30:29 +0200 Subject: [PATCH] Use proper compiler (as per Sebastian's suggestions) --- OAR/Makefile | 89 +++++++++++++++++++++++++++++--------------------- OAR/src/init.c | 4 +-- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/OAR/Makefile b/OAR/Makefile index af516b6..75c4dd3 100644 --- a/OAR/Makefile +++ b/OAR/Makefile @@ -1,43 +1,53 @@ # Configuration section # # Use environment variables if found, otherwise fallback to sane defaults + +# If not explicitely selected (with 'make FPU=1'), compile for FPU emulation +ifeq ($(FPU),) +FPU=0 +endif + +# To be able to properly handle any combination of (FPU, LEON, release) +# options, create a SUFFIX (see below) to differentiate output folders +ifeq ($(FPU),1) +FPU_SUFFIX=FPU +else +FPU_SUFFIX=NONFPU +endif + +# Build up our settings from our inputs and our environment LEON ?= leon3 -RTEMS ?= /opt/rtems-4.11-2016.04.01.FPU +RTEMS ?= /opt/rtems-4.11-2016.04.01.${FPU_SUFFIX} RTEMS_MAKEFILE_PATH ?= ${RTEMS}/sparc-rtems4.11/${LEON} RTEMS_LIB=${RTEMS_MAKEFILE_PATH}/lib CROSS_PREFIX=sparc-rtems4.11 -# Detect the platform (last part of the path of RTEMS_MAKEFILE_PATH - e.g. leon3, leon2, etc) -PLATFORM = $(shell sh -c "echo ${RTEMS_MAKEFILE_PATH} | sed 's,^.*/,,'") +# If not selected, compile debug version of binary (no optimizations) +#ifeq ($(CFG),) +#CFG=debug +#endif # The directories containing the source files, separated by ':' VPATH=src -# If not selected, compile debug version of binary (no optimizations) -ifeq ($(CFG),) -CFG=debug -endif - -# If not explicitely selected (with 'make FPU=1'), compile for FPU emulation -ifeq ($(FPU),) -FPU=0 -endif - # Your source files: regardless of where they reside in the source tree, # VPATH will locate them... NONFPU_SRC= \ - init.c + init.c \ + task2.c +# Code that must be compiled with native FPU enabled (when FPU=1 is passed) FPU_SRC= \ - task1.c \ - task2.c + task1.c + +SUFFIX=$(CFG).$(FPU_SUFFIX).$(LEON) # Build a Dependency list and an Object list, by replacing the .c # extension to .d for dependency files, and .o for object files. -NONFPU_DEP = $(patsubst %.c, deps.$(CFG)/NONFPU_%.d, ${NONFPU_SRC}) -FPU_DEP = $(patsubst %.c, deps.$(CFG)/FPU_%.d, ${FPU_SRC}) -NONFPU_OBJ = $(patsubst %.c, objs.$(CFG)/NONFPU_%.o, ${NONFPU_SRC}) -FPU_OBJ = $(patsubst %.c, objs.$(CFG)/FPU_%.o, ${FPU_SRC}) +NONFPU_DEP = $(patsubst %.c, deps.$(SUFFIX)/NONFPU_%.d, ${NONFPU_SRC}) +FPU_DEP = $(patsubst %.c, deps.$(SUFFIX)/FPU_%.d, ${FPU_SRC}) +NONFPU_OBJ = $(patsubst %.c, objs.$(SUFFIX)/NONFPU_%.o, ${NONFPU_SRC}) +FPU_OBJ = $(patsubst %.c, objs.$(SUFFIX)/FPU_%.o, ${FPU_SRC}) # Your final binary TARGET=fputest @@ -59,16 +69,16 @@ COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems \ # Separate compile options per configuration ifeq ($(CFG),debug) -CFLAGS += ${COMMON} -g -D_DEBUG ${INCLUDEFLAGS} -msoft-float +CFLAGS += ${COMMON} -g -D_DEBUG ${INCLUDEFLAGS} else -CFLAGS += ${COMMON} -g -O2 ${INCLUDEFLAGS} -msoft-float +CFLAGS += ${COMMON} -g -O2 ${INCLUDEFLAGS} endif # Should we generate native FPU instructions for the FPU_SRC? ifeq ($(FPU),1) -CFLAGS:=$(shell bash -c "echo ${CFLAGS} | sed 's,-msoft-float,,'") CFLAGS_FPU:=${CFLAGS} else +CFLAGS += -msoft-float CFLAGS_FPU:=${CFLAGS} LDFLAGS += -msoft-float endif @@ -76,22 +86,29 @@ endif # A common link flag for all configurations LDFLAGS += ${COMMON} -Wl,--gc-sections -all: inform bin.$(CFG)/${TARGET} +all: inform bin.$(SUFFIX)/${TARGET} inform: ifneq ($(CFG),release) ifneq ($(CFG),debug) - @echo "Invalid configuration "$(CFG)" specified." + @echo " " + @echo "Invalid or missing configuration (CFG) "$(CFG)" specified." + @echo " " @echo "You must specify a configuration when running make, e.g." - @echo "make CFG=debug" - @echo - @echo "Possible choices for configuration are 'release' and 'debug'" + @echo " " + @echo " make CFG=debug LEON=leon3 FPU=1 V=1" + @echo " " + @echo "- Possible choices for CFG are 'release' and 'debug'" + @echo "- Possible choices for LEON are 'leon2' and 'leon3' (default)" + @echo "- Possible choices for FPU are '1' (native) and '0' (emulated) (default)" + @echo "- Possible choices for V are '1' (show commands) and '0' (silent) (default)" + @echo " " @exit 1 endif endif -bin.$(CFG)/${TARGET}: ${NONFPU_OBJ} ${FPU_OBJ} | inform +bin.$(SUFFIX)/${TARGET}: ${NONFPU_OBJ} ${FPU_OBJ} | inform @mkdir -p $(dir $@) ifeq ($(V),1) $(CC) -g -o $@ $^ ${LDFLAGS} @@ -103,9 +120,9 @@ ifeq ($(CFG),release) @${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug @${CROSS_PREFIX}-strip $@ endif - @echo Built with RTEMS at ${RTEMS_LIB} for ${PLATFORM}. + @echo Built with RTEMS at ${RTEMS_LIB} for ${LEON}. -objs.$(CFG)/NONFPU_%.o: %.c +objs.$(SUFFIX)/NONFPU_%.o: %.c @mkdir -p $(dir $@) ifeq ($(V),1) $(CC) -c $(CFLAGS) -o $@ $< @@ -114,7 +131,7 @@ else @$(CC) -c $(CFLAGS) -o $@ $< endif -objs.$(CFG)/FPU_%.o: %.c +objs.$(SUFFIX)/FPU_%.o: %.c @mkdir -p $(dir $@) ifeq ($(V),1) $(CC) -c $(CFLAGS_FPU) -o $@ $< @@ -123,14 +140,14 @@ else @$(CC) -c $(CFLAGS_FPU) -o $@ $< endif -deps.$(CFG)/NONFPU_%.d: %.c +deps.$(SUFFIX)/NONFPU_%.d: %.c @mkdir -p $(dir $@) @echo Generating dependencies for $< @set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,objs.$(CFG)\/NONFPU_\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ -deps.$(CFG)/FPU_%.d: %.c +deps.$(SUFFIX)/FPU_%.d: %.c @mkdir -p $(dir $@) @echo Generating dependencies for $< @set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \ @@ -138,9 +155,7 @@ deps.$(CFG)/FPU_%.d: %.c rm -f $@.$$$$ clean: - @rm -rf \ - deps.debug objs.debug bin.debug \ - deps.release objs.release bin.release + @rm -rf deps.* objs.* bin.* # Unless "make clean" is called, include the dependency files # which are auto-generated. Don't fail if they are missing diff --git a/OAR/src/init.c b/OAR/src/init.c index 4d4b5ea..644c163 100644 --- a/OAR/src/init.c +++ b/OAR/src/init.c @@ -27,7 +27,7 @@ rtems_task Init(rtems_task_argument argument) RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, // use RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE for Linux/Windows like // handling of tasks with same priority (i.e. pre-emption) - i == 0 ? RTEMS_FLOATING_POINT : RTEMS_DEFAULT_ATTRIBUTES, + i == 1 ? RTEMS_FLOATING_POINT : RTEMS_DEFAULT_ATTRIBUTES, &Task_id[i]); if (status != RTEMS_SUCCESSFUL) { printf("Failed to rtems_task_create... status:%0x\n", status); @@ -37,7 +37,7 @@ rtems_task Init(rtems_task_argument argument) // Start Task status = rtems_task_start( Task_id[i], - i == 0 ? Task1_EntryPoint : Task2_EntryPoint, + i == 1 ? Task1_EntryPoint : Task2_EntryPoint, i); } printf("Parent task sleeps for a second...\n"); -- GitLab