~martin-decky/helenos/rcu

« back to all changes in this revision

Viewing changes to kernel/Makefile.build

  • Committer: Martin Decky
  • Date: 2010-03-19 18:30:12 UTC
  • Revision ID: martin@uranus.dsrg.hide.ms.mff.cuni.cz-20100319183012-rmyqumxyx09q51kd
more autotooling: run actually the compiler in autotool.py and detect sizes of integers, generate common.h
more build system cleanup: remove redundancy, remove config.defs, merge kernel makefiles to a single file

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
33
 
include Makefile.common
34
 
include ../version
35
 
include ../Makefile.common
36
 
include ../Makefile.config
37
 
include ../config.defs
38
 
 
39
 
LINK = arch/$(KARCH)/_link.ld
40
 
EMPTY_MAP = generic/src/debug/empty_map.o
41
 
SIZEOK_MAP = generic/src/debug/sizeok_map.o
42
 
 
43
 
INCLUDES = generic/include
44
 
OPTIMIZATION = 3
45
 
 
46
 
## Common compiler flags
47
 
#
48
 
 
49
 
DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
50
 
 
51
 
GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
52
 
        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
53
 
        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
54
 
        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
55
 
        -Werror-implicit-function-declaration -Wwrite-strings \
56
 
        -Werror -pipe
57
 
 
58
 
ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
59
 
        -ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
60
 
        -Werror-implicit-function-declaration -Werror -wd170
61
 
 
62
 
SUNCC_CFLAGS = -I$(INCLUDES) -xO$(OPTIMIZATION) \
63
 
        -xnolib -xc99=all -features=extensions \
64
 
        -erroff=E_ZERO_SIZED_STRUCT_UNION
65
 
 
66
 
CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
67
 
        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
68
 
        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
69
 
        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
70
 
        -Werror-implicit-function-declaration -Wwrite-strings \
71
 
        -pipe -arch $(CLANG_ARCH)
72
 
 
73
 
LFLAGS = -M
74
 
AFLAGS =
75
 
 
76
 
-include arch/$(KARCH)/Makefile.inc
77
 
-include genarch/Makefile.inc
78
 
 
79
 
## The at-sign
80
 
#
81
 
# The $(ATSIGN) variable holds the ASCII character representing the at-sign
82
 
# ('@') used in various $(AS) constructs (e.g. @progbits). On architectures that
83
 
# don't use '@' for starting a comment, $(ATSIGN) is merely '@'. However, on
84
 
# those that do use it for starting a comment (e.g. arm32), $(ATSIGN) must be
85
 
# defined as the percentile-sign ('%') in the architecture-dependent
86
 
# Makefile.inc.
87
 
#
88
 
 
89
 
ATSIGN ?= @
90
 
 
91
 
## Cross-platform assembly to start a symtab.data section
92
 
#
93
 
 
94
 
SYMTAB_SECTION = ".section symtab.data, \"a\", $(ATSIGN)progbits;"
95
 
 
96
 
## Compilation options
97
 
#
98
 
 
99
 
ifeq ($(COMPILER),gcc_native)
100
 
        CFLAGS = $(GCC_CFLAGS)
101
 
        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
102
 
endif
103
 
 
104
 
ifeq ($(COMPILER),gcc_cross)
105
 
        CFLAGS = $(GCC_CFLAGS)
106
 
        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
107
 
endif
108
 
 
109
 
ifeq ($(COMPILER),icc)
110
 
        CFLAGS = $(ICC_CFLAGS)
111
 
        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
112
 
endif
113
 
 
114
 
ifeq ($(COMPILER),suncc)
115
 
        CFLAGS = $(SUNCC_CFLAGS)
116
 
        DEFS += $(CONFIG_DEFS)
117
 
        DEPEND_DEFS = $(DEFS)
118
 
endif
119
 
 
120
 
ifeq ($(COMPILER),clang)
121
 
        CFLAGS = $(CLANG_CFLAGS)
