Organize the build system

Change-Id: Ib331bae99041b998eb721b44c3b0b44426270b38
This commit is contained in:
Romain Goyet
2017-02-15 18:02:01 +01:00
parent 5a0ecfc1bc
commit babfe50763
18 changed files with 86 additions and 63 deletions

View File

@@ -1,17 +1,18 @@
PLATFORM ?= device
DEBUG ?= 1
include build/config.mak
include Makefile.$(PLATFORM)
ifndef USE_LIBA
$(error Makefile.PLATFORM should define USE_LIBA)
$(error platform.mak should define USE_LIBA)
endif
ifndef EXE
$(error Makefile.PLATFORM should define EXE, the extension for executables)
$(error platform.mak should define EXE, the extension for executables)
endif
HOSTCC = gcc
HOSTCXX = g++
# Flags - Optimizations
SFLAGS += $(OPTIM_SFLAGS)
# Flags - Header search path
SFLAGS += -Ilib -I.
@@ -21,12 +22,8 @@ SFLAGS += -Wall
# Flags - Header dependency tracking
SFLAGS += -MD -MP
# Flags - Optimizations
ifeq ($(DEBUG),1)
SFLAGS += -ggdb3 -DDEBUG=1 -O0
else
SFLAGS += -Os -fdata-sections -ffunction-sections
LDFLAGS += --gc-sections
SFLAGS += -DDEBUG=1
endif
# Language-specific flags

View File

@@ -1,9 +0,0 @@
CC=clang
CXX=clang++
LD=clang++
SIZE=size
SFLAGS += -DLIBA_LOG_DYNAMIC_MEMORY
USE_LIBA=1
EXE=elf

View File

@@ -1,28 +0,0 @@
TOOLCHAIN=arm-none-eabi
# FIXME decide which one to use.
#COMPILER=llvm
ifeq ($(COMPILER),llvm)
CC=clang
CXX=clang++
else
CC=$(TOOLCHAIN)-gcc
CXX=$(TOOLCHAIN)-g++
endif
LD=$(TOOLCHAIN)-ld.bfd
GDB=$(TOOLCHAIN)-gdb
OBJCOPY=$(TOOLCHAIN)-objcopy
SIZE=$(TOOLCHAIN)-size
# Flags - Arch
ifeq ($(COMPILER),llvm)
SFLAGS += -target thumbv7em-unknown-eabi
else
SFLAGS += -mthumb -march=armv7e-m -mfloat-abi=hard
endif
SFLAGS += -mcpu=cortex-m4 -mfpu=fpv4-sp-d16
# Platform configuration
USE_LIBA=1
EXE=elf

View File

@@ -1,9 +0,0 @@
CC=emcc
CXX=emcc
LD=emcc
LDFLAGS=-s EXPORTED_FUNCTIONS="['_main', '_IonEmscriptenPushEvent']" -Os --shell-file ion/src/emscripten/shell.html
SIZE=size
DEBUG=0
USE_LIBA=0
EXE=html

View File

@@ -1,7 +0,0 @@
CC=clang
CXX=clang++
LD=clang++
SIZE=size
USE_LIBA=0
EXE=elf

20
build/config.mak Normal file
View File

@@ -0,0 +1,20 @@
# You can edit this file to change build settings
PLATFORM ?= device
VERBOSE ?= 0
DEBUG ?= 1
LIBA_LOG_DYNAMIC_MEMORY ?= 0
ESCHER_LOG_EVENTS ?= 0
ION_EVENTS ?= keyboard
# Possible values : keyboard, stdin, random, replay
# Do not edit below this
ifeq ($(DEBUG),1)
OPTIM_SFLAGS ?= -O0
else
OPTIM_SFLAGS ?= -Os
endif
include build/platform.$(PLATFORM).mak
include build/toolchain.$(TOOLCHAIN).mak

View File

@@ -0,0 +1,3 @@
TOOLCHAIN ?= afl
USE_LIBA ?= 1
EXE = bin

View File

@@ -0,0 +1,7 @@
TOOLCHAIN ?= arm-gcc
ifeq ($(COMPILER),llvm)
# Compatibility with old build system
TOOLCHAIN = arm-llvm
endif
USE_LIBA = 1
EXE = elf

View File

@@ -0,0 +1,3 @@
TOOLCHAIN = emscripten
USE_LIBA = 0
EXE = html

View File

@@ -0,0 +1,3 @@
TOOLCHAIN ?= host-clang
USE_LIBA = 0
EXE = elf

3
build/toolchain.afl.mak Normal file
View File

@@ -0,0 +1,3 @@
CC = afl-clang
CXX = afl-clang++
LD = afl-clang++

View File

@@ -0,0 +1,13 @@
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
LD = arm-none-eabi-ld.bfd
GDB = arm-none-eabi-gdb
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
ifeq ($(DEBUG),1)
OPTIM_SFLAGS += -ggdb3
else
OPTIM_SFLAGS += -fdata-sections -ffunction-sections
LDFLAGS = --gc-sections
endif
SFLAGS = -mthumb -march=armv7e-m -mfloat-abi=hard -mcpu=cortex-m4 -mfpu=fpv4-sp-d16

View File

@@ -0,0 +1,4 @@
include build/toolchain.arm-gcc.mak
CC = clang
CXX = clang++
SFLAGS = -target thumbv7em-unknown-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16

View File

@@ -0,0 +1,5 @@
CC = emcc
CXX = emcc
LD = emcc
LDFLAGS = -s EXPORTED_FUNCTIONS="['_main', '_IonEmscriptenPushEvent']" -Os --shell-file ion/src/emscripten/shell.html
SIZE = size

View File

@@ -0,0 +1,4 @@
CC = clang
CXX = clang++
LD = clang++
GDB = lldb

View File

@@ -0,0 +1,6 @@
CC = mingw-w64-x86_64-gcc
CXX = mingw-w64-x86_64-g++
LD = mingw-w64-x86_64-g++
SFLAGS = -D_USE_MATH_DEFINES
LDFLAGS = -static -mwindows
EXE = exe

View File

@@ -1,5 +1,9 @@
SFLAGS += -Iescher/include
ifeq ($(ESCHER_LOG_EVENTS),1)
SFLAGS += -DESCHER_LOG_EVENTS=1
endif
objs += $(addprefix escher/src/,\
alternate_empty_view_controller.o\
app.o\

View File

@@ -1,5 +1,9 @@
SFLAGS += -Iliba/include
ifeq ($(LIBA_LOG_DYNAMIC_MEMORY),1)
SFLAGS += -DLIBA_LOG_DYNAMIC_MEMORY=1
endif
liba/src/external/sqlite/mem5.o: CFLAGS += -w
objs += $(addprefix liba/src/, \