Makefile: use the compiler driver directly
Этот коммит содержится в:
родитель
76a513802f
коммит
5e9e3bd1a0
1 изменённых файлов: 7 добавлений и 39 удалений
46
Makefile
46
Makefile
|
@ -5,37 +5,22 @@ tgo: build/tgo
|
||||||
|
|
||||||
.PHONY: all tgo run-test run-blinky run-blinky2 clean fmt gen-device gen-device-nrf
|
.PHONY: all tgo run-test run-blinky run-blinky2 clean fmt gen-device gen-device-nrf
|
||||||
|
|
||||||
CFLAGS = -Wall -Werror -Os -fno-exceptions -ffunction-sections -fdata-sections $(LLFLAGS)
|
|
||||||
CFLAGS += -fno-exceptions -fno-unwind-tables # Avoid .ARM.exidx etc.
|
|
||||||
|
|
||||||
TARGET ?= unix
|
TARGET ?= unix
|
||||||
|
|
||||||
ifeq ($(TARGET),unix)
|
ifeq ($(TARGET),unix)
|
||||||
# Regular *nix system.
|
# Regular *nix system.
|
||||||
LD = clang
|
|
||||||
SIZE = size
|
SIZE = size
|
||||||
|
|
||||||
else ifeq ($(TARGET),pca10040)
|
else ifeq ($(TARGET),pca10040)
|
||||||
# PCA10040: nRF52832 development board
|
# PCA10040: nRF52832 development board
|
||||||
LD = arm-none-eabi-ld -T arm.ld --gc-sections
|
|
||||||
SIZE = arm-none-eabi-size
|
SIZE = arm-none-eabi-size
|
||||||
OBJCOPY = arm-none-eabi-objcopy
|
OBJCOPY = arm-none-eabi-objcopy
|
||||||
LLFLAGS += -target armv7m-none-eabi
|
|
||||||
TGOFLAGS += -target $(TARGET)
|
TGOFLAGS += -target $(TARGET)
|
||||||
CFLAGS += -I$(CURDIR)/lib/CMSIS/CMSIS/Include
|
|
||||||
CFLAGS += -DNRF52832_XXAA
|
|
||||||
CFLAGS += -Wno-uninitialized
|
|
||||||
OBJ += build/nrfx_system_nrf52.o
|
|
||||||
OBJ += build/nrfx_startup_nrf51.o # TODO nrf52, see https://bugs.llvm.org/show_bug.cgi?id=31601
|
|
||||||
|
|
||||||
else ifeq ($(TARGET),arduino)
|
else ifeq ($(TARGET),arduino)
|
||||||
AS = avr-as -mmcu=atmega328p
|
|
||||||
LD = avr-ld -T avr.ld --gc-sections
|
|
||||||
SIZE = avr-size
|
SIZE = avr-size
|
||||||
OBJCOPY = avr-objcopy
|
OBJCOPY = avr-objcopy
|
||||||
LLFLAGS += -target avr8--
|
|
||||||
TGOFLAGS += -target $(TARGET)
|
TGOFLAGS += -target $(TARGET)
|
||||||
OBJ += build/avr.o
|
|
||||||
|
|
||||||
else
|
else
|
||||||
$(error Unknown target)
|
$(error Unknown target)
|
||||||
|
@ -82,32 +67,15 @@ build/tgo: *.go
|
||||||
@mkdir -p build
|
@mkdir -p build
|
||||||
go build -o build/tgo -i .
|
go build -o build/tgo -i .
|
||||||
|
|
||||||
# Build IR with the Go compiler.
|
# Binary that can run on the host.
|
||||||
build/%.o: src/examples/% src/examples/%/*.go build/tgo src/runtime/*.go
|
build/%: src/examples/% src/examples/%/*.go build/tgo src/runtime/*.go
|
||||||
./build/tgo build $(TGOFLAGS) -o $@ $(subst src/,,$<)
|
./build/tgo build $(TGOFLAGS) -o $@ $(subst src/,,$<)
|
||||||
|
@$(SIZE) $@
|
||||||
|
|
||||||
# Compile system_* file for the nRF.
|
# ELF file that can run on a microcontroller.
|
||||||
build/nrfx_%.o: lib/nrfx/mdk/%.c
|
build/%.elf: src/examples/% src/examples/%/*.go build/tgo src/runtime/*.go
|
||||||
@mkdir -p build
|
./build/tgo build $(TGOFLAGS) -o $@ $(subst src/,,$<)
|
||||||
clang $(CFLAGS) -c -o $@ $^
|
@$(SIZE) $@
|
||||||
|
|
||||||
# Compile startup_* file for the nRF.
|
|
||||||
build/nrfx_%.o: lib/nrfx/mdk/gcc_%.S
|
|
||||||
@mkdir -p build
|
|
||||||
clang $(CFLAGS) -D__STARTUP_CLEAR_BSS -c -o $@ $^
|
|
||||||
|
|
||||||
build/%.o: %.S
|
|
||||||
$(AS) -o $@ $^
|
|
||||||
|
|
||||||
# Generate output ELF executable.
|
|
||||||
build/%: build/%.o $(OBJ)
|
|
||||||
$(LD) -o $@ $^
|
|
||||||
$(SIZE) $@
|
|
||||||
|
|
||||||
# Generate output ELF for use in objcopy (on a microcontroller).
|
|
||||||
build/%.elf: build/%.o $(OBJ)
|
|
||||||
$(LD) -o $@ $^
|
|
||||||
$(SIZE) $@
|
|
||||||
|
|
||||||
# Convert executable to Intel hex file (for flashing).
|
# Convert executable to Intel hex file (for flashing).
|
||||||
build/%.hex: build/%.elf
|
build/%.hex: build/%.elf
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче