Subversion Repositories HelenOS

Rev

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

Rev 4337 Rev 4338
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
33
include ../../Makefile.config
34
 
34
 
35
LIBC_PREFIX = $(shell pwd)
35
LIBC_PREFIX = $(shell pwd)
36
SOFTINT_PREFIX = ../softint
36
SOFTINT_PREFIX = ../softint
37
CONSOLE_PREFIX = ../../srv/console
-
 
38
RTLD_PREFIX = ../../lib/rtld
37
RTLD_PREFIX = ../../lib/rtld
39
 
38
 
40
## Setup toolchain
39
## Setup toolchain
41
#
40
#
42
 
41
 
43
include $(LIBC_PREFIX)/Makefile.toolchain
42
include $(LIBC_PREFIX)/Makefile.toolchain
44
 
43
 
45
CFLAGS += -I$(CONSOLE_PREFIX) -I$(RTLD_PREFIX)/include -I../../srv/loader/include -D__32_BITS__
44
CFLAGS += -I$(RTLD_PREFIX)/include -I../../srv/loader/include -D__32_BITS__
46
PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
45
PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
47
 
46
 
48
## Sources
47
## Sources
49
#
48
#
50
 
49
 
51
 
50
 
52
GENERIC_SOURCES = \
51
GENERIC_SOURCES = \
53
	generic/libc.c \
52
	generic/libc.c \
54
	generic/ddi.c \
53
	generic/ddi.c \
55
	generic/as.c \
54
	generic/as.c \
56
	generic/cap.c \
55
	generic/cap.c \
-
 
56
	generic/console.c \
57
	generic/mem.c \
57
	generic/mem.c \
58
	generic/string.c \
58
	generic/string.c \
59
	generic/fibril.c \
59
	generic/fibril.c \
60
	generic/pcb.c \
60
	generic/pcb.c \
61
	generic/smc.c \
61
	generic/smc.c \
62
	generic/thread.c \
62
	generic/thread.c \
63
	generic/tls.c \
63
	generic/tls.c \
64
	generic/task.c \
64
	generic/task.c \
65
	generic/futex.c \
65
	generic/futex.c \
66
	generic/io/asprintf.c \
66
	generic/io/asprintf.c \
67
	generic/io/io.c \
67
	generic/io/io.c \
68
	generic/io/printf.c \
68
	generic/io/printf.c \
-
 
69
	generic/io/fprintf.c \
-
 
70
	generic/io/stdio.c \
69
	generic/io/stream.c \
71
	generic/io/stream.c \
70
	generic/io/sprintf.c \
72
	generic/io/sprintf.c \
71
	generic/io/snprintf.c \
73
	generic/io/snprintf.c \
72
	generic/io/vprintf.c \
74
	generic/io/vprintf.c \
73
	generic/io/vsprintf.c \
75
	generic/io/vsprintf.c \
74
	generic/io/vsnprintf.c \
76
	generic/io/vsnprintf.c \
75
	generic/io/printf_core.c \
77
	generic/io/printf_core.c \
76
	malloc/malloc.c \
78
	malloc/malloc.c \
77
	generic/sysinfo.c \
79
	generic/sysinfo.c \
78
	generic/ipc.c \
80
	generic/ipc.c \
79
	generic/async.c \
81
	generic/async.c \
80
	generic/dlfcn.c \
82
	generic/dlfcn.c \
81
	generic/loader.c \
83
	generic/loader.c \
82
	generic/getopt.c \
84
	generic/getopt.c \
83
	generic/libadt/list.o \
85
	generic/libadt/list.o \
84
	generic/libadt/hash_table.o \
86
	generic/libadt/hash_table.o \
85
	generic/time.c \
87
	generic/time.c \
86
	generic/err.c \
88
	generic/err.c \
87
	generic/stdlib.c \
89
	generic/stdlib.c \
88
	generic/mman.c \
90
	generic/mman.c \
