2014-05-14 04:24:56 -04:00
|
|
|
include $(MSCDIR)/software/include/generated/cpu.mak
|
|
|
|
TARGET_PREFIX=$(CPU)-elf-
|
2012-02-03 06:08:17 -05:00
|
|
|
|
2013-05-10 16:30:28 -04:00
|
|
|
RM ?= rm -f
|
|
|
|
|
2013-02-16 17:41:42 -05:00
|
|
|
CC_normal := $(TARGET_PREFIX)gcc
|
2013-03-24 11:11:53 -04:00
|
|
|
CX_normal := $(TARGET_PREFIX)g++
|
2013-02-16 17:41:42 -05:00
|
|
|
AS_normal := $(TARGET_PREFIX)as
|
|
|
|
AR_normal := $(TARGET_PREFIX)ar
|
|
|
|
LD_normal := $(TARGET_PREFIX)ld
|
|
|
|
OBJCOPY_normal := $(TARGET_PREFIX)objcopy
|
|
|
|
RANLIB_normal := $(TARGET_PREFIX)ranlib
|
2012-02-03 06:08:17 -05:00
|
|
|
|
2015-04-03 05:43:29 -04:00
|
|
|
CC_quiet = @echo " CC " $@ && $(TARGET_PREFIX)gcc
|
|
|
|
CX_quiet = @echo " CX " $@ && $(TARGET_PREFIX)g++
|
|
|
|
AS_quiet = @echo " AS " $@ && $(TARGET_PREFIX)as
|
|
|
|
AR_quiet = @echo " AR " $@ && $(TARGET_PREFIX)ar
|
|
|
|
LD_quiet = @echo " LD " $@ && $(TARGET_PREFIX)ld
|
2013-02-16 17:41:42 -05:00
|
|
|
OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(TARGET_PREFIX)objcopy
|
2015-04-03 05:43:29 -04:00
|
|
|
RANLIB_quiet = @echo " RANLIB " $@ && $(TARGET_PREFIX)ranlib
|
2012-02-03 06:08:17 -05:00
|
|
|
|
2015-05-02 08:26:19 -04:00
|
|
|
MSC_GIT_ID := $(shell cd $(MSCDIR) && python3 -c "from misoclib.cpu.git import get_id; print(hex(get_id()), end='')")
|
2013-11-09 10:38:44 -05:00
|
|
|
|
2012-02-03 06:08:17 -05:00
|
|
|
ifeq ($(V),1)
|
2013-01-10 11:20:31 -05:00
|
|
|
CC = $(CC_normal)
|
2013-03-24 11:11:53 -04:00
|
|
|
CX = $(CX_normal)
|
2013-01-10 11:20:31 -05:00
|
|
|
AS = $(AS_normal)
|
|
|
|
AR = $(AR_normal)
|
|
|
|
LD = $(LD_normal)
|
|
|
|
OBJCOPY = $(OBJCOPY_normal)
|
|
|
|
RANLIB = $(RANLIB_normal)
|
2012-02-03 06:08:17 -05:00
|
|
|
else
|
2013-01-10 11:20:31 -05:00
|
|
|
CC = $(CC_quiet)
|
2013-03-24 11:11:53 -04:00
|
|
|
CX = $(CX_quiet)
|
2013-01-10 11:20:31 -05:00
|
|
|
AS = $(AS_quiet)
|
|
|
|
AR = $(AR_quiet)
|
|
|
|
LD = $(LD_quiet)
|
|
|
|
OBJCOPY = $(OBJCOPY_quiet)
|
|
|
|
RANLIB = $(RANLIB_quiet)
|
2012-02-03 06:08:17 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Toolchain options
|
|
|
|
#
|
2013-11-09 09:27:32 -05:00
|
|
|
INCLUDES = -I$(MSCDIR)/software/include/base -I$(MSCDIR)/software/include -I$(MSCDIR)/common
|
2014-05-14 04:24:56 -04:00
|
|
|
COMMONFLAGS = -Os $(CPUFLAGS) -Wall -fno-builtin -nostdinc -DMSC_GIT_ID=$(MSC_GIT_ID) $(INCLUDES)
|
2013-03-24 11:11:53 -04:00
|
|
|
CFLAGS = $(COMMONFLAGS) -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
|
|
|
|
CXXFLAGS = $(COMMONFLAGS) -fno-exceptions -ffreestanding
|
2013-11-24 13:50:17 -05:00
|
|
|
LDFLAGS = -nostdlib -nodefaultlibs -L$(MSCDIR)/software/include
|
2012-02-03 06:25:55 -05:00
|
|
|
|
|
|
|
# compile and generate dependencies, based on
|
|
|
|
# http://scottmcpeak.com/autodepend/autodepend.html
|
|
|
|
|
2013-03-24 11:11:53 -04:00
|
|
|
define compilexx-dep
|
2013-05-19 06:41:40 -04:00
|
|
|
$(CX) -c $(CXXFLAGS) $(1) $< -o $*.o
|
|
|
|
@$(CX_normal) -MM $(CXXFLAGS) $(1) $< > $*.d
|
2013-03-24 11:11:53 -04:00
|
|
|
@mv -f $*.d $*.d.tmp
|
|
|
|
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
|
|
|
|
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
|
|
|
|
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
|
|
|
|
@rm -f $*.d.tmp
|
|
|
|
endef
|
|
|
|
|
2013-01-10 11:20:31 -05:00
|
|
|
define compile-dep
|
2013-05-19 06:41:40 -04:00
|
|
|
$(CC) -c $(CFLAGS) $(1) $< -o $*.o
|
|
|
|
@$(CC_normal) -MM $(CFLAGS) $(1) $< > $*.d
|
2012-05-31 14:17:33 -04:00
|
|
|
@mv -f $*.d $*.d.tmp
|
|
|
|
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
|
|
|
|
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
|
|
|
|
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
|
|
|
|
@rm -f $*.d.tmp
|
2013-01-10 11:20:31 -05:00
|
|
|
endef
|
|
|
|
|
|
|
|
define assemble
|
2014-05-14 04:24:56 -04:00
|
|
|
$(CC) -c $(CFLAGS) -o $*.o $<
|
2012-05-31 14:17:33 -04:00
|
|
|
endef
|