| 1 | # | 
|---|
| 2 | # Copyright (c) 2005 Martin Decky | 
|---|
| 3 | # Copyright (c) 2007 Jakub Jermar | 
|---|
| 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 | # | 
|---|
| 29 |  | 
|---|
| 30 | USPACE_PREFIX = ../.. | 
|---|
| 31 | ROOT_PATH = $(USPACE_PREFIX)/.. | 
|---|
| 32 |  | 
|---|
| 33 | CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config | 
|---|
| 34 |  | 
|---|
| 35 | LINKER_SCRIPTS = \ | 
|---|
| 36 | $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld \ | 
|---|
| 37 | $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld \ | 
|---|
| 38 | $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld | 
|---|
| 39 |  | 
|---|
| 40 | PRE_DEPEND = | 
|---|
| 41 | EXTRA_OUTPUT = $(LINKER_SCRIPTS) | 
|---|
| 42 | EXTRA_CLEAN = $(LINKER_SCRIPTS) | 
|---|
| 43 | EXTRA_TEST_CFLAGS = -Wno-deprecated-declarations | 
|---|
| 44 | LIBRARY = libc | 
|---|
| 45 | SOVERSION = 0.0 | 
|---|
| 46 |  | 
|---|
| 47 | -include $(CONFIG_MAKEFILE) | 
|---|
| 48 | -include arch/$(UARCH)/Makefile.inc | 
|---|
| 49 |  | 
|---|
| 50 | GENERIC_SOURCES = \ | 
|---|
| 51 | generic/libc.c \ | 
|---|
| 52 | generic/ddi.c \ | 
|---|
| 53 | generic/as.c \ | 
|---|
| 54 | generic/bd.c \ | 
|---|
| 55 | generic/bd_srv.c \ | 
|---|
| 56 | generic/perm.c \ | 
|---|
| 57 | generic/cap.c \ | 
|---|
| 58 | generic/clipboard.c \ | 
|---|
| 59 | generic/config.c \ | 
|---|
| 60 | generic/context.c \ | 
|---|
| 61 | generic/corecfg.c \ | 
|---|
| 62 | generic/devman.c \ | 
|---|
| 63 | generic/device/hw_res.c \ | 
|---|
| 64 | generic/device/hw_res_parsed.c \ | 
|---|
| 65 | generic/device/pio_window.c \ | 
|---|
| 66 | generic/device/clock_dev.c \ | 
|---|
| 67 | generic/device/led_dev.c \ | 
|---|
| 68 | generic/dirent.c \ | 
|---|
| 69 | generic/dhcp.c \ | 
|---|
| 70 | generic/dnsr.c \ | 
|---|
| 71 | generic/dlfcn.c \ | 
|---|
| 72 | generic/elf/elf.c \ | 
|---|
| 73 | generic/elf/elf_load.c \ | 
|---|
| 74 | generic/elf/elf_mod.c \ | 
|---|
| 75 | generic/event.c \ | 
|---|
| 76 | generic/errno.c \ | 
|---|
| 77 | generic/gsort.c \ | 
|---|
| 78 | generic/loc.c \ | 
|---|
| 79 | generic/mem.c \ | 
|---|
| 80 | generic/str.c \ | 
|---|
| 81 | generic/str_error.c \ | 
|---|
| 82 | generic/strtol.c \ | 
|---|
| 83 | generic/l18n/langs.c \ | 
|---|
| 84 | generic/fibril.c \ | 
|---|
| 85 | generic/fibril_synch.c \ | 
|---|
| 86 | generic/pcb.c \ | 
|---|
| 87 | generic/smc.c \ | 
|---|
| 88 | generic/smp_memory_barrier.c \ | 
|---|
| 89 | generic/thread.c \ | 
|---|
| 90 | generic/tls.c \ | 
|---|
| 91 | generic/task.c \ | 
|---|
| 92 | generic/futex.c \ | 
|---|
| 93 | generic/imath.c \ | 
|---|
| 94 | generic/inet/addr.c \ | 
|---|
| 95 | generic/inet/endpoint.c \ | 
|---|
| 96 | generic/inet/host.c \ | 
|---|
| 97 | generic/inet/hostname.c \ | 
|---|
| 98 | generic/inet/hostport.c \ | 
|---|
| 99 | generic/inet/tcp.c \ | 
|---|
| 100 | generic/inet/udp.c \ | 
|---|
| 101 | generic/inet.c \ | 
|---|
| 102 | generic/inetcfg.c \ | 
|---|
| 103 | generic/inetping.c \ | 
|---|
| 104 | generic/io/asprintf.c \ | 
|---|
| 105 | generic/io/input.c \ | 
|---|
| 106 | generic/io/io.c \ | 
|---|
| 107 | generic/io/chardev.c \ | 
|---|
| 108 | generic/io/chardev_srv.c \ | 
|---|
| 109 | generic/io/chargrid.c \ | 
|---|
| 110 | generic/io/output.c \ | 
|---|
| 111 | generic/io/printf.c \ | 
|---|
| 112 | generic/io/log.c \ | 
|---|
| 113 | generic/io/logctl.c \ | 
|---|
| 114 | generic/io/label.c \ | 
|---|
| 115 | generic/io/kio.c \ | 
|---|
| 116 | generic/io/klog.c \ | 
|---|
| 117 | generic/io/serial.c \ | 
|---|
| 118 | generic/io/snprintf.c \ | 
|---|
| 119 | generic/io/vprintf.c \ | 
|---|
| 120 | generic/io/vsnprintf.c \ | 
|---|
| 121 | generic/io/printf_core.c \ | 
|---|
| 122 | generic/io/con_srv.c \ | 
|---|
| 123 | generic/io/console.c \ | 
|---|
| 124 | generic/io/table.c \ | 
|---|
| 125 | generic/io/visualizer.c \ | 
|---|
| 126 | generic/io/window.c \ | 
|---|
| 127 | generic/iplink.c \ | 
|---|
| 128 | generic/iplink_srv.c \ | 
|---|
| 129 | generic/irc.c \ | 
|---|
| 130 | generic/irq.c \ | 
|---|
| 131 | generic/ieee_double.c \ | 
|---|
| 132 | generic/power_of_ten.c \ | 
|---|
| 133 | generic/double_to_str.c \ | 
|---|
| 134 | generic/malloc.c \ | 
|---|
| 135 | generic/stdio/scanf.c \ | 
|---|
| 136 | generic/stdio/sprintf.c \ | 
|---|
| 137 | generic/stdio/sscanf.c \ | 
|---|
| 138 | generic/stdio/sstream.c \ | 
|---|
| 139 | generic/stdio/vsprintf.c \ | 
|---|
| 140 | generic/sysinfo.c \ | 
|---|
| 141 | generic/ipc.c \ | 
|---|
| 142 | generic/ns.c \ | 
|---|
| 143 | generic/async/client.c \ | 
|---|
| 144 | generic/async/server.c \ | 
|---|
| 145 | generic/async/ports.c \ | 
|---|
| 146 | generic/loader.c \ | 
|---|
| 147 | generic/getopt.c \ | 
|---|
| 148 | generic/adt/checksum.c \ | 
|---|
| 149 | generic/adt/circ_buf.c \ | 
|---|
| 150 | generic/adt/list.c \ | 
|---|
| 151 | generic/adt/hash_table.c \ | 
|---|
| 152 | generic/adt/odict.c \ | 
|---|
| 153 | generic/adt/prodcons.c \ | 
|---|
| 154 | generic/time.c \ | 
|---|
| 155 | generic/tmpfile.c \ | 
|---|
| 156 | generic/stdio.c \ | 
|---|
| 157 | generic/stdlib.c \ | 
|---|
| 158 | generic/udebug.c \ | 
|---|
| 159 | generic/vfs/canonify.c \ | 
|---|
| 160 | generic/vfs/inbox.c \ | 
|---|
| 161 | generic/vfs/mtab.c \ | 
|---|
| 162 | generic/vfs/vfs.c \ | 
|---|
| 163 | generic/rcu.c \ | 
|---|
| 164 | generic/setjmp.c \ | 
|---|
| 165 | generic/stack.c \ | 
|---|
| 166 | generic/stacktrace.c \ | 
|---|
| 167 | generic/arg_parse.c \ | 
|---|
| 168 | generic/stats.c \ | 
|---|
| 169 | generic/assert.c \ | 
|---|
| 170 | generic/bsearch.c \ | 
|---|
| 171 | generic/pio_trace.c \ | 
|---|
| 172 | generic/qsort.c \ | 
|---|
| 173 | generic/ubsan.c \ | 
|---|
| 174 | generic/uuid.c \ | 
|---|
| 175 | generic/vbd.c \ | 
|---|
| 176 | generic/vol.c | 
|---|
| 177 |  | 
|---|
| 178 | ifeq ($(CONFIG_RTLD),y) | 
|---|
| 179 | GENERIC_SOURCES += \ | 
|---|
| 180 | generic/rtld/rtld.c \ | 
|---|
| 181 | generic/rtld/dynamic.c \ | 
|---|
| 182 | generic/rtld/module.c \ | 
|---|
| 183 | generic/rtld/symbol.c | 
|---|
| 184 | endif | 
|---|
| 185 |  | 
|---|
| 186 | ARCH_SOURCES += $(ARCH_AUTOCHECK_HEADERS:%.h=%.check.c) | 
|---|
| 187 |  | 
|---|
| 188 | SOURCES = \ | 
|---|
| 189 | $(GENERIC_SOURCES) \ | 
|---|
| 190 | $(ARCH_SOURCES) | 
|---|
| 191 |  | 
|---|
| 192 | TEST_SOURCES = \ | 
|---|
| 193 | test/adt/circ_buf.c \ | 
|---|
| 194 | test/fibril/timer.c \ | 
|---|
| 195 | test/main.c \ | 
|---|
| 196 | test/mem.c \ | 
|---|
| 197 | test/io/table.c \ | 
|---|
| 198 | test/stdio/scanf.c \ | 
|---|
| 199 | test/odict.c \ | 
|---|
| 200 | test/qsort.c \ | 
|---|
| 201 | test/sprintf.c \ | 
|---|
| 202 | test/stdio.c \ | 
|---|
| 203 | test/stdlib.c \ | 
|---|
| 204 | test/str.c | 
|---|
| 205 |  | 
|---|
| 206 | include $(USPACE_PREFIX)/Makefile.common | 
|---|
| 207 |  | 
|---|
| 208 | $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in | 
|---|
| 209 | $(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@ | 
|---|
| 210 |  | 
|---|
| 211 | $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in | 
|---|
| 212 | $(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DSHLIB -E -x c $< | grep -v "^\#" > $@ | 
|---|
| 213 |  | 
|---|
| 214 | $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in | 
|---|
| 215 | $(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DDLEXE -E -x c $< | grep -v "^\#" > $@ | 
|---|
| 216 |  | 
|---|
| 217 | AUTOCHECK = $(realpath $(ROOT_PATH)/tools/autocheck.awk) | 
|---|
| 218 |  | 
|---|
| 219 | %.check.c: %.h $(AUTOCHECK) | 
|---|
| 220 | cd $(<D) && $(AUTOCHECK) $(<F) > $(@F) | 
|---|