Commit e7f464de authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Harmonizing the two Makefiles - going for merging

parent 0a82f9e7
Pipeline #72 skipped
# Configuration section
#
# 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
EDISOFT_SUPPORT_PATH ?= /root/development/build/rtems-impr/testsuites/support
CROSS_PREFIX=sparc-rtems4.8
# 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 ':'
#
# DEAR USER, YOU MUST EDIT THIS AND ADD YOUR SOURCE FOLDERS
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)
EDISOFT_SRC= \
printk.c \
......@@ -35,26 +45,28 @@ EDISOFT_SRC= \
# compile with newlib! See EDISOFT's UMDN for details.
#
# 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,
# VPATH will locate them...
NONFPU_SRC= \
#
# DEAR USER, YOU MUST EDIT THIS
SRC= \
init.c \
task1.c \
task2.c \
${EDISOFT_SRC}
FPU_SRC= \
task1.c \
task2.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})
DEP = $(patsubst %.c, deps.$(SUFFIX)/%.d, ${SRC})
OBJ = $(patsubst %.c, objs.$(SUFFIX)/%.o, ${SRC})
# Your final binary
#
# DEAR USER, YOU MUST EDIT THIS
TARGET=fputest
# What compiler to use for generating dependencies:
......@@ -67,20 +79,18 @@ INCLUDEFLAGS= -I${EDISOFT_SUPPORT_PATH}/include -I src
# Compilation flags (common)
COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems -nodefaultlibs \
-mcpu=cypress -DBSP_leon3
-mcpu=cypress -DBSP_${LEON}
# Separate compile options per configuration
ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS} -msoft-float
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
else
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS} -msoft-float
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
endif
# Should we generate native FPU instructions for the FPU_SRC?
ifeq ($(FPU),1)
CFLAGS_FPU:=$(shell bash -c "echo ${CFLAGS} | sed 's,-msoft-float,,'")
else
CFLAGS_FPU:=${CFLAGS}
# Should we generate emulated FPU instructions for the SRC?
ifeq ($(FPU),0)
CFLAGS += -msoft-float
LDFLAGS += -msoft-float
endif
......@@ -94,22 +104,29 @@ LDFLAGS += ${COMMON} -nodefaultlibs -Wl,--wrap,_IO_Initialize_all_drivers \
-Wl,--end-group -Wl,--script=linkcmds \
-B/tmp/edilibtmp/edilib/library -lgcc
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}: ${OBJ} | inform
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -g -o $@ $^ ${LDFLAGS}
......@@ -121,9 +138,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)/%.o: %.c
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -c $(CFLAGS) -o $@ $<
......@@ -132,38 +149,21 @@ else
@$(CC) -c $(CFLAGS) -o $@ $<
endif
objs.$(CFG)/FPU_%.o: %.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
deps.$(SUFFIX)/%.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
@mkdir -p $(dir $@)
@echo Generating dependencies for $<
@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 $@.$$$$
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
# (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean)
-include ${NONFPU_DEP}
-include ${FPU_DEP}
ifneq ($(CFG),)
-include ${DEP}
endif
endif
......@@ -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) {
printk("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);
}
printk("Parent task sleeps for a second...\n");
......
......@@ -29,7 +29,7 @@ CROSS_PREFIX=sparc-rtems4.11
# 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
# Your source files: regardless of where they reside in the source tree,
......@@ -70,9 +70,9 @@ COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems \
# Separate compile options per configuration
ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -D_DEBUG ${INCLUDEFLAGS}
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
else
CFLAGS += ${COMMON} -g -O2 ${INCLUDEFLAGS}
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
endif
# Should we generate native FPU instructions for the SRC or not?
......@@ -143,5 +143,7 @@ clean:
# which are auto-generated. Don't fail if they are missing
# (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(CFG),)
-include ${DEP}
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