blob: 5ddfb26b79bb0bb5c15ecb3de16cc64be0e3fee4 [file] [log] [blame]
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07001-include local.mk
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -08002include make/macros.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07003
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -07004PROJECT ?= beagle-test
Travis Geiselbrechteb946052008-09-07 22:32:49 -07005DEBUG ?= 2
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07006
7BUILDDIR := build-$(PROJECT)
8OUTBIN := $(BUILDDIR)/lk.bin
9OUTELF := $(BUILDDIR)/lk
10CONFIGHEADER := $(BUILDDIR)/config.h
11
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070012INCLUDES := -I$(BUILDDIR) -Iinclude
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070013CFLAGS := -O2 -g -fno-builtin -finline -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -include $(CONFIGHEADER)
14#CFLAGS += -Werror
15CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics
16#CPPFLAGS += -Weffc++
17ASMFLAGS := -DASSEMBLY
18LDFLAGS :=
19
20CFLAGS += -ffunction-sections -fdata-sections
21LDFLAGS += -gc-sections
22
23# top level rule
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070024all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070025
26# the following three object lists are identical except for the ordering
27# which is bootobjs, kobjs, objs
28BOOTOBJS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070029OBJS :=
30
31# a linker script needs to be declared in one of the project/target/platform files
32LINKER_SCRIPT :=
33
34# anything you add here will be deleted in make clean
35GENERATED := $(CONFIGHEADER)
36
37# anything added to DEFINES will be put into $(BUILDDIR)/config.h
38DEFINES := LK=1
39
40# Anything added to SRCDEPS will become a dependency of every source file in the system.
41# Useful for header files that may be included by one or more source files.
42SRCDEPS := $(CONFIGHEADER)
43
44# these need to be filled out by the project/target/platform rules.mk files
45TARGET :=
46PLATFORM :=
47ARCH :=
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070048ALLMODULES :=
49MODULES :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070050
51# any rules you put here will also be built by the system before considered being complete
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070052EXTRA_BUILDDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070053
54# any rules you put here will be depended on in clean builds
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070055EXTRA_CLEANDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070056
Travis Geiselbrecht577036f2009-01-24 21:37:21 -080057include project/$(PROJECT).mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070058include target/$(TARGET)/rules.mk
59include platform/$(PLATFORM)/rules.mk
60include arch/$(ARCH)/rules.mk
61include platform/rules.mk
62include target/rules.mk
63include kernel/rules.mk
64include dev/rules.mk
Travis Geiselbrecht68372232009-01-24 21:21:08 -080065include app/rules.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070066
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070067# recursively include any modules in the MODULE variable, leaving a trail of included
68# modules in the ALLMODULES list
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -080069include make/module.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070070
71# any extra top level build dependencies that someone declared
72all:: $(EXTRA_BUILDDEPS)
73
74ALLOBJS := \
75 $(BOOTOBJS) \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070076 $(OBJS)
77
78# add some automatic configuration defines
79DEFINES += \
80 PROJECT_$(PROJECT)=1 \
81 TARGET_$(TARGET)=1 \
82 PLATFORM_$(PLATFORM)=1 \
83 ARCH_$(ARCH)=1 \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070084 $(addsuffix =1,$(addprefix WITH_,$(ALLMODULES)))
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070085
86# debug build?
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070087ifneq ($(DEBUG),)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070088DEFINES += \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070089 DEBUG=$(DEBUG)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070090endif
91
92ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS))
93
94DEPS := $(ALLOBJS:%o=%d)
95
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070096# default to no ccache
97CCACHE ?=
98CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070099LD := $(TOOLCHAIN_PREFIX)ld
100OBJDUMP := $(TOOLCHAIN_PREFIX)objdump
101OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
102CPPFILT := $(TOOLCHAIN_PREFIX)c++filt
103SIZE := $(TOOLCHAIN_PREFIX)size
104NM := $(TOOLCHAIN_PREFIX)nm
105
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700106# comment out or override if you want to see the full output of each command
107NOECHO ?= @
108
109# the logic to compile and link stuff is in here
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800110include make/build.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700111
112clean: $(EXTRA_CLEANDEPS)
113 rm -f $(ALLOBJS) $(DEPS) $(GENERATED) $(OUTBIN) $(OUTELF) $(OUTELF).lst
114
115spotless:
116 rm -rf build-*
117
118install: all
119 scp $(OUTBIN) 192.168.0.4:/tftproot
120
121# generate a config.h file with all of the DEFINES laid out in #define format
122configheader:
123
124$(CONFIGHEADER): configheader
125 @$(MKDIR)
126 @echo generating $@
127 @rm -f $(CONFIGHEADER).tmp; \
128 echo \#ifndef __CONFIG_H > $(CONFIGHEADER).tmp; \
129 echo \#define __CONFIG_H >> $(CONFIGHEADER).tmp; \
130 for d in `echo $(DEFINES) | tr [:lower:] [:upper:]`; do \
131 echo "#define $$d" | sed "s/=/\ /g;s/-/_/g;s/\//_/g" >> $(CONFIGHEADER).tmp; \
132 done; \
133 echo \#endif >> $(CONFIGHEADER).tmp; \
134 if [ -f "$(CONFIGHEADER)" ]; then \
135 if cmp "$(CONFIGHEADER).tmp" "$(CONFIGHEADER)"; then \
136 rm -f $(CONFIGHEADER).tmp; \
137 else \
138 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
139 fi \
140 else \
141 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
142 fi
143
144# Empty rule for the .d files. The above rules will build .d files as a side
145# effect. Only works on gcc 3.x and above, however.
146%.d:
147
148ifeq ($(filter $(MAKECMDGOALS), clean), )
149-include $(DEPS)
150endif
151
152.PHONY: configheader