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