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