source: mainline/kernel/Makefile.build@ 6d7f9bfe

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6d7f9bfe was f6069801, checked in by Jakub Jermar <jakub@…>, 16 years ago

Add generic support for kernel stack traces.
One can print "synchronous" stack traces or stack traces
based on istate information (both kernel and uspace stacks).
Kernel stack traces resolve addresses to symbols, if symbols
are included in the kernel.

  • Property mode set to 100644
File size: 11.4 KB
Line 
1#
2# Copyright (c) 2005 Martin Decky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29
30## Include configuration
31#
32
33include Makefile.common
34include ../version
35include ../Makefile.config
36include ../config.defs
37
38LINK = arch/$(KARCH)/_link.ld
39EMPTY_MAP = generic/src/debug/empty_map.o
40SIZEOK_MAP = generic/src/debug/sizeok_map.o
41
42INCLUDES = generic/include
43OPTIMIZATION = 3
44
45ifndef CROSS_PREFIX
46 CROSS_PREFIX = /usr/local
47endif
48
49## Common compiler flags
50#
51
52DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
53
54GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
55 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
56 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
57 -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Werror \
58 -pipe
59
60ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
61 -ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
62 -Werror -wd170
63
64SUNCC_CFLAGS = -I$(INCLUDES) -xO$(OPTIMIZATION) \
65 -xnolib -xc99=all -features=extensions \
66 -erroff=E_ZERO_SIZED_STRUCT_UNION
67
68CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
69 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
70 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
71 -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -pipe \
72 -arch $(CLANG_ARCH)
73
74LFLAGS = -M
75AFLAGS =
76
77-include arch/$(KARCH)/Makefile.inc
78-include genarch/Makefile.inc
79
80## The at-sign
81#
82# The $(ATSIGN) variable holds the ASCII character representing the at-sign
83# ('@') used in various $(AS) constructs (e.g. @progbits). On architectures that
84# don't use '@' for starting a comment, $(ATSIGN) is merely '@'. However, on
85# those that do use it for starting a comment (e.g. arm32), $(ATSIGN) must be
86# defined as the percentile-sign ('%') in the architecture-dependent
87# Makefile.inc.
88#
89ATSIGN ?= @
90
91## Cross-platform assembly to start a symtab.data section
92#
93SYMTAB_SECTION = ".section symtab.data, \"a\", $(ATSIGN)progbits;"
94
95## Simple detection for the type of the host system
96#
97HOST = $(shell uname)
98
99## On Solaris, some utilities have slightly different names
100#
101ifeq ($(HOST),SunOS)
102 BINUTILS_PREFIX = "g"
103else
104 BINUTILS_PREFIX = ""
105endif
106
107## Toolchain configuration
108#
109
110ifeq ($(COMPILER),gcc_native)
111 CC = gcc
112 GCC = gcc
113 AS = $(BINUTILS_PREFIX)as
114 LD = $(BINUTILS_PREFIX)ld
115 OBJCOPY = $(BINUTILS_PREFIX)objcopy
116 OBJDUMP = $(BINUTILS_PREFIX)objdump
117 LIBDIR = /usr/lib
118 CFLAGS = $(GCC_CFLAGS)
119 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
120endif
121
122ifeq ($(COMPILER),gcc_cross)
123 CC = $(TOOLCHAIN_DIR)/bin/$(TARGET)-gcc
124 GCC = $(CC)
125 AS = $(TOOLCHAIN_DIR)/bin/$(TARGET)-as
126 LD = $(TOOLCHAIN_DIR)/bin/$(TARGET)-ld
127 OBJCOPY = $(TOOLCHAIN_DIR)/bin/$(TARGET)-objcopy
128 OBJDUMP = $(TOOLCHAIN_DIR)/bin/$(TARGET)-objdump
129 LIBDIR = $(TOOLCHAIN_DIR)/lib
130 CFLAGS = $(GCC_CFLAGS)
131 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
132endif
133
134ifeq ($(COMPILER),icc)
135 CC = icc
136 GCC = gcc
137 AS = as
138 LD = ld
139 OBJCOPY = objcopy
140 OBJDUMP = objdump
141 LIBDIR = /usr/lib
142 CFLAGS = $(ICC_CFLAGS)
143 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
144endif
145
146ifeq ($(COMPILER),suncc)
147 CC = suncc
148 GCC = gcc
149 AS = $(BINUTILS_PREFIX)as
150 LD = $(BINUTILS_PREFIX)ld
151 OBJCOPY = $(BINUTILS_PREFIX)objcopy
152 OBJDUMP = $(BINUTILS_PREFIX)objdump
153 LIBDIR = /usr/lib
154 CFLAGS = $(SUNCC_CFLAGS)
155 DEFS += $(CONFIG_DEFS)
156 DEPEND_DEFS = $(DEFS)
157endif
158
159ifeq ($(COMPILER),clang)
160 CC = clang
161 GCC = gcc
162 AS = $(BINUTILS_PREFIX)as
163 LD = $(BINUTILS_PREFIX)ld
164 OBJCOPY = $(BINUTILS_PREFIX)objcopy
165 OBJDUMP = $(BINUTILS_PREFIX)objdump
166 LIBDIR = /usr/lib
167 CFLAGS = $(CLANG_CFLAGS)
168 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
169endif
170
171
172## Generic kernel sources
173#
174
175GENERIC_SOURCES = \
176 generic/src/adt/avl.c \
177 generic/src/adt/bitmap.c \
178 generic/src/adt/btree.c \
179 generic/src/adt/hash_table.c \
180 generic/src/adt/list.c \
181 generic/src/console/chardev.c \
182 generic/src/console/console.c \
183 generic/src/cpu/cpu.c \
184 generic/src/ddi/ddi.c \
185 generic/src/ddi/irq.c \
186 generic/src/ddi/device.c \
187 generic/src/debug/symtab.c \
188 generic/src/debug/stacktrace.c \
189 generic/src/interrupt/interrupt.c \
190 generic/src/main/main.c \
191 generic/src/main/kinit.c \
192 generic/src/main/uinit.c \
193 generic/src/main/version.c \
194 generic/src/main/shutdown.c \
195 generic/src/proc/program.c \
196 generic/src/proc/scheduler.c \
197 generic/src/proc/thread.c \
198 generic/src/proc/task.c \
199 generic/src/proc/the.c \
200 generic/src/proc/tasklet.c \
201 generic/src/syscall/syscall.c \
202 generic/src/syscall/copy.c \
203 generic/src/mm/buddy.c \
204 generic/src/mm/frame.c \
205 generic/src/mm/page.c \
206 generic/src/mm/tlb.c \
207 generic/src/mm/as.c \
208 generic/src/mm/backend_anon.c \
209 generic/src/mm/backend_elf.c \
210 generic/src/mm/backend_phys.c \
211 generic/src/mm/slab.c \
212 generic/src/lib/func.c \
213 generic/src/lib/memstr.c \
214 generic/src/lib/sort.c \
215 generic/src/lib/string.c \
216 generic/src/lib/elf.c \
217 generic/src/lib/rd.c \
218 generic/src/printf/printf_core.c \
219 generic/src/printf/printf.c \
220 generic/src/printf/snprintf.c \
221 generic/src/printf/vprintf.c \
222 generic/src/printf/vsnprintf.c \
223 generic/src/time/clock.c \
224 generic/src/time/timeout.c \
225 generic/src/time/delay.c \
226 generic/src/preempt/preemption.c \
227 generic/src/synch/spinlock.c \
228 generic/src/synch/condvar.c \
229 generic/src/synch/rwlock.c \
230 generic/src/synch/mutex.c \
231 generic/src/synch/semaphore.c \
232 generic/src/synch/smc.c \
233 generic/src/synch/waitq.c \
234 generic/src/synch/futex.c \
235 generic/src/smp/ipi.c \
236 generic/src/smp/smp.c \
237 generic/src/ipc/ipc.c \
238 generic/src/ipc/sysipc.c \
239 generic/src/ipc/ipcrsc.c \
240 generic/src/ipc/irq.c \
241 generic/src/ipc/event.c \
242 generic/src/security/cap.c \
243 generic/src/sysinfo/sysinfo.c
244
245## Kernel console support
246#
247
248ifeq ($(CONFIG_KCONSOLE),y)
249GENERIC_SOURCES += \
250 generic/src/console/kconsole.c \
251 generic/src/console/cmd.c
252endif
253
254## Udebug interface sources
255#
256
257ifeq ($(CONFIG_UDEBUG),y)
258GENERIC_SOURCES += \
259 generic/src/ipc/kbox.c \
260 generic/src/udebug/udebug.c \
261 generic/src/udebug/udebug_ops.c \
262 generic/src/udebug/udebug_ipc.c
263endif
264
265## Test sources
266#
267
268ifeq ($(CONFIG_TEST),y)
269 CFLAGS += -Itest/
270 GENERIC_SOURCES += \
271 test/test.c \
272 test/atomic/atomic1.c \
273 test/btree/btree1.c \
274 test/avltree/avltree1.c \
275 test/fault/fault1.c \
276 test/mm/falloc1.c \
277 test/mm/falloc2.c \
278 test/mm/mapping1.c \
279 test/mm/slab1.c \
280 test/mm/slab2.c \
281 test/synch/rwlock1.c \
282 test/synch/rwlock2.c \
283 test/synch/rwlock3.c \
284 test/synch/rwlock4.c \
285 test/synch/rwlock5.c \
286 test/synch/semaphore1.c \
287 test/synch/semaphore2.c \
288 test/print/print1.c \
289 test/print/print2.c \
290 test/print/print3.c \
291 test/print/print4.c \
292 test/thread/thread1.c \
293 test/sysinfo/sysinfo1.c
294
295 ifeq ($(KARCH),mips32)
296 GENERIC_SOURCES += test/debug/mips1.c
297 else
298 GENERIC_SOURCES += test/debug/mips1_skip.c
299 endif
300
301 ifeq ($(KARCH),ia64)
302 GENERIC_SOURCES += test/mm/purge1.c
303 else
304 GENERIC_SOURCES += test/mm/purge1_skip.c
305 endif
306
307 ifeq ($(CONFIG_FPU),y)
308 ifeq ($(KARCH),ia32)
309 TEST_FPU1 = y
310 TEST_SSE1 = y
311 GENERIC_SOURCES += test/fpu/fpu1_x86.c
312 endif
313
314 ifeq ($(KARCH),amd64)
315 TEST_FPU1 = y
316 TEST_SSE1 = y
317 GENERIC_SOURCES += test/fpu/fpu1_x86.c
318 endif
319
320 ifeq ($(KARCH),ia64)
321 TEST_FPU1 = y
322 GENERIC_SOURCES += test/fpu/fpu1_ia64.c
323 endif
324
325 ifeq ($(KARCH),mips32)
326 TEST_MIPS2 = y
327 endif
328 endif
329
330 ifneq ($(TEST_FPU1),y)
331 GENERIC_SOURCES += test/fpu/fpu1_skip.c
332 endif
333
334 ifeq ($(TEST_SSE1),y)
335 GENERIC_SOURCES += test/fpu/sse1.c
336 else
337 GENERIC_SOURCES += test/fpu/sse1_skip.c
338 endif
339
340 ifeq ($(TEST_MIPS2),y)
341 GENERIC_SOURCES += test/fpu/mips2.c
342 else
343 GENERIC_SOURCES += test/fpu/mips2_skip.c
344 endif
345
346endif
347
348GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
349ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
350GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
351
352ifeq ($(CONFIG_SYMTAB),y)
353 SYMTAB_OBJECTS := generic/src/debug/real_map.o
354else
355 SYMTAB_OBJECTS :=
356endif
357
358.PHONY: all
359
360all: $(BIN) $(DISASM)
361
362-include $(DEPEND)
363
364$(BIN): $(RAW)
365 $(OBJCOPY) -O $(BFD) $< $@
366
367$(DISASM): $(RAW)
368 $(OBJDUMP) -d $< > $@
369
370$(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS)
371 $(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS) -o $@ -Map $(MAP)
372
373$(LINK): $(LINK).in $(DEPEND)
374 $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
375
376%.o: %.S $(DEPEND)
377 $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c $< -o $@
378
379%.o: %.s $(DEPEND)
380 $(AS) $(AFLAGS) $< -o $@
381
382#
383# The FPU tests are the only objects for which we allow the compiler to generate
384# FPU instructions.
385#
386test/fpu/%.o: test/fpu/%.c $(DEPEND)
387 $(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) -c $< -o $@
388ifeq ($(EXTRA_TOOL),stanse)
389 ../tools/jobfile.py $(JOB) $< $@ $(DEFS) $(CFLAGS) $(EXTRA_FLAGS)
390endif
391
392#
393# Ordinary objects.
394#
395%.o: %.c $(DEPEND)
396 $(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) -c $< -o $@
397ifeq ($(EXTRA_TOOL),stanse)
398 ../tools/jobfile.py $(JOB) $< $@ $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS)
399endif
400
401$(REAL_MAP).o: $(REAL_MAP).bin
402 echo $(SYMTAB_SECTION)" .incbin \"$<\"" | $(AS) $(AFLAGS) -o $@
403
404$(REAL_MAP).bin: $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
405 echo $(SYMTAB_SECTION) | $(AS) $(AFLAGS) -o $(EMPTY_MAP)
406 $(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP) -o $@ -Map $(MAP_PREV)
407 $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
408 tools/genmap.py $(MAP_PREV) $(DUMP) $@
409
410 # Do it once again, this time to get correct even the symbols
411 # on architectures that have bss after symtab
412
413 echo $(SYMTAB_SECTION)" .incbin \"$@\"" | $(AS) $(AFLAGS) -o $(SIZEOK_MAP)
414 $(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP) -o $@ -Map $(MAP_PREV)
415 $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
416 tools/genmap.py $(MAP_PREV) $(DUMP) $@
417
418$(DEPEND): $(ARCH_INCLUDE) $(GENARCH_INCLUDE)
419 makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > $@ 2> /dev/null
420 -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
421
422$(ARCH_INCLUDE): arch/$(KARCH)/include/
423 ln -sfn ../../$< $@
424
425$(GENARCH_INCLUDE): genarch/include/
426 ln -sfn ../../$< $@
Note: See TracBrowser for help on using the repository browser.