Subversion Repositories HelenOS

Rev

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

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