2 # Copyright (c) 2006 Atmark Techno, Inc. All Rights Reserved.
6 # Guarantee that the top-level TARGET variable, if set, is armadillo.
12 .PROFILE := $(PROFILE)
18 # Configure settings based on the target passed from the top-level
19 # makefile. The PROFILE := armadillo line is just a default and can
20 # be overridden from the command line.
22 NCVT = ../../../tools/ncvt
23 current-profile := $(shell $(NCVT) $(TARGET) $(.PROFILE))
24 ifneq (,$(wildcard profile-stamp))
25 previous-profile := $(shell cat profile-stamp)
26 ifneq ($(current-profile), $(previous-profile))
27 error := profile-error
32 # Configuration for standalone, optimized ARM920T cross-compile.
34 BUILD_NAME := $(shell $(NCVT) -c "-" loader $(TARGET) $(.PROFILE) v$(HERMIT_VERSION))
35 BUILD_TARGETS := $(BUILD_NAME).bin
38 GCC_VER := $(shell $(CROSS)gcc -dumpversion | sed "s/\..*//")
39 INCLUDEDIR := ../../../include
41 CFLAGS := -Wall -O2 -fomit-frame-pointer -I$(INCLUDEDIR) -nostdlib \
42 -DHERMIT_VERSION='"$(HERMIT_VERSION)"' \
43 -march=armv4 -mtune=arm9tdmi -static
44 CFLAGS += -DTARGET_STRING=\"$(TARGET)\" -DPROFILE_STRING=\"$(.PROFILE)\"
47 # The LDSCRIPT variable can be overridden based on the target-derived
51 OBJSECTIONS := .boot .text .data .bss
52 OBJCOPYFLAGS := -O binary -S $(addprefix -j ,$(OBJSECTIONS))
54 ASMS := boot.S lib1funcs.S
55 SRCS := entry.c loader.c memmap.c linux.c board.c mmu.c medium_io.c
56 SRCS += ../memzero.c ../medium.c ../frob.c ../setenv.c ../gunzip.c
57 SRCS += ../flash/flash_core.c ../flash/flash_amd.c
61 SRCS += ../flash/flash_spi_dummy.c ../flash/flash_intel_dummy.c
68 CFLAGS += -DCONSOLE=0 -DRELOCATE
69 status := profile-detect
72 ifeq (eth, $(.PROFILE))
73 SRCS += eth_ep93xx.c i2c_armadillo2x0.c tftpdl.c
74 SRCS += ../net/arp.c ../net/eth.c ../net/eth_util.c ../net/ip.c
75 SRCS += ../net/tftp.c ../net/udp.c ../net/mac.c
76 CFLAGS += -DCONSOLE=0 -DRELOCATE -DENABLE_ETH
77 # CFLAGS += -DDEBUG_ETH
78 status := profile-detect
81 ifeq (ttyAM1, $(.PROFILE))
82 CFLAGS += -DCONSOLE=1 -DRELOCATE
83 status := profile-detect
86 ifeq (notty, $(.PROFILE))
88 status := profile-detect
91 ifeq (boot, $(.PROFILE))
92 ASMS := init.S lib1funcs.S
93 CFLAGS += -DCONSOLE=0 -DBOOTMODE
95 status := profile-detect
98 ifeq (boot-eth, $(.PROFILE))
99 ASMS := init.S lib1funcs.S
100 SRCS += eth_ep93xx.c i2c_armadillo2x0.c tftpdl.c
101 SRCS += ../net/arp.c ../net/eth.c ../net/eth_util.c ../net/ip.c
102 SRCS += ../net/tftp.c ../net/udp.c ../net/mac.c
103 CFLAGS += -DCONSOLE=0 -DBOOTMODE -DENABLE_ETH
104 # CFLAGS += -DDEBUG_ETH
106 status := profile-detect
116 # S*21/24*31 = 399.974400MHz
121 # S*21/16*19 = 367.718400MHz
126 CFLAGS += -DPLL_HI=$(.PLL_HI)
129 CFLAGS += -DPLL_LO=$(.PLL_LO)
134 error := profile-unknown
138 OBJS := $(SRCS:.c=.o)
139 DEPS := $(SRCS:.c=.d)
140 LIBS := -lgcc -ltarget
142 all: $(error) profile-stamp $(BUILD_TARGETS)
145 @echo "profile-stamp mismatch; 'make scrub' to switch profiles"
146 @echo " previous PROFILE:" $(previous-profile)
147 @echo " current PROFILE:" $(current-profile)
150 @echo "unknown PROFILE: $(.PROFILE)"
153 @echo "$(current-profile)" > $@
155 # Hermit second stage loader (ELF image)
156 $(BUILD_NAME).elf: $(ASMS) $(OBJS) ../common/libtarget.a Makefile $(BUILD_NAME).lds
157 $(CC) $(CFLAGS) -L. -L../common \
158 -Wl,-Map,$(BUILD_NAME).map \
159 -Wl,-T$(BUILD_NAME).lds -o $@ \
161 -Wl,--start-group $(LIBS) -Wl,--end-group
163 $(BUILD_NAME).lds: $(wildcard loader.lds.*)
164 cp loader.lds.$(LDSCRIPT) $@
167 $(CROSS)objcopy $(OBJCOPYFLAGS) $< $@
169 # automated dependency checking
170 ifeq (,$(filter clean scrub,$(MAKECMDGOALS)))
173 DEPENDS := ../../../depend.sh
175 env CC=$(CC) $(DEPENDS) $< $@ $(CFLAGS)
181 $(INSTALL) -m 644 -o root -g root \
183 $(INSTALLPREFIX)/lib/hermit/
188 rm -f $(OBJS) loader-*.lds *.elf *.bin *.map
191 rm -f *.d ../*.d ../flash/*.d ../net/*.d
192 rm -f *.o ../*.o ../flash/*.o ../net/*.o