1#
2# cris/Makefile
3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies. Remember to do have actions
6# for "archclean" and "archdep" for cleaning up and making dependencies for
7# this architecture
8#
9# This file is subject to the terms and conditions of the GNU General Public
10# License.  See the file "COPYING" in the main directory of this archive
11# for more details.
12
13LD_SCRIPT=$(TOPDIR)/arch/cris/cris.ld
14
15# A bug in ld prevents us from having a (constant-value) symbol in a
16# "ORIGIN =" or "LENGTH =" expression.  We fix that by generating a
17# linker file with the symbolic part of those expressions evaluated.
18#  Unfortunately, there is trouble making vmlinux depend on anything we
19# generate here, so we *always* regenerate the final linker script and
20# replace the LD macro to get what we want.  Thankfully(?) vmlinux is
21# always rebuilt (due to calling make recursively and not knowing if
22# anything was rebuilt).
23#  The shell script to build in some kind of dependency is really not
24# necessary for reasons of speed.  It's there because always
25# regenerating stuff (even for incremental linking of subsystems!) is
26# even more nauseating.
27LD = if [ ! -e $(LD_SCRIPT).tmp -o $(LD_SCRIPT) -nt $(LD_SCRIPT).tmp ]; then \
28          sed -e s/@CONFIG_ETRAX_DRAM_VIRTUAL_BASE@/0x$(CONFIG_ETRAX_DRAM_VIRTUAL_BASE)/ \
29              -e s/@CONFIG_ETRAX_DRAM_SIZE_M@/$(CONFIG_ETRAX_DRAM_SIZE)/ \
30              < $(LD_SCRIPT) > $(LD_SCRIPT).tmp; \
31     else true; \
32     fi && $(CROSS_COMPILE)ld -mcrislinux
33
34LINKFLAGS = -T $(LD_SCRIPT).tmp
35
36# objcopy is used to make binary images from the resulting linked file
37
38OBJCOPY := $(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S
39
40# -mlinux enables -march=v10, -fno-underscores, -D__linux__ among others
41
42CFLAGS := $(CFLAGS) -mlinux -pipe
43
44ifdef CONFIG_ETRAX_KGDB
45CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS)) -g
46CFLAGS += -fno-omit-frame-pointer
47endif
48
49AFLAGS += -mlinux
50
51HEAD := arch/cris/kernel/head.o
52
53SUBDIRS += arch/cris/kernel arch/cris/mm arch/cris/lib arch/cris/drivers
54ifdef CONFIG_ETRAX_AXISFLASHMAP
55# only build this if axis flash map is used, because they depend on
56# each others config options
57SUBDIRS += arch/cris/boot/rescue
58endif
59
60# Note that the order of .o files below is important is some cases
61# (because initcalls are executed in the order they are linked)
62# Never add any driver before mm.o!
63CORE_FILES += arch/cris/kernel/kernel.o arch/cris/mm/mm.o
64DRIVERS += arch/cris/drivers/drivers.o
65LIBGCC = $(shell $(CC) $(CFLAGS) -print-file-name=libgcc.a)
66LIBS := $(TOPDIR)/arch/cris/lib/lib.a $(LIBS) $(TOPDIR)/arch/cris/lib/lib.a $(LIBGCC)
67
68arch/cris/kernel: dummy
69	$(MAKE) linuxsubdirs SUBDIRS=arch/cris/kernel
70
71arch/cris/mm: dummy
72	$(MAKE) linuxsubdirs SUBDIRS=arch/cris/mm
73
74MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
75
76vmlinux.bin: vmlinux
77	$(OBJCOPY) vmlinux vmlinux.bin
78
79timage: vmlinux.bin
80	cat vmlinux.bin cramfs.img >timage
81
82simimage: timage
83	cp vmlinux.bin simvmlinux.bin
84
85# the following will remake timage without compiling the kernel
86# it does of course require that all object files exist...
87
88cramfs:
89## cramfs      - Creates a cramfs image
90	mkcramfs -b 8192 -m romfs_meta.txt root cramfs.img
91	cat vmlinux.bin cramfs.img >timage
92
93clinux: vmlinux.bin decompress.bin rescue.bin
94
95decompress.bin: dummy
96	@make -C arch/cris/boot/compressed decompress.bin
97
98rescue.bin: dummy
99	@make -C arch/cris/boot/rescue rescue.bin
100
101zImage: vmlinux.bin
102## zImage     - Compressed kernel (gzip)
103	@$(MAKEBOOT) zImage
104
105compressed: zImage
106
107archclean:
108	@$(MAKEBOOT) clean
109	rm -f timage vmlinux.bin cramfs.img
110	rm -rf $(LD_SCRIPT).tmp
111
112archmrproper:
113
114archdep:
115	@$(MAKEBOOT) dep
116