source: mainline/uspace/lib/posix/Makefile@ 66262a1b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 66262a1b was 66262a1b, checked in by Jiří Zárevúcky <jiri.zarevucky@…>, 7 years ago

Don't use custom ldscripts in uspace.

Even with the *-linux-gnu targets, there is practically nothing Linux-specific
in the linker itself. We get a few GNU program headers this way, but those
can be safely ignored.

  • 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
38LIBC_STARTUP_FILE = $(STARTUP_OBJECT)
39EXPORT_STARTUP_FILE = crt0.o
40
41EXPORT_FILES = \
42 ../math/libmath.a \
43 ../clui/libclui.a \
44 $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a \
45 $(LIBSOFTINT_PREFIX)/libsoftint.a \
46 $(LIBC_PREFIX)/libc.a \
47 $(LIBRARY).a \
48 $(EXPORT_STARTUP_FILE) \
49 $(SPECS)
50
51PRE_DEPEND = $(INCLUDE_LIBC)
52EXTRA_CLEAN = $(INCLUDE_LIBC)
53
54EXTRA_OUTPUT = $(SPECS) $(EXPORT_STARTUP_FILE)
55
56SOURCES = \
57 src/ctype.c \
58 src/dlfcn.c \
59 src/fcntl.c \
60 src/fnmatch.c \
61 src/locale.c \
62 src/pthread/condvar.c \
63 src/pthread/keys.c \
64 src/pthread/mutex.c \
65 src/pthread/threads.c \
66 src/pwd.c \
67 src/signal.c \
68 src/stdio.c \
69 src/stdio/scanf.c \
70 src/stdlib.c \
71 src/stdlib/strtold.c \
72 src/string.c \
73 src/strings.c \
74 src/sys/mman.c \
75 src/sys/stat.c \
76 src/sys/wait.c \
77 src/time.c \
78 src/unistd.c
79
80TEST_SOURCES = \
81 test/main.c \
82 test/scanf.c
83
84EXPORT_CPPFLAGS = \
85 -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs \
86 -isystem $$(HELENOS_EXPORT_ROOT)/include
87
88EXPORT_LDFLAGS = \
89 -L$$(HELENOS_EXPORT_ROOT)/lib
90
91EXPORT_LDLIBS = \
92 -Wl,--start-group -lposix -lmath -lc -lsoftfloat -lsoftint -Wl,--end-group
93
94EXPORT_CFLAGS = \
95 -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs
96
97include $(USPACE_PREFIX)/Makefile.common
98
99$(SPECS): $(CONFIG_MAKEFILE)
100 echo '*self_spec:' > $@.new
101 echo '+ $(COMMON_CFLAGS)' >> $@.new
102 echo >> $@.new
103 echo '*cpp:' >> $@.new
104 echo '+ $(COMMON_CPPFLAGS)' >> $@.new
105 echo >> $@.new
106 echo '*lib:' >> $@.new
107 echo '$(EXPORT_LDLIBS)' >> $@.new
108 mv $@.new $@
109
110$(EXPORT_STARTUP_FILE): $(LIBC_STARTUP_FILE)
111 cp $< $@
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 "$(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.