~jan.vesely/helenos/usb

1 by Martin Decky
Initial import
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
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
29
## Configuration
30
#
31
32
ROOT_PATH = ..
33
34
VERSION_DEF = $(ROOT_PATH)/version
35
36
COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
37
COMMON_HEADER = $(ROOT_PATH)/common.h
1443.1.36 by Vojtech Horky
Prevent compile-time symlinks in kernel
38
COMMON_HEADER_ARCH = arch/$(KARCH)/include/arch/common.h
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
39
40
CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
41
CONFIG_HEADER = $(ROOT_PATH)/config.h
42
43
-include $(VERSION_DEF)
44
-include $(COMMON_MAKEFILE)
45
-include $(CONFIG_MAKEFILE)
46
47
## Common names
48
#
49
50
DEPEND = Makefile.depend
51
DEPEND_PREV = $(DEPEND).prev
52
RAW = kernel.raw
53
BIN = kernel.bin
54
MAP = kernel.map
55
JOB = kernel.job
56
MAP_PREV = $(MAP).prev
57
DISASM = kernel.disasm
58
DUMP = kernel.dump
59
REAL_MAP = generic/src/debug/real_map
60
61
GENMAP = tools/genmap.py
62
JOBFILE = $(ROOT_PATH)/tools/jobfile.py
63
64
LINK = arch/$(KARCH)/_link.ld
65
EMPTY_MAP = generic/src/debug/empty_map.o
66
SIZEOK_MAP = generic/src/debug/sizeok_map.o
67
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
68
.PHONY: all clean autogen_clean
117 by Martin Decky
proper support for parallel building (this time really tested)
69
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
70
all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BIN) $(DISASM)
71
	-[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
1 by Martin Decky
Initial import
72
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
73
clean: autogen_clean
1443.1.38 by Vojtech Horky
Prevent compile-time symlinks for ABI
74
	rm -f $(DEPEND) $(DEPEND_PREV) $(RAW) $(BIN) $(MAP) $(JOB) $(MAP_PREV) $(DISASM) $(DUMP) $(REAL_MAP).* arch/*/_link.ld arch/*/include/arch/common.h
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
75
	find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.o' -follow -exec rm '{}' \;
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
76
77
## Common compiler flags
78
#
79
1443.1.38 by Vojtech Horky
Prevent compile-time symlinks for ABI
80
INCLUDES = generic/include genarch/include arch/$(KARCH)/include ../abi/include
1443.1.36 by Vojtech Horky
Prevent compile-time symlinks in kernel
81
INCLUDES_FLAGS = $(addprefix -I,$(INCLUDES))
439 by Jakub Jermar
Prepare to support size-optimized builds and stripped binaries.
82
83
ifeq ($(CONFIG_OPTIMIZE_FOR_SIZE),y)
497 by Martin Decky
add indentation
84
	OPTIMIZATION = s
439 by Jakub Jermar
Prepare to support size-optimized builds and stripped binaries.
85
else
512 by Jiri Svoboda
Revert accidental change of optimization level from changeset:head,510.
86
	OPTIMIZATION = 3
439 by Jakub Jermar
Prepare to support size-optimized builds and stripped binaries.
87
endif
326 by Martin Decky
simplify makefiles slightly
88
1446 by Jiri Svoboda
Consolidate and update copyright banners.
89
DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
90
1443.1.36 by Vojtech Horky
Prevent compile-time symlinks in kernel
91
GCC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
92
	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
93
	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
941 by Martin Decky
use C99 with GNU extensions as the language standard when building by GCC
94
	-std=gnu99 -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
95
	-Werror-implicit-function-declaration -Wwrite-strings \
496 by Martin Decky
use -Werror only in debug builds
96
	-pipe
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
97
1443.1.36 by Vojtech Horky
Prevent compile-time symlinks in kernel
98
ICC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
99
	-ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
496 by Martin Decky
use -Werror only in debug builds
100
	-Werror-implicit-function-declaration -wd170
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
101
1443.1.44 by Vojtech Horky
amd64 compiles with clang again
102
# clang does not support following options but I am not sure whether
103
# something won't break because of that:
104
# -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) -finput-charset=UTF-8
1443.1.36 by Vojtech Horky
Prevent compile-time symlinks in kernel
105
CLANG_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
1443.1.44 by Vojtech Horky
amd64 compiles with clang again
106
	-ffreestanding -fno-builtin -nostdlib -nostdinc \
1736.30.257 by Martin Decky
revive clang support
107
	-std=gnu99 -Wall -Werror -Wextra -Wno-unused-parameter -Wmissing-prototypes \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
108
	-Werror-implicit-function-declaration -Wwrite-strings \
1736.30.257 by Martin Decky
revive clang support
109
	-integrated-as -pipe -target $(CLANG_TARGET)
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
110
496 by Martin Decky
use -Werror only in debug builds
111
ifeq ($(CONFIG_DEBUG),y)
112
	GCC_CFLAGS += -Werror
113
	ICC_CFLAGS += -Werror
114
endif
115
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
116
ifeq ($(CONFIG_LTO),y)
117
	GCC_CFLAGS += -flto
118
endif
119
617 by Martin Decky
add initial support for line debugging information and generating disassembly outputs with source code intermixed (useful for analyzing of stack traces)
120
ifeq ($(CONFIG_LINE_DEBUG),y)
121
	GCC_CFLAGS += -g
122
	ICC_CFLAGS += -g
123
	CLANG_CFLAGS += -g
124
endif
125
527 by Jakub Jermar
Fix ordering of [AL]FLAGS initialization and arch Makefile.inc inclusion.
126
#
127
# Mind the mutual ordering with the inclusion of the arch Makefile.inc.
128
# AFLAGS and LFLAGS must be initialized before the inclusion.
129
#
130
AFLAGS =
934 by Jiri Svoboda
Link with -n (nmagic) instead of -N (omagic). omagic makes text sections
131
LFLAGS = -n -T $(LINK) -M
527 by Jakub Jermar
Fix ordering of [AL]FLAGS initialization and arch Makefile.inc inclusion.
132
133
#
134
# Mind the mutual ordering with the initialization of AFLAGS and LFLAGS.
135
# The arch Makefile.inc must be included after the initialization.
136
#
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
137
-include arch/$(KARCH)/Makefile.inc
138
-include genarch/Makefile.inc
139
-include $(DEPEND)
140
141
## The at-sign
142
#
143
# The $(ATSIGN) variable holds the ASCII character representing the at-sign
144
# ('@') used in various $(AS) constructs (e.g. @progbits). On architectures that
145
# don't use '@' for starting a comment, $(ATSIGN) is merely '@'. However, on
146
# those that do use it for starting a comment (e.g. arm32), $(ATSIGN) must be
147
# defined as the percentile-sign ('%') in the architecture-dependent
148
# Makefile.inc.
149
#
150
151
ATSIGN ?= @
152
153
## Cross-platform assembly to start a symtab.data section
154
#
155
156
SYMTAB_SECTION = ".section symtab.data, \"a\", $(ATSIGN)progbits;"
157
158
## Compilation options
159
#
160
161
ifeq ($(COMPILER),gcc_native)
162
	CFLAGS = $(GCC_CFLAGS)
163
	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
164
	INSTRUMENTATION = -finstrument-functions
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
165
endif
166
167
ifeq ($(COMPILER),gcc_cross)
168
	CFLAGS = $(GCC_CFLAGS)
169
	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
170
	INSTRUMENTATION = -finstrument-functions
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
171
endif
172
1736.7.25 by Vojtech Horky
Add support for *-helenos-* toolchain
173
ifeq ($(COMPILER),gcc_helenos)
174
	CFLAGS = $(GCC_CFLAGS)
175
	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
176
	INSTRUMENTATION = -finstrument-functions
177
endif
178
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
179
ifeq ($(COMPILER),icc)
180
	CFLAGS = $(ICC_CFLAGS)
181
	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
182
	INSTRUMENTATION =
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
183
endif
184
185
ifeq ($(COMPILER),clang)
186
	CFLAGS = $(CLANG_CFLAGS)
187
	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
188
	INSTRUMENTATION =
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
189
endif
190
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
191
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
192
## Generic kernel sources
193
#
194
195
GENERIC_SOURCES = \
196
	generic/src/adt/avl.c \
197
	generic/src/adt/bitmap.c \
198
	generic/src/adt/btree.c \
1527.2.45 by Adam Hraska
cht: Added initial working concurrent hash table. Builds and runs.
199
	generic/src/adt/cht.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
200
	generic/src/adt/hash_table.c \
201
	generic/src/adt/list.c \
202
	generic/src/console/chardev.c \
203
	generic/src/console/console.c \
1443.1.24 by Vojtech Horky
Create function for displaying --more-- prompt
204
	generic/src/console/prompt.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
205
	generic/src/cpu/cpu.c \
1527.2.17 by Adam Hraska
cpu_mask: Added to Makefile.
206
	generic/src/cpu/cpu_mask.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
207
	generic/src/ddi/ddi.c \
208
	generic/src/ddi/irq.c \
209
	generic/src/ddi/device.c \
210
	generic/src/debug/symtab.c \
211
	generic/src/debug/stacktrace.c \
551.1.3 by Jakub Jermar
Foundations for the unified panic architecture.
212
	generic/src/debug/panic.c \
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
213
	generic/src/debug/debug.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
214
	generic/src/interrupt/interrupt.c \
1736.31.2 by Martin Sucha
Cherrypick kernel logging facility
215
	generic/src/log/log.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
216
	generic/src/main/main.c \
217
	generic/src/main/kinit.c \
218
	generic/src/main/uinit.c \
219
	generic/src/main/version.c \
220
	generic/src/main/shutdown.c \
221
	generic/src/proc/program.c \
222
	generic/src/proc/scheduler.c \
223
	generic/src/proc/thread.c \
224
	generic/src/proc/task.c \
225
	generic/src/proc/the.c \
226
	generic/src/syscall/syscall.c \
227
	generic/src/syscall/copy.c \
825.1.40 by Jakub Jermar
Add calls to set up kernel virtual memory (both identity and non-identity)
228
	generic/src/mm/km.c \
825.1.7 by Jakub Jermar
Add the memory reservation API.
229
	generic/src/mm/reserve.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
230
	generic/src/mm/frame.c \
231
	generic/src/mm/page.c \
232
	generic/src/mm/tlb.c \
233
	generic/src/mm/as.c \
234
	generic/src/mm/backend_anon.c \
235
	generic/src/mm/backend_elf.c \
236
	generic/src/mm/backend_phys.c \
237
	generic/src/mm/slab.c \
238
	generic/src/lib/func.c \
239
	generic/src/lib/memstr.c \
1736.1.52 by Jakub Jermar
Revert to the state of mainline,1783.
240
	generic/src/lib/memfnc.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
241
	generic/src/lib/sort.c \
314.1.3 by Jiri Svoboda
Rename string.h to str.h to avoid header conflict with standard C string.h.
242
	generic/src/lib/str.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
243
	generic/src/lib/elf.c \
825.1.77 by Jakub Jermar
WIP: Add first bits of a generic resource allocator.
244
	generic/src/lib/ra.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
245
	generic/src/lib/rd.c \
246
	generic/src/printf/printf_core.c \
247
	generic/src/printf/printf.c \
248
	generic/src/printf/snprintf.c \
249
	generic/src/printf/vprintf.c \
250
	generic/src/printf/vsnprintf.c \
251
	generic/src/time/clock.c \
252
	generic/src/time/timeout.c \
253
	generic/src/time/delay.c \
254
	generic/src/preempt/preemption.c \
255
	generic/src/synch/spinlock.c \
256
	generic/src/synch/condvar.c \
257
	generic/src/synch/mutex.c \
258
	generic/src/synch/semaphore.c \
259
	generic/src/synch/smc.c \
1527.2.99 by Adam Hraska
Added syscall smp_memory_barrier.
260
	generic/src/synch/smp_memory_barrier.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
261
	generic/src/synch/waitq.c \
262
	generic/src/synch/futex.c \
1527.2.11 by Adam Hraska
workq: Add work queues: allow blocking work items, queuing items from interrupt handlers.
263
	generic/src/synch/workqueue.c \
1527.2.1 by Adam Hraska
rcu: initial files with dummy functions.
264
	generic/src/synch/rcu.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
265
	generic/src/smp/ipi.c \
266
	generic/src/smp/smp.c \
1527.2.4 by Adam Hraska
smp_call: initial unicast version for ia32, amd64.
267
	generic/src/smp/smp_call.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
268
	generic/src/ipc/ipc.c \
269
	generic/src/ipc/sysipc.c \
1596.1.16 by Jakub Jermar
Basic infrastructure for system IPC ops.
270
	generic/src/ipc/sysipc_ops.c \
271
	generic/src/ipc/ops/clnestab.c \
272
	generic/src/ipc/ops/conctmeto.c \
273
	generic/src/ipc/ops/concttome.c \
274
	generic/src/ipc/ops/connclone.c \
275
	generic/src/ipc/ops/dataread.c \
276
	generic/src/ipc/ops/datawrite.c \
277
	generic/src/ipc/ops/debug.c \
278
	generic/src/ipc/ops/sharein.c \
279
	generic/src/ipc/ops/shareout.c \
280
	generic/src/ipc/ops/stchngath.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
281
	generic/src/ipc/ipcrsc.c \
282
	generic/src/ipc/irq.c \
283
	generic/src/ipc/event.c \
284
	generic/src/security/cap.c \
329.1.1 by Stanislav Kozina
ps
285
	generic/src/sysinfo/sysinfo.c \
382 by Martin Decky
sysinfo API cleanup
286
	generic/src/sysinfo/stats.c
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
287
288
## Kernel console support
289
#
290
291
ifeq ($(CONFIG_KCONSOLE),y)
292
GENERIC_SOURCES += \
293
	generic/src/console/kconsole.c \
294
	generic/src/console/cmd.c
295
endif
296
297
## Udebug interface sources
298
#
299
300
ifeq ($(CONFIG_UDEBUG),y)
301
GENERIC_SOURCES += \
302
	generic/src/ipc/kbox.c \
303
	generic/src/udebug/udebug.c \
304
	generic/src/udebug/udebug_ops.c \
305
	generic/src/udebug/udebug_ipc.c
306
endif
307
308
## Test sources
309
#
310
311
ifeq ($(CONFIG_TEST),y)
312
	CFLAGS += -Itest/
313
	GENERIC_SOURCES += \
314
		test/test.c \
315
		test/atomic/atomic1.c \
316
		test/btree/btree1.c \
1527.2.46 by Adam Hraska
cht: Added CHT stress test.
317
		test/cht/cht1.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
318
		test/avltree/avltree1.c \
319
		test/fault/fault1.c \
320
		test/mm/falloc1.c \
321
		test/mm/falloc2.c \
322
		test/mm/mapping1.c \
323
		test/mm/slab1.c \
324
		test/mm/slab2.c \
325
		test/synch/semaphore1.c \
326
		test/synch/semaphore2.c \
1527.2.11 by Adam Hraska
workq: Add work queues: allow blocking work items, queuing items from interrupt handlers.
327
		test/synch/workqueue2.c \
328
		test/synch/workqueue3.c \
1527.2.20 by Adam Hraska
workq: Moved almost all tests to a single test entry function.
329
		test/synch/rcu1.c \
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
330
		test/print/print1.c \
331
		test/print/print2.c \
332
		test/print/print3.c \
333
		test/print/print4.c \
726.1.4 by Martin Decky
add print5 test
334
		test/print/print5.c \
1527.2.5 by Adam Hraska
smp_call: Moved content of arch header to generic header.
335
		test/thread/thread1.c \
336
		test/smpcall/smpcall1.c
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
337
	
338
	ifeq ($(KARCH),mips32)
339
		GENERIC_SOURCES += test/debug/mips1.c
340
	else
341
		GENERIC_SOURCES += test/debug/mips1_skip.c
342
	endif
343
	
344
	ifeq ($(KARCH),ia64)
345
		GENERIC_SOURCES += test/mm/purge1.c
346
	else
347
		GENERIC_SOURCES += test/mm/purge1_skip.c
348
	endif
349
	
350
endif
351
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
352
## Sources where instrumentation is enabled
353
#
354
594 by Martin Decky
add early_putchar() which can be used to do early kernel console output for debugging purposes
355
ifeq ($(CONFIG_TRACE),y)
597 by Martin Decky
improve kernel function tracing
356
	INSTRUMENTED_SOURCES = \
357
		generic/src/adt/btree.c \
358
		generic/src/cpu/cpu.c \
359
		generic/src/ddi/ddi.c \
360
		generic/src/interrupt/interrupt.c \
361
		generic/src/main/main.c \
362
		generic/src/main/kinit.c \
363
		generic/src/proc/the.c \
364
		generic/src/mm/frame.c \
365
		generic/src/mm/page.c \
366
		generic/src/mm/tlb.c \
367
		generic/src/mm/as.c \
368
		generic/src/mm/slab.c \
369
		generic/src/sysinfo/sysinfo.c \
370
		generic/src/console/kconsole.c
371
else
372
	INSTRUMENTED_SOURCES =
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
373
endif
374
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
375
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
376
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
377
GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
378
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
379
ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG)))
380
ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG)))
381
ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG)))
382
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
383
LFLAGS_LTO := $(addprefix -Xlinker ,$(LFLAGS))
384
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
385
ifeq ($(CONFIG_SYMTAB),y)
386
	SYMTAB_OBJECTS := generic/src/debug/real_map.o
