Root/Makefile.am

1# Iris: micro-kernel for a capability-based operating system.
2# Makefile.am: build rules
3# Copyright 2009-2012 Bas Wijnen <wijnen@debian.org>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18AUTOMAKE_OPTIONS = subdir-objects foreign
19
20# Define some variables.
21OBJDUMP = $(host_alias)-objdump
22OBJCOPY = $(host_alias)-objcopy
23SERIAL ?= /dev/ttyUSB0
24junk = mdebug.abi32 gnu.attributes ctors eh_frame eh_frame_hdr MIPS.abiflags reginfo comment pdr note.gnu.build-id
25objcopyflags = -S $(addprefix --remove-section=.,$(junk))
26
27start_load = 0x80100000
28
29noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/board/stage1.raw
30noinst_PROGRAMS = iris.elf mips/start.elf mips/board/stage1.elf
31
32%.raw: %.elf
33    $(OBJCOPY) $(objcopyflags) -Obinary $< $@
34
35# Define boot_threads depending on selected mode.
36if UDC
37boot_threads = hardware/udc
38else
39if UNBRICK
40boot_threads = hardware/sdmmc glue/usbmassstorage
41else
42boot_threads = hardware/sdmmc glue/partition glue/fat
43noinst_DATA += iris.tar.gz
44endif
45endif
46
47# Threadlist must be the last file on the line below.
48iris_sources = kernel/panic.cc kernel/data.cc kernel/alloc.cc kernel/memory.cc kernel/invoke.cc kernel/schedule.cc mips/interrupts.cc mips/arch.cc userspace/boot/threadlist.S
49boot_sources = mips/init.cc mips/board/board.cc
50headers = include/kernel.hh include/iris.hh include/devices.hh include/keys.hh mips/arch.hh mips/board/jz4740.hh mips/board/board.hh mips/nand.hh
51iris_elf_DEPENDENCIES = mips/board/iris.ld
52iris_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 -DNANONOTE -DUSE_SERIAL
53iris_elf_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 -fno-exceptions -fno-common
54iris_elf_LDFLAGS = -Wl,--omagic -nostdlib -T mips/board/iris.ld
55iris_elf_SOURCES = mips/entry.S ${iris_sources} mips/boot.S ${boot_sources} ${headers}
56
57mips_start_elf_CPPFLAGS = -fno-inline -mips32 -DSTART="0x$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b1-8')" -DADDR0="0x$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep addr000$$ | cut -b1-8')"
58mips_start_elf_LDFLAGS = -Wl,--omagic -Wl,-Ttext -Wl,$(start_load) -nostdlib
59mips_start_elf_SOURCES = mips/start-hack.S iris.raw
60
61mips/start-hack.S: mips/start.S iris.raw
62    cp $< $@
63
64mips_board_stage1_elf_DEPENDENCIES = mips/board/stage1.ld
65mips_board_stage1_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32
66mips_board_stage1_elf_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 -fno-exceptions -fno-common
67mips_board_stage1_elf_LDFLAGS = -Wl,--omagic -Wl,-T -Wl,mips/board/stage1.ld -nostdlib
68mips_board_stage1_elf_SOURCES = mips/board/stage1.cc
69
70program_targets = \
71    userspace/bootinit.elf \
72    userspace/init.elf \
73    userspace/boot.elf \
74    userspace/gpio.elf \
75    userspace/lcd.elf \
76    userspace/nand.elf \
77    userspace/rtc.elf \
78    userspace/sdmmc.elf \
79    userspace/udc.elf \
80    userspace/elfrun.elf \
81    userspace/fat.elf \
82    userspace/font.elf \
83    userspace/gui.elf \
84    userspace/partition.elf \
85    userspace/usbmassstorage.elf \
86    userspace/alarm.elf \
87    userspace/ball.elf \
88    userspace/booter.elf \
89    userspace/bsquare.elf \
90    userspace/buzzer.elf \
91    userspace/metronome.elf \
92    userspace/test.elf
93
94fs_targets = \
95    fs/alarm.elf \
96    fs/ball.elf \
97    fs/boot.elf \
98    fs/booter.elf \
99    fs/bootinit.elf \
100    fs/bsquare.elf \
101    fs/buzzer.elf \
102    fs/elfrun.elf \
103    fs/fat.elf \
104    fs/font.elf \
105    fs/gpio.elf \
106    fs/gui.elf \
107    fs/init.elf \
108    fs/lcd.elf \
109    fs/metronome.elf \
110    fs/nand.elf \
111    fs/partition.elf \
112    fs/rtc.elf \
113    fs/sdmmc.elf \
114    fs/test.elf \
115    fs/udc.elf \
116    fs/usbmassstorage.elf
117
118noinst_PROGRAMS += $(program_targets)
119noinst_DATA += $(fs_targets)
120AM_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 -DNANONOTE
121AM_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
122AM_LDFLAGS = -nostdlib
123
124BUILT_SOURCES = $(headers) userspace/data/charset.data server
125
126userspace/boot/threadlist.S: userspace/boot/mkthreadlist Makefile $(addprefix fs/,$(addsuffix .elf,bootinit $(notdir $(boot_threads))))
127    $< bootinit $(boot_threads) > $@
128
129PYPP = /usr/bin/pypp
130%.cc: %.ccp
131    $(PYPP) --name $< < $< > $@
132%.hh: %.hhp
133    $(PYPP) --name $< < $< > $@
134
135userspace/data/charset.data: userspace/data/charset
136    $< > $@
137fs/font.dat: userspace/data/courier-10+8+32.png userspace/data/makefont
138    userspace/data/makefont $< > $@
139fs/init.config: userspace/data/init.config
140    ln -s ../$< $@
141
142fs/%.elf: userspace/%.elf
143    mkdir -p fs
144    $(OBJCOPY) -S $< $@
145
146userspace_bootinit_elf_SOURCES = userspace/boot/crt0.cc userspace/boot/bootinit.cc ${headers}
147userspace_init_elf_SOURCES = userspace/boot/crt0.cc userspace/boot/init.cc ${headers}
148
149userspace_boot_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/boot.cc ${headers}
150userspace_buzzer_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/buzzer.cc ${headers}
151userspace_gpio_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/gpio.cc ${headers}
152userspace_lcd_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/lcd.cc ${headers}
153userspace_nand_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/nand.cc ${headers}
154userspace_rtc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/rtc.cc ${headers}
155userspace_sdmmc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/sdmmc.cc ${headers}
156userspace_udc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/udc.cc ${headers}
157
158#userspace_buffer_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/buffer.cc ${headers}
159userspace_elfrun_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/elfrun.cc ${headers}
160userspace_fat_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/fat.cc ${headers}
161userspace_font_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/font.cc ${headers}
162userspace_gui_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/gui.cc ${headers}
163userspace_partition_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/partition.cc ${headers}
164userspace_usbmassstorage_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/usbmassstorage.cc ${headers}
165
166userspace_metronome_elf_SOURCES = userspace/boot/crt0.cc userspace/application/metronome.cc ${headers}
167userspace_test_elf_SOURCES = userspace/boot/crt0.cc userspace/application/test.cc ${headers}
168userspace_alarm_elf_SOURCES = userspace/boot/crt0.cc userspace/application/alarm.cc ${headers}
169userspace_ball_elf_SOURCES = userspace/boot/crt0.cc userspace/application/ball.cc ${headers}
170userspace_booter_elf_SOURCES = userspace/boot/crt0.cc userspace/application/booter.cc ${headers}
171userspace_bsquare_elf_SOURCES = userspace/boot/crt0.cc userspace/application/bsquare.cc ${headers}
172
173server:
174    test -e native/Makefile || native/autogen.sh
175    $(MAKE) -C native
176
177# This target is meaningless for SD boot mode.
178test: mips/start.raw mips/start.elf server mips/board/stage1.raw fs/init.config fs/font.dat
179    echo shutdown | nc localhost 5050 || true
180    native/usb-server
181    echo 'reboot $(start_load) 0x$(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') mips/start.raw' | nc localhost 5050
182
183# SD boot stuff
184iris.tar.gz: mips/start.raw.gz mips/start.elf $(fs_targets) fs/init.config fs/font.dat
185    test -d fs/boot || mkdir fs/boot
186    mkimage -A mips -T kernel -a $(start_load) -e $(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') -n Iris -d mips/start.raw.gz fs/boot/uImage | sed -e 's/:/;/g'
187    cd fs && tar czvf ../$@ --dereference *
188%.gz: %
189    gzip < $< > $@
190
191sources = \
192    userspace/boot/bootinit.cc \
193    userspace/boot/init.cc \
194    userspace/hardware/boot.cc \
195    userspace/hardware/buzzer.cc \
196    userspace/hardware/gpio.cc \
197    userspace/hardware/lcd.cc \
198    userspace/hardware/nand.cc \
199    userspace/hardware/rtc.cc \
200    userspace/hardware/sdmmc.cc \
201    userspace/hardware/udc.cc \
202    userspace/glue/elfrun.cc \
203    userspace/glue/fat.cc \
204    userspace/glue/font.cc \
205    userspace/glue/gui.cc \
206    userspace/glue/partition.cc \
207    userspace/glue/usbmassstorage.cc \
208    userspace/application/alarm.cc \
209    userspace/application/ball.cc \
210    userspace/application/booter.cc \
211    userspace/application/bsquare.cc \
212    userspace/application/metronome.cc \
213    userspace/application/test.cc
214
215debug:
216    stty -F $(SERIAL) 57600 raw
217    cat $(SERIAL)
218
219autoclean: maintainer-clean
220    test ! -f native/Makefile || $(MAKE) -C native autoclean
221    rm -rf aclocal.m4 configure compile depcomp fs install-sh iris.raw iris-sd.tar Makefile.in missing $(iris_sources) $(boot_sources) $(sources) $(headers) mips/start-hack.S mips/start.raw mips/start.raw.gz userspace/data/charset.data iris.tar.gz mips/board/stage1.cc mips/board/stage1.elf mips/board/stage1.raw mips/board/stage1.elf userspace/boot/crt0.cc
222

Archive Download this file

Branches:
master



interactive