89
	generic/udebug.c \
91
	generic/udebug.c \
90
	generic/vfs/vfs.c \
92
	generic/vfs/vfs.c \
91
	generic/vfs/canonify.c
93
	generic/vfs/canonify.c
92
 
94
 
93
ARCH_SOURCES += \
95
ARCH_SOURCES += \
94
	arch/$(ARCH)/src/entry.s \
96
	arch/$(ARCH)/src/entry.s \
95
	arch/$(ARCH)/src/thread_entry.s
97
	arch/$(ARCH)/src/thread_entry.s
96
 
98
 
97
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
99
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
98
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
100
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
99
OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
101
OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
100
PIC_OBJECTS := $(addsuffix .pio,$(basename $(OBJECTS)))
102
PIC_OBJECTS := $(addsuffix .pio,$(basename $(OBJECTS)))
101
 
103
 
102
.PHONY: all clean depend kerninc
104
.PHONY: all clean depend kerninc
103
 
105
 
104
all: kerninc libc.a libc.pic.a arch/$(ARCH)/_link.ld
106
all: kerninc libc.a libc.pic.a arch/$(ARCH)/_link.ld
105
 
107
 
106
kerninc:
108
kerninc:
107
	ln -sfn ../../../../kernel/generic/include include/kernel
109
	ln -sfn ../../../../kernel/generic/include include/kernel
108
	ln -sfn kernel/arch include/arch
110
	ln -sfn kernel/arch include/arch
109
	ln -sfn ../arch/$(ARCH)/include include/libarch
111
	ln -sfn ../arch/$(ARCH)/include include/libarch
110
 
112
 
111
-include Makefile.depend
113
-include Makefile.depend
112
 
114
 
113
clean:
115
clean:
114
	-rm -f include/kernel include/arch include/libarch libc.a libc.pic.a arch/$(ARCH)/_link.ld Makefile.depend
116
	-rm -f include/kernel include/arch include/libarch libc.a libc.pic.a arch/$(ARCH)/_link.ld Makefile.depend
115
	find . \( -name '*.o' -o -name '*.pio' \) -follow -exec rm \{\} \;
117
	find . \( -name '*.o' -o -name '*.pio' \) -follow -exec rm \{\} \;
116
 
118
 
117
depend: kerninc
119
depend: kerninc
118
	-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
120
	-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
119
	-makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(ARCH_SOURCES) $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
121
	-makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(ARCH_SOURCES) $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
120
 
122
 
121
libc.a: depend $(OBJECTS)
123
libc.a: depend $(OBJECTS)
122
	$(AR) rc $@ $(LIBS) $(OBJECTS)
124
	$(AR) rc $@ $(LIBS) $(OBJECTS)
123
 
125
 
124
libc.pic.a: depend $(PIC_OBJECTS)
126
libc.pic.a: depend $(PIC_OBJECTS)
125
	$(AR) rc $@ $(LIBS) $(PIC_OBJECTS)
127
	$(AR) rc $@ $(LIBS) $(PIC_OBJECTS)
126
 
128
 
127
arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in
129
arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in
128
	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
130
	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
129
 
131
 
130
%.o: %.S
132
%.o: %.S
131
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
133
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
132
 
134
 
133
%.o: %.s
135
%.o: %.s
134
	$(AS) $(AFLAGS) $< -o $@
136
	$(AS) $(AFLAGS) $< -o $@
135
 
137
 
136
%.o: %.c
138
%.o: %.c
137
	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
139
	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
138
 
140
 
139
%.pio: %.S
141
%.pio: %.S
140
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
142
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
141
 
143
 
142
%.pio: %.s
144
%.pio: %.s
143
	$(AS) $(AFLAGS) $< -o $@
145
	$(AS) $(AFLAGS) $< -o $@
144
 
146
 
145
%.pio: %.c
147
%.pio: %.c
146
	$(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
148
	$(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
147
 
149