387
else
388
	SYMTAB_OBJECTS :=
389
endif
390
391
$(BIN): $(RAW)
392
	$(OBJCOPY) -O $(BFD) $< $@
393
394
$(DISASM): $(RAW)
617 by Martin Decky
add initial support for line debugging information and generating disassembly outputs with source code intermixed (useful for analyzing of stack traces)
395
ifeq ($(CONFIG_LINE_DEBUG),y)
396
	$(OBJDUMP) -d -S $< > $@
397
else
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
398
	$(OBJDUMP) -d $< > $@
617 by Martin Decky
add initial support for line debugging information and generating disassembly outputs with source code intermixed (useful for analyzing of stack traces)
399
endif
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
400
401
$(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS)
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
402
ifeq ($(CONFIG_LTO),y)
403
	$(GCC) $(LFLAGS_LTO) -Xlinker -Map -Xlinker $(MAP) $(DEFS) $(GCC_CFLAGS) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS)
404
else
405
	$(LD) $(LFLAGS) -Map $(MAP) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS)
406
endif
439 by Jakub Jermar
Prepare to support size-optimized builds and stripped binaries.
407
ifeq ($(CONFIG_STRIP_BINARIES),y)
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
408
	$(STRIP) $(RAW)
439 by Jakub Jermar
Prepare to support size-optimized builds and stripped binaries.
409
endif
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
410
411
$(LINK): $(LINK).in $(DEPEND)
1443.1.44 by Vojtech Horky
amd64 compiles with clang again
412
	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
