Subversion Repositories HelenOS

Rev

Rev 3564 | Rev 3686 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3564 Rev 3569
1
#
1
#
2
# Copyright (c) 2005 Martin Decky
2
# Copyright (c) 2005 Martin Decky
3
# Copyright (c) 2008 Jiri Svoboda
3
# Copyright (c) 2008 Jiri Svoboda
4
# All rights reserved.
4
# All rights reserved.
5
#
5
#
6
# Redistribution and use in source and binary forms, with or without
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
7
# modification, are permitted provided that the following conditions
8
# are met:
8
# are met:
9
#
9
#
10
# - Redistributions of source code must retain the above copyright
10
# - Redistributions of source code must retain the above copyright
11
#   notice, this list of conditions and the following disclaimer.
11
#   notice, this list of conditions and the following disclaimer.
12
# - Redistributions in binary form must reproduce the above copyright
12
# - Redistributions in binary form must reproduce the above copyright
13
#   notice, this list of conditions and the following disclaimer in the
13
#   notice, this list of conditions and the following disclaimer in the
14
#   documentation and/or other materials provided with the distribution.
14
#   documentation and/or other materials provided with the distribution.
15
# - The name of the author may not be used to endorse or promote products
15
# - The name of the author may not be used to endorse or promote products
16
#   derived from this software without specific prior written permission.
16
#   derived from this software without specific prior written permission.
17
#
17
#
18
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#
28
#
29
 
29
 
30
## Common compiler flags
30
## Common compiler flags
31
#
31
#
32
 
32
 
-
 
33
include ../../Makefile.config
-
 
34
 
33
LIBC_PREFIX = $(shell pwd)
35
LIBC_PREFIX = $(shell pwd)
34
SOFTINT_PREFIX = ../softint
36
SOFTINT_PREFIX = ../softint
35
CONSOLE_PREFIX = ../../srv/console
37
CONSOLE_PREFIX = ../../srv/console
36
 
38
 
37
## Setup toolchain
39
## Setup toolchain
38
#
40
#
39
 
41
 
40
include $(LIBC_PREFIX)/Makefile.toolchain
42
include $(LIBC_PREFIX)/Makefile.toolchain
41
 
43
 
42
CFLAGS += -I$(CONSOLE_PREFIX)
44
CFLAGS += -I$(CONSOLE_PREFIX)
43
PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
45
PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
44
 
46
 
45
## Sources
47
## Sources
46
#
48
#
47
 
49
 
48
 
50
 
49
GENERIC_SOURCES = \
51
GENERIC_SOURCES = \
50
	generic/libc.c \
52
	generic/libc.c \
51
	generic/ddi.c \
53
	generic/ddi.c \
52
	generic/as.c \
54
	generic/as.c \
53
	generic/cap.c \
55
	generic/cap.c \
54
	generic/string.c \
56
	generic/string.c \
55
	generic/fibril.c \
57
	generic/fibril.c \
56
	generic/pcb.c \
58
	generic/pcb.c \
57
	generic/smc.c \
59
	generic/smc.c \
58
	generic/thread.c \
60
	generic/thread.c \
59
	generic/tls.c \
61
	generic/tls.c \
60
	generic/task.c \
62
	generic/task.c \
61
	generic/futex.c \
63
	generic/futex.c \
62
	generic/io/asprintf.c \
64
	generic/io/asprintf.c \
63
	generic/io/io.c \
65
	generic/io/io.c \
64
	generic/io/printf.c \
66
	generic/io/printf.c \
65
	generic/io/stream.c \
67
	generic/io/stream.c \
66
	generic/io/sprintf.c \
68
	generic/io/sprintf.c \
67
	generic/io/snprintf.c \
69
	generic/io/snprintf.c \
68
	generic/io/vprintf.c \
70
	generic/io/vprintf.c \
69
	generic/io/vsprintf.c \
71
	generic/io/vsprintf.c \
70
	generic/io/vsnprintf.c \
72
	generic/io/vsnprintf.c \
71
	generic/io/printf_core.c \
73
	generic/io/printf_core.c \
72
	malloc/malloc.c \
74
	malloc/malloc.c \
73
	generic/sysinfo.c \
75
	generic/sysinfo.c \
74
	generic/ipc.c \
76
	generic/ipc.c \
75
	generic/async.c \
77
	generic/async.c \
76
	generic/loader.c \
78
	generic/loader.c \
77
	generic/getopt.c \
