2015-07-25 20:28:37 -04:00
|
|
|
TARGET_PREFIX=$(TRIPLE)-
|
2012-02-03 06:08:17 -05:00
|
|
|
|
2013-05-10 16:30:28 -04:00
|
|
|
RM ?= rm -f
|
2015-07-31 06:31:04 -04:00
|
|
|
PYTHON ?= python3
|
2013-05-10 16:30:28 -04:00
|
|
|
|
2015-07-26 09:06:48 -04:00
|
|
|
ifeq ($(CLANG),1)
|
2015-07-28 04:51:28 -04:00
|
|
|
CC_normal := clang -target $(TRIPLE) -integrated-as
|
|
|
|
CX_normal := clang++ -target $(TRIPLE) -integrated-as
|
2015-07-26 03:00:58 -04:00
|
|
|
else
|
|
|
|
CC_normal := $(TARGET_PREFIX)gcc
|
|
|
|
CX_normal := $(TARGET_PREFIX)g++
|
|
|
|
endif
|
2015-07-25 20:28:37 -04:00
|
|
|
AR_normal := $(TARGET_PREFIX)ar
|
|
|
|
LD_normal := $(TARGET_PREFIX)ld
|
2013-02-16 17:41:42 -05:00
|
|
|
OBJCOPY_normal := $(TARGET_PREFIX)objcopy
|
2012-02-03 06:08:17 -05:00
|
|
|
|
2015-07-25 20:28:37 -04:00
|
|
|
CC_quiet = @echo " CC " $@ && $(CC_normal)
|
|
|
|
CX_quiet = @echo " CX " $@ && $(CX_normal)
|
|
|
|
AR_quiet = @echo " AR " $@ && $(AR_normal)
|
|
|
|
LD_quiet = @echo " LD " $@ && $(LD_normal)
|
|
|
|
OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(OBJCOPY_normal)
|
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
|
|
|
AR = $(AR_normal)
|
|
|
|
LD = $(LD_normal)
|
|
|
|
OBJCOPY = $(OBJCOPY_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
|
|
|
AR = $(AR_quiet)
|
|
|
|
LD = $(LD_quiet)
|
|
|
|
OBJCOPY = $(OBJCOPY_quiet)
|
2012-02-03 06:08:17 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Toolchain options
|
|
|
|
#
|
2015-09-28 08:33:37 -04:00
|
|
|
INCLUDES = -I$(MISOC_DIRECTORY)/software/include/base -I$(MISOC_DIRECTORY)/software/include -I$(MISOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY)
|
|
|
|
COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES)
|
2015-07-25 20:30:21 -04:00
|
|
|
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
|
2015-09-28 08:33:37 -04:00
|
|
|
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MISOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
|
|
|
|
LDFLAGS = -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY)
|
2012-02-03 06:25:55 -05:00
|
|
|
|
|
|
|
# compile and generate dependencies, based on
|
|
|
|
# http://scottmcpeak.com/autodepend/autodepend.html
|
|
|
|
|
2015-11-03 11:31:53 -05:00
|
|
|
define compilexx
|
|
|
|
$(CX) -c $(CXXFLAGS) $(1) $< -o $@
|
2013-03-24 11:11:53 -04:00
|
|
|
endef
|
|
|
|
|
2015-11-03 11:31:53 -05:00
|
|
|
define compile
|
|
|
|
$(CC) -c $(CFLAGS) $(1) $< -o $@
|
2013-01-10 11:20:31 -05:00
|
|
|
endef
|
|
|
|
|
|
|
|
define assemble
|
2015-11-03 11:31:53 -05:00
|
|
|
$(CC) -c $(CFLAGS) -o $@ $<
|
2012-05-31 14:17:33 -04:00
|
|
|
endef
|