96 lines
3.1 KiB
Plaintext
96 lines
3.1 KiB
Plaintext
|
os:=${shell uname -s}
|
||
|
|
||
|
OBJDIR?=obj
|
||
|
BINDIR?=exe
|
||
|
|
||
|
|
||
|
ifndef COMPILER
|
||
|
COMPILER=gcc
|
||
|
endif
|
||
|
|
||
|
ifeq (${COMPILER}, gcc)
|
||
|
|
||
|
PREFIX:=${shell type arm-stellaris-eabi-gcc > /dev/null 2>&1 && \
|
||
|
echo arm-stellaris-eabi || echo arm-none-eabi}
|
||
|
|
||
|
CC=${PREFIX}-gcc
|
||
|
|
||
|
ARMGCC_ROOT:=${shell dirname '${shell sh -c "which ${CC}"}'}/..
|
||
|
|
||
|
CPU=-mcpu=cortex-m4
|
||
|
#FPU=-mfpu=fpv4-sp-d16 -mfloat-abi=softfp
|
||
|
|
||
|
AFLAGS=-mthumb \
|
||
|
${CPU} \
|
||
|
${FPU} \
|
||
|
-MD
|
||
|
|
||
|
CFLAGS=-mthumb \
|
||
|
${CPU} \
|
||
|
${FPU} \
|
||
|
-ffunction-sections \
|
||
|
-fdata-sections \
|
||
|
-MD \
|
||
|
-std=c99 \
|
||
|
-g \
|
||
|
-O0 \
|
||
|
-c
|
||
|
|
||
|
AR=${PREFIX}-ar
|
||
|
LD=${PREFIX}-ld
|
||
|
|
||
|
LDFLAGS=--gc-sections
|
||
|
|
||
|
# Get the location of libgcc.a from the GCC front-end.
|
||
|
LIBGCC:=${shell ${CC} -mthumb ${CFLAGS} -print-libgcc-file-name}
|
||
|
|
||
|
# Get the location of libc.a from the GCC front-end.
|
||
|
LIBC:=${shell ${CC} ${CFLAGS} -print-file-name=libc.a}
|
||
|
|
||
|
# Get the location of libm.a from the GCC front-end.
|
||
|
LIBM:=${shell ${CC} ${CFLAGS} -print-file-name=libm.a}
|
||
|
|
||
|
OBJCOPY=${PREFIX}-objcopy
|
||
|
|
||
|
CFLAGS+=${CFLAGSgcc}
|
||
|
|
||
|
AFLAGS+=${patsubst %,-I%,${subst :, ,${IPATH}}}
|
||
|
CFLAGS+=${patsubst %,-I%,${subst :, ,${IPATH}}}
|
||
|
|
||
|
${OBJDIR}/%.o: %.c
|
||
|
${CC} ${CFLAGS} -D${COMPILER} -o ${@} ${<}
|
||
|
|
||
|
${OBJDIR}/%.o: driverlib/%.c
|
||
|
${CC} ${CFLAGS} -D${COMPILER} -o ${@} ${<}
|
||
|
|
||
|
${OBJDIR}/%.o: %.S
|
||
|
${CC} ${AFLAGS} -D${COMPILER} -o ${@} -c ${<}
|
||
|
|
||
|
${BINDIR}/%.a:
|
||
|
${AR} -cr ${@} ${^}
|
||
|
|
||
|
${BINDIR}/%.axf:
|
||
|
@if [ 'x${SCATTERgcc_${notdir ${@:.axf=}}}' = x ]; \
|
||
|
then \
|
||
|
ldname="${ROOT}/gcc/standalone.ld"; \
|
||
|
else \
|
||
|
ldname="${SCATTERgcc_${notdir ${@:.axf=}}}"; \
|
||
|
fi; \
|
||
|
if [ 'x${VERBOSE}' = x ]; \
|
||
|
then \
|
||
|
echo " LD ${@} ${LNK_SCP}"; \
|
||
|
else \
|
||
|
echo ${LD} -T $${ldname} \
|
||
|
--entry ${ENTRY_${notdir ${@:.axf=}}} \
|
||
|
${LDFLAGSgcc_${notdir ${@:.axf=}}} \
|
||
|
${LDFLAGS} -o ${@} $(filter %.o %.a, ${^}) \
|
||
|
'${LIBM}' '${LIBC}' '${LIBGCC}'; \
|
||
|
fi; \
|
||
|
${LD} -T $${ldname} \
|
||
|
--entry ${ENTRY_${notdir ${@:.axf=}}} \
|
||
|
${LDFLAGSgcc_${notdir ${@:.axf=}}} \
|
||
|
${LDFLAGS} -o ${@} $(filter %.o %.a, ${^}) \
|
||
|
'${LIBM}' '${LIBC}' '${LIBGCC}'
|
||
|
@${OBJCOPY} -O binary ${@} ${@:.axf=.bin}
|
||
|
endif
|