Makefile (2177B)
1 ## Copyright 2011 Brian Swetland <swetland@frotz.net> 2 ## 3 ## Licensed under the Apache License, Version 2.0 (the "License"); 4 ## you may not use this file except in compliance with the License. 5 ## You may obtain a copy of the License at 6 ## 7 ## http://www.apache.org/licenses/LICENSE-2.0 8 ## 9 ## Unless required by applicable law or agreed to in writing, software 10 ## distributed under the License is distributed on an "AS IS" BASIS, 11 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 ## See the License for the specific language governing permissions and 13 ## limitations under the License. 14 15 what_to_build:: all 16 17 -include local.mk 18 19 TOOLCHAIN ?= arm-none-eabi- 20 21 TARGET_CC := $(TOOLCHAIN)gcc 22 TARGET_LD := $(TOOLCHAIN)ld 23 TARGET_AR := $(TOOLCHAIN)ar 24 TARGET_OBJCOPY := $(TOOLCHAIN)objcopy 25 TARGET_OBJDUMP := $(TOOLCHAIN)objdump 26 27 TARGET_CFLAGS := -g -Os -Wall 28 TARGET_CFLAGS += -Wno-unused-but-set-variable 29 TARGET_CFLAGS += -I. -Iinclude 30 TARGET_CFLAGS += -mcpu=cortex-m3 -mthumb -mthumb-interwork 31 TARGET_CFLAGS += -ffunction-sections -fdata-sections 32 TARGET_CFLAGS += -fno-builtin -nostdlib 33 34 # tell gcc there's not a full libc it can depend on 35 # so it won't do thinks like printf("...") -> puts("...") 36 TARGET_CFLAGS += -ffreestanding 37 TARGET_LFLAGS := --gc-sections 38 39 #TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_CFLAGS) -print-libgcc-file-name) 40 41 UNAME := $(shell uname) 42 UNAME_M := $(shell uname -m) 43 44 HOST_CFLAGS := -g -O1 -Wall 45 HOST_CFLAGS += -Itools -Iinclude 46 HOST_CFLAGS += -DLINENOISE_INTERRUPTIBLE 47 48 ifeq ($(UNAME),Darwin) 49 HOST_CFLAGS += -I/opt/local/include -L/opt/local/lib 50 HOST_LIBS += -lusb-1.0 51 endif 52 ifeq ($(UNAME),Linux) 53 HOST_CFLAGS += -DWITH_THUMB2_DISASSEMBLE=1 54 HOST_LIBS += -lusb-1.0 -lpthread -lrt 55 endif 56 57 OUT := out 58 BIN := bin 59 OUT_HOST_OBJ := $(OUT)/_obj/host 60 OUT_TARGET_OBJ := $(OUT)/_obj/target 61 62 ALL := 63 DEPS := 64 AGENTS := 65 66 # build system internals 67 include build/build.mk 68 69 # architecture configurations 70 include $(wildcard arch/*/config.mk) 71 72 # additional modules 73 include $(wildcard */module.mk) 74 75 clean:: 76 @echo clean 77 @rm -rf $(OUT) $(BIN) 78 79 # we generate .d as a side-effect of compiling. override generic rule: 80 %.d: 81 -include $(DEPS) 82 83 all:: $(ALL) 84