aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: f8fc84194c6c0c9e2e5e59a5a2f8f25ff892d163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Makefile - build a kernel+filesystem image for stand-alone Linux booting
#
# Copyright (C) 2011 ARM Limited. All rights reserved.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE.txt file.


# Include config file (prefer config.mk, fall back to config-default.mk)
ifneq ($(wildcard config.mk),)
include config.mk
else
include config-default.mk
endif

LIBFDTOBJS      = libfdt/fdt.o libfdt/fdt_ro.o libfdt/fdt_wip.o \
		  libfdt/fdt_sw.o libfdt/fdt_rw.o libfdt/fdt_strerror.o
MONITOR		= monitor.S
BOOTLOADER	= boot.S
OBJS 		= boot.o c_start.o monitor.o semihosting.o string.o semi_loader.o $(LIBFDTOBJS)
KERNEL		= uImage

IMAGE		= linux-system.axf
SEMIIMG 	= linux-system-semi.axf
LD_SCRIPT	= model.lds.S


CC		= $(CROSS_COMPILE)gcc
LD		= $(CROSS_COMPILE)ld

# These are needed by the underlying kernel make
export CROSS_COMPILE ARCH

# Build all wrappers
all: $(IMAGE) $(SEMIIMG)

# Build just the semihosting wrapper
semi: $(SEMIIMG)

clean distclean:
	rm -f $(IMAGE) $(SEMIIMG) \
	model.lds modelsemi.lds $(OBJS) $(KERNEL)

$(KERNEL): $(KERNEL_SRC)/arch/arm/boot/uImage
	cp $< $@

$(IMAGE): $(OBJS) model.lds $(KERNEL) $(FILESYSTEM) Makefile
	$(LD) -o $@ $(OBJS) --script=model.lds

$(SEMIIMG): $(OBJS) modelsemi.lds
	$(LD) -o $@ $(OBJS) --script=modelsemi.lds

boot.o: $(BOOTLOADER)
	$(CC) $(CPPFLAGS) -DKCMD='$(KCMD)' -c -o $@ $<

monitor.o: $(MONITOR)
	$(CC) $(CPPFLAGS) -c -o $@ $<

%.o: %.c
	$(CC) $(CPPFLAGS) -O2 -ffreestanding -I. -Ilibfdt -c -o $@ $<

model.lds: $(LD_SCRIPT) Makefile
	$(CC) $(CPPFLAGS) -E -P -C -o $@ $<

modelsemi.lds: $(LD_SCRIPT) Makefile
	$(CC) $(CPPFLAGS) -DSEMIHOSTING=1 -E -P -C -o $@ $<

$(KERNEL_SRC)/arch/arm/boot/uImage: force
	$(MAKE) -C $(KERNEL_SRC) -j4 uImage

# Pass any target we don't know about through to the kernel makefile.
# This is a convenience rule so we can say 'make menuconfig' etc here.
# Note that any rules in this file must have a command or be marked as
# .PHONY.
%: force
	$(MAKE) -C $(KERNEL_SRC) $@

force: ;

Makefile: ;

.PHONY: all semi clean distclean config.mk config-default.mk