| 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
|
|---|
| 32 |
|
|---|
| 33 | EXTRA_CFLAGS = -Iinclude/posix -D_XOPEN_SOURCE
|
|---|
| 34 |
|
|---|
| 35 | EXPORT_FILES = \
|
|---|
| 36 | ../math/libmath.a \
|
|---|
| 37 | ../clui/libclui.a \
|
|---|
| 38 | ../gui/libgui.a \
|
|---|
| 39 | ../draw/libdraw.a \
|
|---|
| 40 | ../softrend/libsoftrend.a \
|
|---|
| 41 | ../hound/libhound.a \
|
|---|
| 42 | ../pcm/libpcm.a \
|
|---|
| 43 | ../cpp/libcpp.a \
|
|---|
| 44 | $(LIBC_PREFIX)/libc.a \
|
|---|
| 45 | $(LIBC_PREFIX)/crt0.o \
|
|---|
| 46 | $(LIBC_PREFIX)/crt1.o \
|
|---|
| 47 | $(LIBRARY).a
|
|---|
| 48 |
|
|---|
| 49 | SOURCES = \
|
|---|
| 50 | src/ctype.c \
|
|---|
| 51 | src/dlfcn.c \
|
|---|
| 52 | src/fcntl.c \
|
|---|
| 53 | src/fnmatch.c \
|
|---|
| 54 | src/locale.c \
|
|---|
| 55 | src/pthread/condvar.c \
|
|---|
| 56 | src/pthread/keys.c \
|
|---|
| 57 | src/pthread/mutex.c \
|
|---|
| 58 | src/pthread/threads.c \
|
|---|
| 59 | src/pwd.c \
|
|---|
| 60 | src/signal.c \
|
|---|
| 61 | src/stdio.c \
|
|---|
| 62 | src/stdlib.c \
|
|---|
| 63 | src/string.c \
|
|---|
| 64 | src/strings.c \
|
|---|
| 65 | src/sys/mman.c \
|
|---|
| 66 | src/sys/stat.c \
|
|---|
| 67 | src/sys/wait.c \
|
|---|
| 68 | src/time.c \
|
|---|
| 69 | src/unistd.c
|
|---|
| 70 |
|
|---|
| 71 | TEST_SOURCES = \
|
|---|
| 72 | test/main.c \
|
|---|
| 73 | test/stdio.c \
|
|---|
| 74 | test/stdlib.c \
|
|---|
| 75 | test/unistd.c
|
|---|
| 76 |
|
|---|
| 77 | EXTRA_TEST_CFLAGS = -Wno-deprecated-declarations
|
|---|
| 78 |
|
|---|
| 79 | EXPORT_CPPFLAGS = \
|
|---|
| 80 | -isystem $$(HELENOS_EXPORT_ROOT)/include/posix \
|
|---|
| 81 | -isystem $$(HELENOS_EXPORT_ROOT)/include/libc \
|
|---|
| 82 | -idirafter $$(HELENOS_EXPORT_ROOT)/include \
|
|---|
| 83 | $(COMMON_CPPFLAGS)
|
|---|
| 84 |
|
|---|
| 85 | EXPORT_LDFLAGS = \
|
|---|
| 86 | -L$$(HELENOS_EXPORT_ROOT)/lib \
|
|---|
| 87 | $$(HELENOS_EXPORT_ROOT)/lib/crt0.o \
|
|---|
| 88 | $$(HELENOS_EXPORT_ROOT)/lib/crt1.o
|
|---|
| 89 |
|
|---|
| 90 | EXPORT_LDLIBS = \
|
|---|
| 91 | -Wl,--start-group -lposix -lmath -lc -lgcc -Wl,--end-group
|
|---|
| 92 |
|
|---|
| 93 | EXPORT_CFLAGS = \
|
|---|
| 94 | $(COMMON_CFLAGS)
|
|---|
| 95 |
|
|---|
| 96 | EXPORT_CXXFLAGS = \
|
|---|
| 97 | $(COMMON_CXXFLAGS)
|
|---|
| 98 |
|
|---|
| 99 | include $(USPACE_PREFIX)/Makefile.common
|
|---|
| 100 |
|
|---|
| 101 | export: $(EXPORT_DIR)/config.mk $(EXPORT_DIR)/config.rc \
|
|---|
| 102 | $(EXPORT_DIR)/Makefile.common $(EXPORT_DIR)/Makefile.config
|
|---|
| 103 |
|
|---|
| 104 | $(EXPORT_DIR)/config.mk: export-libs export-includes
|
|---|
| 105 | echo '# Generated file, do not modify.' >> $@.new
|
|---|
| 106 | echo '# Do not forget to set HELENOS_EXPORT_ROOT.' >> $@.new
|
|---|
| 107 | echo 'HELENOS_CROSS_PATH="$(shell dirname `which $(CC)`)"' >> $@.new
|
|---|
| 108 | echo 'HELENOS_ARCH="$(firstword $(subst -, ,$(TARGET)))"' >> $@.new
|
|---|
| 109 | echo 'HELENOS_TARGET="$(TARGET)"' >> $@.new
|
|---|
| 110 | echo 'HELENOS_CPPFLAGS="$(EXPORT_CPPFLAGS)"' >> $@.new
|
|---|
| 111 | echo 'HELENOS_CFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
|
|---|
| 112 | echo 'HELENOS_CXXFLAGS="$(EXPORT_CXXFLAGS)"' >> $@.new
|
|---|
| 113 | echo 'HELENOS_LDFLAGS="$(EXPORT_LDFLAGS)"' >> $@.new
|
|---|
| 114 | echo 'HELENOS_LDLIBS="$(EXPORT_LDLIBS)"' >> $@.new
|
|---|
| 115 | mv $@.new $@
|
|---|
| 116 |
|
|---|
| 117 | $(EXPORT_DIR)/config.rc: $(EXPORT_DIR)/config.mk
|
|---|
| 118 | sed 's:$$(HELENOS_EXPORT_ROOT):$$HELENOS_EXPORT_ROOT:g' < $< >$@
|
|---|
| 119 |
|
|---|
| 120 | $(EXPORT_DIR)/Makefile.common: ../../../Makefile.common
|
|---|
| 121 | cp $< $@
|
|---|
| 122 |
|
|---|
| 123 | $(EXPORT_DIR)/Makefile.config: ../../../Makefile.config
|
|---|
| 124 | cp $< $@
|
|---|
| 125 |
|
|---|
| 126 | export-libs: $(EXPORT_FILES) export-includes
|
|---|
| 127 | mkdir -p $(EXPORT_DIR)/lib
|
|---|
| 128 | cp -L $(EXPORT_FILES) $(EXPORT_DIR)/lib
|
|---|
| 129 |
|
|---|
| 130 | export-includes: $(shell find ./include ../c/arch/$(UARCH)/include $(ROOT_PATH)/abi/include -name '*.h')
|
|---|
| 131 | mkdir -p $(EXPORT_DIR)/include
|
|---|
| 132 | rm -rf $(EXPORT_DIR)/include.new
|
|---|
| 133 | cp -r -L -T ./include $(EXPORT_DIR)/include.new
|
|---|
| 134 | cp -r -L ../c/arch/$(UARCH)/include/libarch $(EXPORT_DIR)/include.new/libc
|
|---|
| 135 | cp -r -L $(ROOT_PATH)/abi/include/* $(EXPORT_DIR)/include.new
|
|---|
| 136 | mkdir -p $(EXPORT_DIR)/include.new/libclui
|
|---|
| 137 | cp -L ../clui/tinput.h $(EXPORT_DIR)/include.new/libclui
|
|---|
| 138 | rm -rf $(EXPORT_DIR)/include
|
|---|
| 139 | mkdir -p $(EXPORT_DIR)/include.new/libdraw
|
|---|
| 140 | cp -r -L -t $(EXPORT_DIR)/include.new/libdraw ../draw/include/*
|
|---|
| 141 | mkdir -p $(EXPORT_DIR)/include.new/libgui
|
|---|
| 142 | cp -L -t $(EXPORT_DIR)/include.new/libgui ../gui/*.h
|
|---|
| 143 | mkdir -p $(EXPORT_DIR)/include.new/libhound
|
|---|
| 144 | cp -r -L -t $(EXPORT_DIR)/include.new/libhound ../hound/include/*
|
|---|
| 145 | mkdir -p $(EXPORT_DIR)/include.new/libpcm
|
|---|
| 146 | cp -r -L -t $(EXPORT_DIR)/include.new/libpcm ../pcm/include/*
|
|---|
| 147 | mkdir -p $(EXPORT_DIR)/include.new/libcpp
|
|---|
| 148 | cp -r -L -t $(EXPORT_DIR)/include.new/libcpp ../cpp/include/*
|
|---|
| 149 | mv $(EXPORT_DIR)/include.new $(EXPORT_DIR)/include
|
|---|