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 | ## Common compiler flags
|
---|
30 | #
|
---|
31 |
|
---|
32 | LIBC_PREFIX = $(shell pwd)
|
---|
33 | SOFTINT_PREFIX = ../softint
|
---|
34 | LINK = arch/$(UARCH)/_link.ld
|
---|
35 |
|
---|
36 |
|
---|
37 | ## Setup toolchain
|
---|
38 | #
|
---|
39 |
|
---|
40 | include Makefile.common
|
---|
41 | include Makefile.toolchain
|
---|
42 |
|
---|
43 |
|
---|
44 | ## Sources
|
---|
45 | #
|
---|
46 |
|
---|
47 | GENERIC_SOURCES = \
|
---|
48 | generic/libc.c \
|
---|
49 | generic/ddi.c \
|
---|
50 | generic/as.c \
|
---|
51 | generic/cap.c \
|
---|
52 | generic/clipboard.c \
|
---|
53 | generic/devmap.c \
|
---|
54 | generic/event.c \
|
---|
55 | generic/errno.c \
|
---|
56 | generic/mem.c \
|
---|
57 | generic/string.c \
|
---|
58 | generic/fibril.c \
|
---|
59 | generic/fibril_sync.c \
|
---|
60 | generic/pcb.c \
|
---|
61 | generic/smc.c \
|
---|
62 | generic/thread.c \
|
---|
63 | generic/tls.c \
|
---|
64 | generic/task.c \
|
---|
65 | generic/futex.c \
|
---|
66 | generic/io/asprintf.c \
|
---|
67 | generic/io/io.c \
|
---|
68 | generic/io/printf.c \
|
---|
69 | generic/io/klog.c \
|
---|
70 | generic/io/snprintf.c \
|
---|
71 | generic/io/vprintf.c \
|
---|
72 | generic/io/vsnprintf.c \
|
---|
73 | generic/io/printf_core.c \
|
---|
74 | generic/io/console.c \
|
---|
75 | generic/malloc.c \
|
---|
76 | generic/sysinfo.c \
|
---|
77 | generic/ipc.c \
|
---|
78 | generic/async.c \
|
---|
79 | generic/loader.c \
|
---|
80 | generic/getopt.c \
|
---|
81 | generic/adt/list.o \
|
---|
82 | generic/adt/hash_table.o \
|
---|
83 | generic/time.c \
|
---|
84 | generic/err.c \
|
---|
85 | generic/stdlib.c \
|
---|
86 | generic/mman.c \
|
---|
87 | generic/udebug.c \
|
---|
88 | generic/vfs/vfs.c \
|
---|
89 | generic/vfs/canonify.c
|
---|
90 |
|
---|
91 | ARCH_SOURCES += \
|
---|
92 | arch/$(UARCH)/src/entry.s \
|
---|
93 | arch/$(UARCH)/src/thread_entry.s
|
---|
94 |
|
---|
95 | GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
|
---|
96 | ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
|
---|
97 | OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
|
---|
98 |
|
---|
99 | .PHONY: all
|
---|
100 |
|
---|
101 | all: $(LIBC) $(LINK)
|
---|
102 |
|
---|
103 | -include $(DEPEND)
|
---|
104 |
|
---|
105 | $(LIBC): $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
|
---|
106 | $(AR) rc $@ $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
|
---|
107 |
|
---|
108 | $(LINK): $(LINK).in
|
---|
109 | $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
|
---|
110 |
|
---|
111 | %.o: %.S $(DEPEND)
|
---|
112 | $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
|
---|
113 |
|
---|
114 | %.o: %.s $(DEPEND)
|
---|
115 | $(AS) $(AFLAGS) $< -o $@
|
---|
116 |
|
---|
117 | %.o: %.c $(DEPEND)
|
---|
118 | $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
|
---|
119 |
|
---|
120 | $(DEPEND): $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH)
|
---|
121 | makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > $@ 2> /dev/null
|
---|
122 | -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
|
---|
123 |
|
---|
124 | $(INCLUDE_ARCH): $(INCLUDE_KERNEL) $(INCLUDE_KERNEL)/arch
|
---|
125 | ln -sfn kernel/arch $@
|
---|
126 |
|
---|
127 | $(INCLUDE_LIBARCH): arch/$(UARCH)/include
|
---|
128 | ln -sfn ../$< $@
|
---|
129 |
|
---|
130 | $(INCLUDE_KERNEL)/arch: ../../../kernel/generic/include/arch $(INCLUDE_KERNEL)
|
---|
131 |
|
---|
132 | $(INCLUDE_KERNEL): ../../../kernel/generic/include/
|
---|
133 | ln -sfn ../$< $@
|
---|