122
 
        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
123
 
endif
124
 
 
125
 
 
126
 
## Generic kernel sources
127
 
#
128
 
 
129
 
GENERIC_SOURCES = \
130
 
        generic/src/adt/avl.c \
131
 
        generic/src/adt/bitmap.c \
132
 
        generic/src/adt/btree.c \
133
 
        generic/src/adt/hash_table.c \
134
 
        generic/src/adt/list.c \
135
 
        generic/src/console/chardev.c \
136
 
        generic/src/console/console.c \
137
 
        generic/src/cpu/cpu.c \
138
 
        generic/src/ddi/ddi.c \
139
 
        generic/src/ddi/irq.c \
140
 
        generic/src/ddi/device.c \
141
 
        generic/src/debug/symtab.c \
142
 
        generic/src/debug/stacktrace.c \
143
 
        generic/src/interrupt/interrupt.c \
144
 
        generic/src/main/main.c \
145
 
        generic/src/main/kinit.c \
146
 
        generic/src/main/uinit.c \
147
 
        generic/src/main/version.c \
148
 
        generic/src/main/shutdown.c \
149
 
        generic/src/proc/program.c \
150
 
        generic/src/proc/scheduler.c \
151
 
        generic/src/proc/thread.c \
152
 
        generic/src/proc/task.c \
153
 
        generic/src/proc/the.c \
154
 
        generic/src/proc/tasklet.c \
155
 
        generic/src/syscall/syscall.c \
156
 
        generic/src/syscall/copy.c \
157
 
        generic/src/mm/buddy.c \
158
 
        generic/src/mm/frame.c \
159
 
        generic/src/mm/page.c \
160
 
        generic/src/mm/tlb.c \
161
 
        generic/src/mm/as.c \
162
 
        generic/src/mm/backend_anon.c \
163
 
        generic/src/mm/backend_elf.c \
164
 
        generic/src/mm/backend_phys.c \
165
 
        generic/src/mm/slab.c \
166
 
        generic/src/lib/func.c \
167
 
        generic/src/lib/memstr.c \
168
 
        generic/src/lib/sort.c \
169
 
        generic/src/lib/string.c \
170
 
        generic/src/lib/elf.c \
171
 
        generic/src/lib/rd.c \
172
 
        generic/src/printf/printf_core.c \
173
 
        generic/src/printf/printf.c \
174
 
        generic/src/printf/snprintf.c \
175
 
        generic/src/printf/vprintf.c \
176
 
        generic/src/printf/vsnprintf.c \
177
 
        generic/src/time/clock.c \
178
 
        generic/src/time/timeout.c \
179
 
        generic/src/time/delay.c \
180
 
        generic/src/preempt/preemption.c \
181
 
        generic/src/synch/spinlock.c \
182
 
        generic/src/synch/condvar.c \
183
 
        generic/src/synch/rwlock.c \
184
 
        generic/src/synch/mutex.c \
185
 
        generic/src/synch/semaphore.c \
186
 
        generic/src/synch/smc.c \
187
 
        generic/src/synch/waitq.c \
188
 
        generic/src/synch/futex.c \
189
 
        generic/src/smp/ipi.c \
190
 
        generic/src/smp/smp.c \
191
 
        generic/src/ipc/ipc.c \
192
 
        generic/src/ipc/sysipc.c \
193
 
        generic/src/ipc/ipcrsc.c \
194
 
        generic/src/ipc/irq.c \
195
 
        generic/src/ipc/event.c \
196
 
        generic/src/security/cap.c \
197
 
        generic/src/sysinfo/sysinfo.c
198
 
 
199
 
## Kernel console support
200
 
#
201
 
 
202
 
ifeq ($(CONFIG_KCONSOLE),y)
203
 
GENERIC_SOURCES += \
204
 
        generic/src/console/kconsole.c \
205
 
        generic/src/console/cmd.c
