[0e4ab80] | 1 | #
|
---|
[df4ed85] | 2 | # Copyright (c) 2005 Martin Decky
|
---|
[1ea99cc] | 3 | # Copyright (c) 2008 Jiri Svoboda
|
---|
[0e4ab80] | 4 | # All rights reserved.
|
---|
| 5 | #
|
---|
| 6 | # Redistribution and use in source and binary forms, with or without
|
---|
| 7 | # modification, are permitted provided that the following conditions
|
---|
| 8 | # are met:
|
---|
| 9 | #
|
---|
| 10 | # - Redistributions of source code must retain the above copyright
|
---|
| 11 | # notice, this list of conditions and the following disclaimer.
|
---|
| 12 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 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
|
---|
| 16 | # derived from this software without specific prior written permission.
|
---|
| 17 | #
|
---|
| 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
|
---|
| 20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 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
|
---|
| 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
|
---|
| 27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | #
|
---|
[3eddaff] | 29 |
|
---|
[0e4ab80] | 30 | ## Common compiler flags
|
---|
| 31 | #
|
---|
[3eddaff] | 32 |
|
---|
[b006bfb8] | 33 | LIBC_PREFIX = $(shell pwd)
|
---|
[11a4fbf] | 34 | SOFTINT_PREFIX = ../softint
|
---|
[3eddaff] | 35 |
|
---|
[ac47b7c2] | 36 |
|
---|
[25b0e6a] | 37 | ## Setup toolchain
|
---|
[0e4ab80] | 38 | #
|
---|
[3eddaff] | 39 |
|
---|
[25b0e6a] | 40 | include $(LIBC_PREFIX)/Makefile.toolchain
|
---|
[1ea99cc] | 41 | -include rtld/arch/$(UARCH)/Makefile.inc
|
---|
[0e4ab80] | 42 |
|
---|
[1ea99cc] | 43 | CFLAGS += -Irtld/include -I../../srv/loader/include -D__32_BITS__
|
---|
| 44 | PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
|
---|
[fcd7053] | 45 |
|
---|
[0e4ab80] | 46 | ## Sources
|
---|
| 47 | #
|
---|
| 48 |
|
---|
| 49 | GENERIC_SOURCES = \
|
---|
[cc6f688] | 50 | generic/libc.c \
|
---|
[a1e17fc] | 51 | generic/ddi.c \
|
---|
[11fa83a] | 52 | generic/as.c \
|
---|
[7981e3cc] | 53 | generic/cap.c \
|
---|
[1090b8c] | 54 | generic/devmap.c \
|
---|
[05641a9e] | 55 | generic/event.c \
|
---|
[db24058] | 56 | generic/errno.c \
|
---|
[e64c4b2] | 57 | generic/mem.c \
|
---|
[936351c1] | 58 | generic/string.c \
|
---|
[fa23560] | 59 | generic/fibril.c \
|
---|
[041186f] | 60 | generic/fibril_sync.c \
|
---|
[c98e6ee] | 61 | generic/pcb.c \
|
---|
| 62 | generic/smc.c \
|
---|
[c05290e] | 63 | generic/thread.c \
|
---|
[fa23560] | 64 | generic/tls.c \
|
---|
[f30e6a0b] | 65 | generic/task.c \
|
---|
[1cef26f] | 66 | generic/futex.c \
|
---|
[ab00d5a] | 67 | generic/io/asprintf.c \
|
---|
[4e2cf8b] | 68 | generic/io/io.c \
|
---|
[3214a20] | 69 | generic/io/printf.c \
|
---|
[2595dab] | 70 | generic/io/klog.c \
|
---|
[3214a20] | 71 | generic/io/snprintf.c \
|
---|
| 72 | generic/io/vprintf.c \
|
---|
| 73 | generic/io/vsnprintf.c \
|
---|
| 74 | generic/io/printf_core.c \
|
---|
[2595dab] | 75 | generic/io/console.c \
|
---|
[db24058] | 76 | generic/malloc.c \
|
---|
[450cd3a] | 77 | generic/sysinfo.c \
|
---|
[80649a91] | 78 | generic/ipc.c \
|
---|
| 79 | generic/async.c \
|
---|
[1ea99cc] | 80 | generic/dlfcn.c \
|
---|
[45454e9b] | 81 | generic/loader.c \
|
---|
[216d6fc] | 82 | generic/getopt.c \
|
---|
[d9c8c81] | 83 | generic/adt/list.o \
|
---|
| 84 | generic/adt/hash_table.o \
|
---|
[c594489] | 85 | generic/time.c \
|
---|
| 86 | generic/err.c \
|
---|
[83b1d61] | 87 | generic/stdlib.c \
|
---|
[2f02aa17] | 88 | generic/mman.c \
|
---|
[9a1b20c] | 89 | generic/udebug.c \
|
---|
[dadcec1] | 90 | generic/vfs/vfs.c \
|
---|
[1ea99cc] | 91 | generic/vfs/canonify.c \
|
---|
| 92 | rtld/rtld.c \
|
---|
| 93 | rtld/elf_load.c \
|
---|
| 94 | rtld/dynamic.c \
|
---|
| 95 | rtld/module.c \
|
---|
| 96 | rtld/symbol.c
|
---|
| 97 |
|
---|
[0e4ab80] | 98 |
|
---|
[1a030b8] | 99 | ARCH_SOURCES += \
|
---|
[fcd7053] | 100 | arch/$(UARCH)/src/entry.s \
|
---|
| 101 | arch/$(UARCH)/src/thread_entry.s
|
---|
[3eddaff] | 102 |
|
---|
[0e4ab80] | 103 | GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
|
---|
| 104 | ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
|
---|
[5ae4443] | 105 | OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
|
---|
[1ea99cc] | 106 | PIC_OBJECTS := $(addsuffix .pio,$(basename $(OBJECTS)))
|
---|
| 107 |
|
---|
| 108 | OUTPUT := libc.a
|
---|
| 109 |
|
---|
| 110 | ifeq ($(CONFIG_BUILD_SHARED_LIBC), y)
|
---|
| 111 | OUTPUT += libc.pic.a
|
---|
| 112 | endif
|
---|
[0e4ab80] | 113 |
|
---|
[b419162] | 114 | .PHONY: all clean depend kerninc
|
---|
[0e4ab80] | 115 |
|
---|
[1ea99cc] | 116 | all: kerninc $(OUTPUT) arch/$(UARCH)/_link.ld
|
---|
[b419162] | 117 |
|
---|
| 118 | kerninc:
|
---|
[00acd66] | 119 | ln -sfn ../../../../kernel/generic/include include/kernel
|
---|
[7e44122] | 120 | ln -sfn kernel/arch include/arch
|
---|
[fcd7053] | 121 | ln -sfn ../arch/$(UARCH)/include include/libarch
|
---|
[1ea99cc] | 122 | ln -sfn ../arch/$(UARCH)/include rtld/include/arch
|
---|
[0e4ab80] | 123 |
|
---|
| 124 | -include Makefile.depend
|
---|
[3eddaff] | 125 |
|
---|
| 126 | clean:
|
---|
[1ea99cc] | 127 | -rm -f include/kernel include/arch include/libarch rtld/include/arch libc.a libc.pic.a arch/$(UARCH)/_link.ld Makefile.depend
|
---|
| 128 | find . \( -name '*.o' -o -name '*.pio' \) -follow -exec rm \{\} \;
|
---|
[0e4ab80] | 129 |
|
---|
[29a9f62] | 130 | depend: kerninc
|
---|
[fcd7053] | 131 | -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
|
---|
[1ea99cc] | 132 | -makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(ARCH_SOURCES) $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
|
---|
[3eddaff] | 133 |
|
---|
[1ea99cc] | 134 | libc.a: depend $(OBJECTS)
|
---|
| 135 | $(AR) rc $@ $(LIBS) $(OBJECTS)
|
---|
| 136 |
|
---|
| 137 | libc.pic.a: depend $(PIC_OBJECTS)
|
---|
| 138 | $(AR) rc $@ $(LIBS) $(PIC_OBJECTS)
|
---|
[3eddaff] | 139 |
|
---|
[fcd7053] | 140 | arch/$(UARCH)/_link.ld: arch/$(UARCH)/_link.ld.in
|
---|
[b006bfb8] | 141 | $(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
|
---|
[25b0e6a] | 142 |
|
---|
[0e4ab80] | 143 | %.o: %.S
|
---|
| 144 | $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
|
---|
[3eddaff] | 145 |
|
---|
| 146 | %.o: %.s
|
---|
[0e4ab80] | 147 | $(AS) $(AFLAGS) $< -o $@
|
---|
[3eddaff] | 148 |
|
---|
| 149 | %.o: %.c
|
---|
[0e4ab80] | 150 | $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
|
---|
[1ea99cc] | 151 |
|
---|
| 152 | %.pio: %.S
|
---|
| 153 | $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
|
---|
| 154 |
|
---|
| 155 | %.pio: %.s
|
---|
| 156 | $(AS) $(AFLAGS) $< -o $@
|
---|
| 157 |
|
---|
| 158 | %.pio: %.c
|
---|
| 159 | $(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
|
---|