[2d2b8e6] | 1 | #
|
---|
| 2 | # Copyright (c) 2011 Petr Koupy
|
---|
| 3 | # Copyright (c) 2011 Jiri Zarevucky
|
---|
| 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 | LIBRARY = libposix
|
---|
[965c250] | 32 |
|
---|
[a3da2b2] | 33 | EXTRA_CFLAGS = -Iinclude/
|
---|
| 34 |
|
---|
| 35 | INCLUDE_LIBC = ./include/libc
|
---|
[965c250] | 36 |
|
---|
[2660ee3] | 37 | SPECS = gcc.specs
|
---|
[fc0b2a8] | 38 | LIBC_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
|
---|
| 39 | LIBC_STARTUP_FILE = $(shell sed -n -e 's/^.*STARTUP(\(.*\)).*$$/\1/p' $(LIBC_LINKER_SCRIPT))
|
---|
| 40 | EXPORT_LINKER_SCRIPT = link.ld
|
---|
[2660ee3] | 41 | EXPORT_STARTUP_FILE = crt0.o
|
---|
| 42 |
|
---|
| 43 | EXPORT_FILES = \
|
---|
| 44 | ../math/libmath.a \
|
---|
| 45 | ../clui/libclui.a \
|
---|
[ba3841e2] | 46 | $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a \
|
---|
| 47 | $(LIBSOFTINT_PREFIX)/libsoftint.a \
|
---|
| 48 | $(LIBC_PREFIX)/libc.a \
|
---|
| 49 | $(LIBRARY).a \
|
---|
[2660ee3] | 50 | $(EXPORT_STARTUP_FILE) \
|
---|
[fc0b2a8] | 51 | $(EXPORT_LINKER_SCRIPT) \
|
---|
[2660ee3] | 52 | $(SPECS)
|
---|
| 53 |
|
---|
[c773adc] | 54 | PRE_DEPEND = $(INCLUDE_LIBC)
|
---|
[ba3841e2] | 55 | EXTRA_CLEAN = $(INCLUDE_LIBC)
|
---|
[3a37751] | 56 |
|
---|
[fc0b2a8] | 57 | EXTRA_OUTPUT = $(SPECS) $(EXPORT_LINKER_SCRIPT) $(EXPORT_STARTUP_FILE)
|
---|
[2d2b8e6] | 58 |
|
---|
| 59 | SOURCES = \
|
---|
[df2e5514] | 60 | src/ctype.c \
|
---|
| 61 | src/dlfcn.c \
|
---|
| 62 | src/fcntl.c \
|
---|
| 63 | src/fnmatch.c \
|
---|
| 64 | src/locale.c \
|
---|
| 65 | src/pthread/condvar.c \
|
---|
| 66 | src/pthread/keys.c \
|
---|
| 67 | src/pthread/mutex.c \
|
---|
| 68 | src/pthread/threads.c \
|
---|
| 69 | src/pwd.c \
|
---|
| 70 | src/signal.c \
|
---|
| 71 | src/stdio.c \
|
---|
| 72 | src/stdlib.c \
|
---|
| 73 | src/stdlib/strtold.c \
|
---|
| 74 | src/string.c \
|
---|
| 75 | src/strings.c \
|
---|
| 76 | src/sys/mman.c \
|
---|
| 77 | src/sys/stat.c \
|
---|
| 78 | src/sys/wait.c \
|
---|
| 79 | src/time.c \
|
---|
| 80 | src/unistd.c
|
---|
[2d2b8e6] | 81 |
|
---|
[eeb23f2d] | 82 | TEST_SOURCES = \
|
---|
| 83 | test/main.c \
|
---|
[4e6a610] | 84 | test/stdio.c \
|
---|
| 85 | test/stdlib.c \
|
---|
| 86 | test/unistd.c
|
---|
| 87 |
|
---|
| 88 | EXTRA_TEST_CFLAGS = -Wno-deprecated-declarations
|
---|
[eeb23f2d] | 89 |
|
---|
[2660ee3] | 90 | EXPORT_CPPFLAGS = \
|
---|
| 91 | -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs \
|
---|
| 92 | -isystem $$(HELENOS_EXPORT_ROOT)/include
|
---|
| 93 |
|
---|
| 94 | EXPORT_LDFLAGS = \
|
---|
[fc0b2a8] | 95 | -L$$(HELENOS_EXPORT_ROOT)/lib \
|
---|
| 96 | -T link.ld
|
---|
[2660ee3] | 97 |
|
---|
[ea42e44] | 98 | EXPORT_LDLIBS = \
|
---|
[363fe7e] | 99 | -Wl,--start-group -lposix -lmath -lc -lsoftfloat -lsoftint -Wl,--end-group
|
---|
[ea42e44] | 100 |
|
---|
[2660ee3] | 101 | EXPORT_CFLAGS = \
|
---|
[ea42e44] | 102 | -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs
|
---|
[2660ee3] | 103 |
|
---|
[2d2b8e6] | 104 | include $(USPACE_PREFIX)/Makefile.common
|
---|
| 105 |
|
---|
[2660ee3] | 106 | $(SPECS): $(CONFIG_MAKEFILE)
|
---|
| 107 | echo '*self_spec:' > $@.new
|
---|
| 108 | echo '+ $(COMMON_CFLAGS)' >> $@.new
|
---|
| 109 | echo >> $@.new
|
---|
[ea42e44] | 110 | echo '*cpp:' >> $@.new
|
---|
| 111 | echo '+ $(COMMON_CPPFLAGS)' >> $@.new
|
---|
[2660ee3] | 112 | echo >> $@.new
|
---|
[ea42e44] | 113 | echo '*lib:' >> $@.new
|
---|
| 114 | echo '$(EXPORT_LDLIBS)' >> $@.new
|
---|
[2660ee3] | 115 | mv $@.new $@
|
---|
| 116 |
|
---|
[fc0b2a8] | 117 | $(EXPORT_LINKER_SCRIPT): $(LIBC_LINKER_SCRIPT)
|
---|
| 118 | sed 's/STARTUP(.*)/STARTUP(crt0.o)/' $< > $@
|
---|
| 119 |
|
---|
[2660ee3] | 120 | $(EXPORT_STARTUP_FILE): $(LIBC_STARTUP_FILE)
|
---|
| 121 | cp $< $@
|
---|
| 122 |
|
---|
| 123 | $(INCLUDE_LIBC): $(shell find ../c/include -name '*.h')
|
---|
| 124 | cp -r -L --remove-destination -T ../c/include $@
|
---|
| 125 | find ../c/include -type f -and -not -name '*.h' -delete
|
---|
| 126 |
|
---|
| 127 | export: $(EXPORT_DIR)/config.mk $(EXPORT_DIR)/config.rc
|
---|
| 128 |
|
---|
| 129 | $(EXPORT_DIR)/config.mk: export-libs export-includes
|
---|
| 130 | echo '# Generated file, do not modify.' >> $@.new
|
---|
| 131 | echo '# Do not forget to set HELENOS_EXPORT_ROOT.' >> $@.new
|
---|
[c39671d] | 132 | echo 'HELENOS_CROSS_PATH="$(shell dirname "$(CC)")"' >> $@.new
|
---|
[ea42e44] | 133 | echo 'HELENOS_ARCH="$(firstword $(subst -, ,$(TARGET)))"' >> $@.new
|
---|
[2660ee3] | 134 | echo 'HELENOS_TARGET="$(TARGET)"' >> $@.new
|
---|
| 135 | echo 'HELENOS_CPPFLAGS="$(EXPORT_CPPFLAGS)"' >> $@.new
|
---|
| 136 | echo 'HELENOS_CFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
|
---|
[ea42e44] | 137 | echo 'HELENOS_CXXFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
|
---|
[2660ee3] | 138 | echo 'HELENOS_LDFLAGS="$(EXPORT_LDFLAGS)"' >> $@.new
|
---|
[ea42e44] | 139 | echo 'HELENOS_LDLIBS="$(EXPORT_LDLIBS)"' >> $@.new
|
---|
[2660ee3] | 140 | mv $@.new $@
|
---|
| 141 |
|
---|
| 142 | $(EXPORT_DIR)/config.rc: $(EXPORT_DIR)/config.mk
|
---|
| 143 | sed 's:$$(HELENOS_EXPORT_ROOT):$$HELENOS_EXPORT_ROOT:g' < $< >$@
|
---|
| 144 |
|
---|
| 145 | export-libs: $(EXPORT_FILES) export-includes
|
---|
| 146 | mkdir -p $(EXPORT_DIR)/lib
|
---|
| 147 | cp -L $(EXPORT_FILES) $(EXPORT_DIR)/lib
|
---|
| 148 |
|
---|
| 149 | export-includes: $(INCLUDE_LIBC) $(shell find ./include ../c/arch/$(UARCH)/include $(ROOT_PATH)/abi/include -name '*.h')
|
---|
| 150 | mkdir -p $(EXPORT_DIR)/include
|
---|
| 151 | rm -rf $(EXPORT_DIR)/include.new
|
---|
| 152 | cp -r -L -T ./include/posix $(EXPORT_DIR)/include.new
|
---|
| 153 | cp -r -L -T ./include/libc $(EXPORT_DIR)/include.new/libc
|
---|
| 154 | cp -r -L ../c/arch/$(UARCH)/include/* $(EXPORT_DIR)/include.new/libc
|
---|
| 155 | cp -r -L $(ROOT_PATH)/abi/include/* $(EXPORT_DIR)/include.new
|
---|
| 156 | mkdir -p $(EXPORT_DIR)/include.new/libclui
|
---|
| 157 | cp -L ../clui/tinput.h $(EXPORT_DIR)/include.new/libclui
|
---|
[f1380b7] | 158 |
|
---|
[2660ee3] | 159 | find "$(EXPORT_DIR)/include.new/libc" "$(EXPORT_DIR)/include.new/libclui" -name '*.h' -exec sed \
|
---|
| 160 | -e 's:#include <:#include <libc/:' \
|
---|
| 161 | -e 's:#include <libc/abi/:#include <abi/:' \
|
---|
| 162 | -e 's:#include <libc/_bits/:#include <_bits/:' \
|
---|
| 163 | -e 's:#include <libc/libc/:#include <libc/:' \
|
---|
| 164 | -i {} \;
|
---|
| 165 | find "$(EXPORT_DIR)/include.new" -name '*.h' -exec sed \
|
---|
| 166 | -e 's:#include "posix/:#include ":' \
|
---|
| 167 | -e 's:#include <posix/:#include <:' \
|
---|
| 168 | -i {} \;
|
---|
[f1380b7] | 169 |
|
---|
[2660ee3] | 170 | rm -rf $(EXPORT_DIR)/include
|
---|
| 171 | mv $(EXPORT_DIR)/include.new $(EXPORT_DIR)/include
|
---|