206
 
endif
207
 
 
208
 
## Udebug interface sources
209
 
#
210
 
 
211
 
ifeq ($(CONFIG_UDEBUG),y)
212
 
GENERIC_SOURCES += \
213
 
        generic/src/ipc/kbox.c \
214
 
        generic/src/udebug/udebug.c \
215
 
        generic/src/udebug/udebug_ops.c \
216
 
        generic/src/udebug/udebug_ipc.c
217
 
endif
218
 
 
219
 
## Test sources
220
 
#
221
 
 
222
 
ifeq ($(CONFIG_TEST),y)
223
 
        CFLAGS += -Itest/
224
 
        GENERIC_SOURCES += \
225
 
                test/test.c \
226
 
                test/atomic/atomic1.c \
227
 
                test/btree/btree1.c \
228
 
                test/avltree/avltree1.c \
229
 
                test/fault/fault1.c \
230
 
                test/mm/falloc1.c \
231
 
                test/mm/falloc2.c \
232
 
                test/mm/mapping1.c \
233
 
                test/mm/slab1.c \
234
 
                test/mm/slab2.c \
235
 
                test/synch/rwlock1.c \
236
 
                test/synch/rwlock2.c \
237
 
                test/synch/rwlock3.c \
238
 
                test/synch/rwlock4.c \
239
 
                test/synch/rwlock5.c \
240
 
                test/synch/semaphore1.c \
241
 
                test/synch/semaphore2.c \
242
 
                test/print/print1.c \
243
 
                test/print/print2.c \
244
 
                test/print/print3.c \
245
 
                test/print/print4.c \
246
 
                test/thread/thread1.c \
247
 
                test/sysinfo/sysinfo1.c
248
 
        
249
 
        ifeq ($(KARCH),mips32)
250
 
                GENERIC_SOURCES += test/debug/mips1.c
251
 
        else
252
 
                GENERIC_SOURCES += test/debug/mips1_skip.c
253
 
        endif
254
 
        
255
 
        ifeq ($(KARCH),ia64)
256
 
                GENERIC_SOURCES += test/mm/purge1.c
257
 
        else
258
 
                GENERIC_SOURCES += test/mm/purge1_skip.c
259
 
        endif
260
 
        
261
 
        ifeq ($(CONFIG_FPU),y)
262
 
                ifeq ($(KARCH),ia32)
263
 
                        TEST_FPU1 = y
264
 
                        TEST_SSE1 = y
265
 
                        GENERIC_SOURCES += test/fpu/fpu1_x86.c
266
 
                endif
267
 
                
268
 
                ifeq ($(KARCH),amd64)
269
 
                        TEST_FPU1 = y
270
 
                        TEST_SSE1 = y
271
 
                        GENERIC_SOURCES += test/fpu/fpu1_x86.c
272
 
                endif
273
 
                
274
 
                ifeq ($(KARCH),ia64)
275
 
                        TEST_FPU1 = y
276
 
                        GENERIC_SOURCES += test/fpu/fpu1_ia64.c
277
 
                endif
278
 
                
279
 
                ifeq ($(KARCH),mips32)
280
 
                        TEST_MIPS2 = y
281
 
                endif
282
 
        endif
283
 
        
284
 
        ifneq ($(TEST_FPU1),y)
285
 
                GENERIC_SOURCES += test/fpu/fpu1_skip.c
286
 
        endif
287
 
        
288
 
        ifeq ($(TEST_SSE1),y)
289
 
                GENERIC_SOURCES += test/fpu/sse1.c
290
 
        else
291
 
                GENERIC_SOURCES += test/fpu/sse1_skip.c
292
 
        endif
293
 
        
294
 
        ifeq ($(TEST_MIPS2),y)
295
 
                GENERIC_SOURCES += test/fpu/mips2.c
296
 
        else
297
 
                GENERIC_SOURCES += test/fpu/mips2_skip.c
