litex: reorganize things, first work working version
[litex.git] / litex / soc / software / common.mak
1 TARGET_PREFIX=$(TRIPLE)-
2
3 RM ?= rm -f
4 PYTHON ?= python3
5
6 ifeq ($(CLANG),1)
7 CC_normal := clang -target $(TRIPLE) -integrated-as
8 CX_normal := clang++ -target $(TRIPLE) -integrated-as
9 else
10 CC_normal := $(TARGET_PREFIX)gcc
11 CX_normal := $(TARGET_PREFIX)g++
12 endif
13 AR_normal := $(TARGET_PREFIX)ar
14 LD_normal := $(TARGET_PREFIX)ld
15 OBJCOPY_normal := $(TARGET_PREFIX)objcopy
16
17 CC_quiet = @echo " CC " $@ && $(CC_normal)
18 CX_quiet = @echo " CX " $@ && $(CX_normal)
19 AR_quiet = @echo " AR " $@ && $(AR_normal)
20 LD_quiet = @echo " LD " $@ && $(LD_normal)
21 OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(OBJCOPY_normal)
22
23 ifeq ($(V),1)
24 CC = $(CC_normal)
25 CX = $(CX_normal)
26 AR = $(AR_normal)
27 LD = $(LD_normal)
28 OBJCOPY = $(OBJCOPY_normal)
29 else
30 CC = $(CC_quiet)
31 CX = $(CX_quiet)
32 AR = $(AR_quiet)
33 LD = $(LD_quiet)
34 OBJCOPY = $(OBJCOPY_quiet)
35 endif
36
37 # Toolchain options
38 #
39 INCLUDES = -I$(SOC_DIRECTORY)/software/include/base -I$(SOC_DIRECTORY)/software/include -I$(SOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY)
40 COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES)
41 CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
42 CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(SOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
43 LDFLAGS = -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY)
44
45 # compile and generate dependencies, based on
46 # http://scottmcpeak.com/autodepend/autodepend.html
47
48 define compilexx
49 $(CX) -c $(CXXFLAGS) $(1) $< -o $@
50 endef
51
52 define compile
53 $(CC) -c $(CFLAGS) $(1) $< -o $@
54 endef
55
56 define assemble
57 $(CC) -c $(CFLAGS) -o $@ $<
58 endef