413
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
414
%.h: %.ag
415
	$(AUTOGEN) probe $< >$<.probe.c
1736.30.171 by Jakub Jermar
Do not be GCC-centric when autogenerating kernel headers.
416
	$(CC) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
417
	$(AUTOGEN) generate $< <$<.probe.s >$@   
418
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
419
%.o: %.S $(DEPEND)
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
420
	$(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c -o $@ $<
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
421
ifeq ($(PRECHECK),y)
422
	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(GCC_CFLAGS) -D__ASM__
423
endif
424
425
%.o: %.s $(DEPEND)
326 by Martin Decky
simplify makefiles slightly
426
	$(AS) $(AFLAGS) -o $@ $<
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
427
ifeq ($(PRECHECK),y)
428
	$(JOBFILE) $(JOB) $< $@ as asm $(DEFS) $(CFLAGS) $(EXTRA_FLAGS)
429
endif
430
431
%.o: %.c $(DEPEND)
573 by Martin Decky
remove LOG_EXEC() macro, use compile-time instrumentation for detailed kernel logging
432
	$(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) $(if $(findstring $<,$(INSTRUMENTED_SOURCES)),$(INSTRUMENTATION)) -c -o $@ $<
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
433
ifeq ($(PRECHECK),y)
434
	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS)