79
	generic/getopt.c \
78
	generic/libadt/list.o \
80
	generic/libadt/list.o \
79
	generic/libadt/hash_table.o \
81
	generic/libadt/hash_table.o \
80
	generic/time.c \
82
	generic/time.c \
81
	generic/err.c \
83
	generic/err.c \
82
	generic/stdlib.c \
84
	generic/stdlib.c \
83
	generic/mman.c \
85
	generic/mman.c \
84
	generic/udebug.c \
86
	generic/udebug.c \
85
	generic/vfs/vfs.c \
87
	generic/vfs/vfs.c \
86
	generic/vfs/canonify.c
88
	generic/vfs/canonify.c
87
 
89
 
88
ARCH_SOURCES += \
90
ARCH_SOURCES += \
89
	arch/$(ARCH)/src/entry.s \
91
	arch/$(ARCH)/src/entry.s \
90
	arch/$(ARCH)/src/thread_entry.s
92
	arch/$(ARCH)/src/thread_entry.s
91
 
93
 
92
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
94
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
93
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
95
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
94
 
96
 
95
OBJECTS = $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
97
OBJECTS = $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
96
PIC_OBJECTS = $(addsuffix .pio,$(basename $(OBJECTS)))
98
PIC_OBJECTS = $(addsuffix .pio,$(basename $(OBJECTS)))
97
 
99
 
98
.PHONY: all clean depend kerninc
100
.PHONY: all clean depend kerninc
99
 
101
 
100
all: kerninc libc.a libc.pic.a arch/$(ARCH)/_link.ld
102
all: kerninc libc.a libc.pic.a arch/$(ARCH)/_link.ld
101
 
103
 
102
kerninc:
104
kerninc:
103
	ln -sfn ../../../../kernel/generic/include include/kernel
105
	ln -sfn ../../../../kernel/generic/include include/kernel
104
	ln -sfn kernel/arch include/arch
106
	ln -sfn kernel/arch include/arch
105
	ln -sfn ../arch/$(ARCH)/include include/libarch
107
	ln -sfn ../arch/$(ARCH)/include include/libarch
106
 
108
 
107
-include Makefile.depend
109
-include Makefile.depend
108
 
110
 
109
clean:
111
clean:
110
	-rm -f include/kernel include/arch include/libarch libc.a libc.pic.a arch/$(ARCH)/_link.ld Makefile.depend
112
	-rm -f include/kernel include/arch include/libarch libc.a libc.pic.a arch/$(ARCH)/_link.ld Makefile.depend
111
	find . \( -name '*.o' -o -name '*.pio' \) -follow -exec rm \{\} \;
113
	find . \( -name '*.o' -o -name '*.pio' \) -follow -exec rm \{\} \;
112
 
114
 
113
depend: kerninc
115
depend: kerninc
114
	-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
116
	-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
115
	-makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(ARCH_SOURCES) $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
117
	-makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(ARCH_SOURCES) $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
116
 
118
 
117
libc.a: depend $(OBJECTS)
119
libc.a: depend $(OBJECTS)
118
	$(AR) rc $@ $(LIBS) $(OBJECTS)
120
	$(AR) rc $@ $(LIBS) $(OBJECTS)
119
 
121
 
120
libc.pic.a: depend $(PIC_OBJECTS)
122
libc.pic.a: depend $(PIC_OBJECTS)
121
	$(AR) rc $@ $(LIBS) $(PIC_OBJECTS)
123
	$(AR) rc $@ $(LIBS) $(PIC_OBJECTS)
122
 
124
 
123
arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in
125
arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in
124
	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
126
	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
125
 
127
 
126
%.o: %.S
128
%.o: %.S
127
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
129
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
128
 
130
 
129
%.o: %.s
131
%.o: %.s
130
	$(AS) $(AFLAGS) $< -o $@
132
	$(AS) $(AFLAGS) $< -o $@
131
 
133
 
132
%.o: %.c
134
%.o: %.c
133
	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
135
	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
134
 
136
 
135
%.pio: %.S
137
%.pio: %.S
136
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
138
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
137
 
139
 
138
%.pio: %.s
140
%.pio: %.s
139
	$(AS) $(AFLAGS) $< -o $@
141
	$(AS) $(AFLAGS) $< -o $@
140
 
142
 
141
%.pio: %.c
143
%.pio: %.c
142
	$(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
144
	$(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
143
 
145