298
 
        endif
299
 
        
300
 
endif
301
 
 
302
 
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
303
 
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
304
 
GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
305
 
 
306
 
ifeq ($(CONFIG_SYMTAB),y)
307
 
        SYMTAB_OBJECTS := generic/src/debug/real_map.o
308
 
else
309
 
        SYMTAB_OBJECTS :=
310
 
endif
311
 
 
312
 
.PHONY: all
313
 
 
314
 
all: $(BIN) $(DISASM)
315
 
 
316
 
-include $(DEPEND)
317
 
 
318
 
$(BIN): $(RAW)
319
 
        $(OBJCOPY) -O $(BFD) $< $@
320
 
 
321
 
$(DISASM): $(RAW)
322
 
        $(OBJDUMP) -d $< > $@
323
 
 
324
 
$(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS)
325
 
        $(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS) -o $@ -Map $(MAP)
326
 
 
327
 
$(LINK): $(LINK).in $(DEPEND)
328
 
        $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
329
 
 
330
 
%.o: %.S $(DEPEND)
331
 
        $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c $< -o $@
332
 
ifeq ($(PRECHECK),y)
333
 
        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(GCC_CFLAGS) -D__ASM__
334
 
endif
335
 
 
336
 
%.o: %.s $(DEPEND)
337
 
        $(AS) $(AFLAGS) $< -o $@
338
 
ifeq ($(PRECHECK),y)
339
 
        $(JOBFILE) $(JOB) $< $@ as asm $(DEFS) $(CFLAGS) $(EXTRA_FLAGS)
340
 
endif
341
 
 
342
 
#
343
 
# The FPU tests are the only objects for which we allow the compiler to generate
344
 
# FPU instructions.
345
 
#
346
 
test/fpu/%.o: test/fpu/%.c $(DEPEND)
347
 
        $(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) -c $< -o $@
348
 
ifeq ($(PRECHECK),y)
349
 
        $(JOBFILE) $(JOB) $< $@ cc test $(DEFS) $(CFLAGS) $(EXTRA_FLAGS)
350
 
endif
351
 
 
352
 
#
353
 
# Ordinary objects.
354
 
#
355
 
%.o: %.c $(DEPEND)
356
 
        $(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) -c $< -o $@
357
 
ifeq ($(PRECHECK),y)
358
 
        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS)
359
 
endif
360
 
 
361
 
$(REAL_MAP).o: $(REAL_MAP).bin
362
 
        echo $(SYMTAB_SECTION)" .incbin \"$<\"" | $(AS) $(AFLAGS) -o $@
363
 
 
364
 
$(REAL_MAP).bin: $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
365
 
        echo $(SYMTAB_SECTION) | $(AS) $(AFLAGS) -o $(EMPTY_MAP)
366
 
        $(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP) -o $@ -Map $(MAP_PREV)
367
 
        $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
368
 
        $(GENMAP) $(MAP_PREV) $(DUMP) $@
369
 
        
370
 
        # Do it once again, this time to get correct even the symbols
371
 
        # on architectures that have bss after symtab
372
 
        
373
 
        echo $(SYMTAB_SECTION)" .incbin \"$@\"" | $(AS) $(AFLAGS) -o $(SIZEOK_MAP)
374
 
        $(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP) -o $@ -Map $(MAP_PREV)
375
 
        $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
376
 
        $(GENMAP) $(MAP_PREV) $(DUMP) $@
377
 
 
378
 
$(DEPEND): $(ARCH_INCLUDE) $(GENARCH_INCLUDE)
379
 
        makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > $@ 2> /dev/null
380
 
        -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
381
 
 
382
 
$(ARCH_INCLUDE): arch/$(KARCH)/include/
383
 
        ln -sfn ../../$< $@
384
 
 
385
 
$(GENARCH_INCLUDE): genarch/include/
386
 
        ln -sfn ../../$< $@