435
endif
436
437
$(REAL_MAP).o: $(REAL_MAP).bin
438
	echo $(SYMTAB_SECTION)" .incbin \"$<\"" | $(AS) $(AFLAGS) -o $@
439
440
$(REAL_MAP).bin: $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
441
	echo $(SYMTAB_SECTION) | $(AS) $(AFLAGS) -o $(EMPTY_MAP)
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
442
ifeq ($(CONFIG_LTO),y)
443
	$(GCC) $(LFLAGS_LTO) -Xlinker -Map -Xlinker $(MAP_PREV) $(DEFS) $(GCC_CFLAGS) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP)
444
else
445
	$(LD) $(LFLAGS) -Map $(MAP_PREV) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP)
446
endif
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
447
	$(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
448
	$(GENMAP) $(MAP_PREV) $(DUMP) $@
449
	
450
	# Do it once again, this time to get correct even the symbols
451
	# on architectures that have bss after symtab
452
	
453
	echo $(SYMTAB_SECTION)" .incbin \"$@\"" | $(AS) $(AFLAGS) -o $(SIZEOK_MAP)
498 by Martin Decky
add kernel support for link-time optimization (GCC 4.5+)
454
ifeq ($(CONFIG_LTO),y)
455
	$(GCC) $(LFLAGS_LTO) -Xlinker -Map -Xlinker $(MAP_PREV) $(DEFS) $(GCC_CFLAGS) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP)
456
else
457
	$(LD) $(LFLAGS) -Map $(MAP_PREV) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP)
458
endif
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
459
	$(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
460
	$(GENMAP) $(MAP_PREV) $(DUMP) $@
461
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
462
$(DEPEND): $(COMMON_HEADER_ARCH) $(ARCH_AUTOGENS_H)
324 by Martin Decky
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
463
	makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > $@ 2> /dev/null
464
	-[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
465
466
$(COMMON_HEADER_ARCH): $(COMMON_HEADER)
1443.1.36 by Vojtech Horky
Prevent compile-time symlinks in kernel
467
	ln -sfn ../../../../$< $@
1736.39.8 by Jakub Jermar
Add buildsystem rules for building and cleaning autogens.
468
469
autogen_clean:
470
	-rm $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)