source: mainline/uspace/lib/posix/Makefile@ bbe5e34

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since bbe5e34 was bbe5e34, checked in by GitHub <noreply@…>, 7 years ago

Switch completely to HelenOS-specific toolchain target (#44)

As previously discussed, utilizing the compiler-provided headers and libraries would
allow us to avoid a number of problems and reduce the amount of architecture-support
code that we have to implement ourselves. With this change, the support for using
Linux-targeted toolchain, or even the host toolchain itself, is removed, due to the
inherent issues caused by such setup.

Additionally, the toolchain installation is a bit simplified to install all targets into a single
prefix. This prefix can be added to the PATH so that one can simply execute
e.g. amd64-helenos-gcc instead of needing to use the whole path.

  • Property mode set to 100644
File size: 5.1 KB
Line 
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
30USPACE_PREFIX = ../..
31LIBRARY = libposix
32
33EXTRA_CFLAGS = -Iinclude/
34
35INCLUDE_LIBC = ./include/libc
36
37SPECS = gcc.specs
38
39EXPORT_FILES = \
40 ../math/libmath.a \
41 ../clui/libclui.a \
42 $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a \
43 $(LIBSOFTINT_PREFIX)/libsoftint.a \
44 $(LIBC_PREFIX)/libc.a \
45 $(LIBC_PREFIX)/crt0.o \
46 $(LIBC_PREFIX)/crt1.o \
47 $(LIBRARY).a \
48 $(SPECS)
49
50PRE_DEPEND = $(INCLUDE_LIBC)
51EXTRA_CLEAN = $(INCLUDE_LIBC)
52
53EXTRA_OUTPUT = $(SPECS)
54
55SOURCES = \
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
76
77TEST_SOURCES = \
78 test/main.c \
79 test/stdio.c \
80 test/stdlib.c \
81 test/unistd.c
82
83EXTRA_TEST_CFLAGS = -Wno-deprecated-declarations
84
85EXPORT_CPPFLAGS = \
86 -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs \
87 -isystem $$(HELENOS_EXPORT_ROOT)/include
88
89EXPORT_LDFLAGS = \
90 -L$$(HELENOS_EXPORT_ROOT)/lib \
91 $$(HELENOS_EXPORT_ROOT)/lib/crt0.o \
92 $$(HELENOS_EXPORT_ROOT)/lib/crt1.o
93
94EXPORT_LDLIBS = \
95 -Wl,--start-group -lposix -lmath -lc -lsoftfloat -lsoftint -Wl,--end-group
96
97EXPORT_CFLAGS = \
98 -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs
99
100include $(USPACE_PREFIX)/Makefile.common
101
102$(SPECS): $(CONFIG_MAKEFILE)
103 echo '*self_spec:' > $@.new
104 echo '+ $(COMMON_CFLAGS)' >> $@.new
105 echo >> $@.new
106 echo '*cpp:' >> $@.new
107 echo '+ $(COMMON_CPPFLAGS)' >> $@.new
108 echo >> $@.new
109 echo '*lib:' >> $@.new
110 echo '$(EXPORT_LDLIBS)' >> $@.new
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
117export: $(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
122 echo 'HELENOS_CROSS_PATH="$(shell dirname `which "$(CC)"`)"' >> $@.new
123 echo 'HELENOS_ARCH="$(firstword $(subst -, ,$(TARGET)))"' >> $@.new
124 echo 'HELENOS_TARGET="$(TARGET)"' >> $@.new
125 echo 'HELENOS_CPPFLAGS="$(EXPORT_CPPFLAGS)"' >> $@.new
126 echo 'HELENOS_CFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
127 echo 'HELENOS_CXXFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
128 echo 'HELENOS_LDFLAGS="$(EXPORT_LDFLAGS)"' >> $@.new
129 echo 'HELENOS_LDLIBS="$(EXPORT_LDLIBS)"' >> $@.new
130 mv $@.new $@
131
132$(EXPORT_DIR)/config.rc: $(EXPORT_DIR)/config.mk
133 sed 's:$$(HELENOS_EXPORT_ROOT):$$HELENOS_EXPORT_ROOT:g' < $< >$@
134
135export-libs: $(EXPORT_FILES) export-includes
136 mkdir -p $(EXPORT_DIR)/lib
137 cp -L $(EXPORT_FILES) $(EXPORT_DIR)/lib
138
139export-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
148
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 {} \;
159
160 rm -rf $(EXPORT_DIR)/include
161 mv $(EXPORT_DIR)/include.new $(EXPORT_DIR)/include
Note: See TracBrowser for help on using the repository browser.