Commit e7f464de authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Harmonizing the two Makefiles - going for merging

parent 0a82f9e7
Pipeline #72 skipped
# Configuration section # Configuration section
# #
# Use environment variables if found, otherwise fallback to sane defaults # Use environment variables if found, otherwise fallback to sane defaults
RTEMS_MAKEFILE_PATH ?= /opt/rtems-4.8/sparc-rtems4.8/leon3 #
# 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_MAKEFILE_PATH = /opt/rtems-4.8/sparc-rtems4.8/${LEON}
RTEMS_LIB=${RTEMS_MAKEFILE_PATH}/lib RTEMS_LIB=${RTEMS_MAKEFILE_PATH}/lib
EDISOFT_SUPPORT_PATH ?= /root/development/build/rtems-impr/testsuites/support EDISOFT_SUPPORT_PATH ?= /root/development/build/rtems-impr/testsuites/support
CROSS_PREFIX=sparc-rtems4.8 CROSS_PREFIX=sparc-rtems4.8
# Detect the platform (last part of the path of RTEMS_MAKEFILE_PATH - e.g. leon3, leon2, etc) # If not selected, compile debug version of binary (no optimizations)
PLATFORM = $(shell sh -c "echo ${RTEMS_MAKEFILE_PATH} | sed 's,^.*/,,'") #ifeq ($(CFG),)
#CFG=debug
#endif
# The directories containing the source files, separated by ':' # The directories containing the source files, separated by ':'
#
# DEAR USER, YOU MUST EDIT THIS AND ADD YOUR SOURCE FOLDERS
VPATH=src:${EDISOFT_SUPPORT_PATH}/src VPATH=src:${EDISOFT_SUPPORT_PATH}/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
# Use EDISOFT's support code for e.g. printing to serial (printk) # Use EDISOFT's support code for e.g. printing to serial (printk)
EDISOFT_SRC= \ EDISOFT_SRC= \
printk.c \ printk.c \
...@@ -35,26 +45,28 @@ EDISOFT_SRC= \ ...@@ -35,26 +45,28 @@ EDISOFT_SRC= \
# compile with newlib! See EDISOFT's UMDN for details. # compile with newlib! See EDISOFT's UMDN for details.
# #
# This is necessary for printk (serial port registers per specific BSP) # This is necessary for printk (serial port registers per specific BSP)
EDISOFT_SRC += ${PLATFORM}.c EDISOFT_SRC += ${LEON}.c
# Your source files: regardless of where they reside in the source tree, # Your source files: regardless of where they reside in the source tree,
# VPATH will locate them... # VPATH will locate them...
NONFPU_SRC= \ #
init.c \ # DEAR USER, YOU MUST EDIT THIS
SRC= \
init.c \
task1.c \
task2.c \
${EDISOFT_SRC} ${EDISOFT_SRC}
FPU_SRC= \ SUFFIX=$(CFG).$(FPU_SUFFIX).$(LEON)
task1.c \
task2.c
# Build a Dependency list and an Object list, by replacing the .c # Build a Dependency list and an Object list, by replacing the .c
# extension to .d for dependency files, and .o for object files. # extension to .d for dependency files, and .o for object files.
NONFPU_DEP = $(patsubst %.c, deps.$(CFG)/NONFPU_%.d, ${NONFPU_SRC}) DEP = $(patsubst %.c, deps.$(SUFFIX)/%.d, ${SRC})
FPU_DEP = $(patsubst %.c, deps.$(CFG)/FPU_%.d, ${FPU_SRC}) OBJ = $(patsubst %.c, objs.$(SUFFIX)/%.o, ${SRC})
NONFPU_OBJ = $(patsubst %.c, objs.$(CFG)/NONFPU_%.o, ${NONFPU_SRC})
FPU_OBJ = $(patsubst %.c, objs.$(CFG)/FPU_%.o, ${FPU_SRC})
# Your final binary # Your final binary
#
# DEAR USER, YOU MUST EDIT THIS
TARGET=fputest TARGET=fputest
# What compiler to use for generating dependencies: # What compiler to use for generating dependencies:
...@@ -67,20 +79,18 @@ INCLUDEFLAGS= -I${EDISOFT_SUPPORT_PATH}/include -I src ...@@ -67,20 +79,18 @@ INCLUDEFLAGS= -I${EDISOFT_SUPPORT_PATH}/include -I src
# Compilation flags (common) # Compilation flags (common)
COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems -nodefaultlibs \ COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems -nodefaultlibs \
-mcpu=cypress -DBSP_leon3 -mcpu=cypress -DBSP_${LEON}
# Separate compile options per configuration # Separate compile options per configuration
ifeq ($(CFG),debug) ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS} -msoft-float CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
else else
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS} -msoft-float CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
endif endif
# Should we generate native FPU instructions for the FPU_SRC? # Should we generate emulated FPU instructions for the SRC?
ifeq ($(FPU),1) ifeq ($(FPU),0)
CFLAGS_FPU:=$(shell bash -c "echo ${CFLAGS} | sed 's,-msoft-float,,'") CFLAGS += -msoft-float
else
CFLAGS_FPU:=${CFLAGS}
LDFLAGS += -msoft-float LDFLAGS += -msoft-float
endif endif
...@@ -94,22 +104,29 @@ LDFLAGS += ${COMMON} -nodefaultlibs -Wl,--wrap,_IO_Initialize_all_drivers \ ...@@ -94,22 +104,29 @@ LDFLAGS += ${COMMON} -nodefaultlibs -Wl,--wrap,_IO_Initialize_all_drivers \
-Wl,--end-group -Wl,--script=linkcmds \ -Wl,--end-group -Wl,--script=linkcmds \
-B/tmp/edilibtmp/edilib/library -lgcc -B/tmp/edilibtmp/edilib/library -lgcc
all: inform bin.$(CFG)/${TARGET} all: inform bin.$(SUFFIX)/${TARGET}
inform: inform:
ifneq ($(CFG),release) ifneq ($(CFG),release)
ifneq ($(CFG),debug) 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 "You must specify a configuration when running make, e.g."
@echo "make CFG=debug" @echo " "
@echo @echo " make CFG=debug LEON=leon3 FPU=1 V=1"
@echo "Possible choices for configuration are 'release' and 'debug'" @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 @exit 1
endif endif
endif endif
bin.$(CFG)/${TARGET}: ${NONFPU_OBJ} ${FPU_OBJ} | inform bin.$(SUFFIX)/${TARGET}: ${OBJ} | inform
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
ifeq ($(V),1) ifeq ($(V),1)
$(CC) -g -o $@ $^ ${LDFLAGS} $(CC) -g -o $@ $^ ${LDFLAGS}
...@@ -121,9 +138,9 @@ ifeq ($(CFG),release) ...@@ -121,9 +138,9 @@ ifeq ($(CFG),release)
@${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug @${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug
@${CROSS_PREFIX}-strip $@ @${CROSS_PREFIX}-strip $@
endif 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)/%.o: %.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
ifeq ($(V),1) ifeq ($(V),1)
$(CC) -c $(CFLAGS) -o $@ $< $(CC) -c $(CFLAGS) -o $@ $<
...@@ -132,38 +149,21 @@ else ...@@ -132,38 +149,21 @@ else
@$(CC) -c $(CFLAGS) -o $@ $< @$(CC) -c $(CFLAGS) -o $@ $<
endif endif
objs.$(CFG)/FPU_%.o: %.c deps.$(SUFFIX)/%.d: %.c
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -c $(CFLAGS_FPU) -o $@ $<
else
@echo [CC] $@
@$(CC) -c $(CFLAGS_FPU) -o $@ $<
endif
deps.$(CFG)/NONFPU_%.d: %.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@echo Generating dependencies for $< @echo Generating dependencies for $<
@set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \ @set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,objs.$(CFG)\/NONFPU_\1.o $@ : ,g' < $@.$$$$ > $@; \ sed 's,\($*\)\.o[ :]*,objs.$(CFG)\/\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
deps.$(CFG)/FPU_%.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 $@.$$$$ rm -f $@.$$$$
clean: clean:
@rm -rf \ @rm -rf deps.* objs.* bin.*
deps.debug objs.debug bin.debug \
deps.release objs.release bin.release
# Unless "make clean" is called, include the dependency files # Unless "make clean" is called, include the dependency files
# which are auto-generated. Don't fail if they are missing # which are auto-generated. Don't fail if they are missing
# (-include), since they will be missing in the first invocation! # (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),clean)
-include ${NONFPU_DEP} ifneq ($(CFG),)
-include ${FPU_DEP} -include ${DEP}
endif
endif endif
...@@ -27,7 +27,7 @@ rtems_task Init(rtems_task_argument argument) ...@@ -27,7 +27,7 @@ rtems_task Init(rtems_task_argument argument)
RTEMS_MINIMUM_STACK_SIZE, RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES, // use RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE for Linux/Windows like RTEMS_DEFAULT_MODES, // use RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE for Linux/Windows like
// handling of tasks with same priority (i.e. pre-emption) // 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]); &Task_id[i]);
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_task_create... status:%0x\n", status); printk("Failed to rtems_task_create... status:%0x\n", status);
...@@ -37,7 +37,7 @@ rtems_task Init(rtems_task_argument argument) ...@@ -37,7 +37,7 @@ rtems_task Init(rtems_task_argument argument)
// Start Task // Start Task
status = rtems_task_start( status = rtems_task_start(
Task_id[i], Task_id[i],
i == 0 ? Task1_EntryPoint : Task2_EntryPoint, i == 1 ? Task1_EntryPoint : Task2_EntryPoint,
i); i);
} }
printk("Parent task sleeps for a second...\n"); printk("Parent task sleeps for a second...\n");
......
...@@ -29,7 +29,7 @@ CROSS_PREFIX=sparc-rtems4.11 ...@@ -29,7 +29,7 @@ CROSS_PREFIX=sparc-rtems4.11
# The directories containing the source files, separated by ':' # The directories containing the source files, separated by ':'
# #
# DEAR USER, YOU MUST EDIT THIS # DEAR USER, YOU MUST EDIT THIS AND ADD YOUR SOURCE FOLDERS
VPATH=src VPATH=src
# Your source files: regardless of where they reside in the source tree, # Your source files: regardless of where they reside in the source tree,
...@@ -70,9 +70,9 @@ COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems \ ...@@ -70,9 +70,9 @@ COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems \
# Separate compile options per configuration # Separate compile options per configuration
ifeq ($(CFG),debug) ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -D_DEBUG ${INCLUDEFLAGS} CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
else else
CFLAGS += ${COMMON} -g -O2 ${INCLUDEFLAGS} CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
endif endif
# Should we generate native FPU instructions for the SRC or not? # Should we generate native FPU instructions for the SRC or not?
...@@ -143,5 +143,7 @@ clean: ...@@ -143,5 +143,7 @@ clean:
# which are auto-generated. Don't fail if they are missing # which are auto-generated. Don't fail if they are missing
# (-include), since they will be missing in the first invocation! # (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),clean)
ifneq ($(CFG),)
-include ${DEP} -include ${DEP}
endif endif
endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment