source: mainline/uspace/lib/posix/Makefile@ 99d3123

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

Remove undefined references to main program from shared libc.

  • Property mode set to 100644
File size: 5.4 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_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
39EXPORT_LINKER_SCRIPT = link.ld
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 $(LIBC_PREFIX)/crt0.o \
48 $(LIBC_PREFIX)/crt1.o \
49 $(LIBRARY).a \
50 $(EXPORT_LINKER_SCRIPT) \
51 $(SPECS)
52
53PRE_DEPEND = $(INCLUDE_LIBC)
54EXTRA_CLEAN = $(INCLUDE_LIBC)
55
56EXTRA_OUTPUT = $(SPECS) $(EXPORT_LINKER_SCRIPT) $(EXPORT_STARTUP_FILE)
57
58SOURCES = \
59 src/ctype.c \
60 src/dlfcn.c \
61 src/fcntl.c \
62 src/fnmatch.c \
63 src/locale.c \
64 src/pthread/condvar.c \
65 src/pthread/keys.c \
66 src/pthread/mutex.c \
67 src/pthread/threads.c \
68 src/pwd.c \
69 src/signal.c \
70 src/stdio.c \
71 src/stdlib.c \
72 src/stdlib/strtold.c \
73 src/string.c \
74 src/strings.c \
75 src/sys/mman.c \
76 src/sys/stat.c \
77 src/sys/wait.c \
78 src/time.c \
79 src/unistd.c
80
81TEST_SOURCES = \
82 test/main.c \
83 test/stdio.c \
84 test/stdlib.c \
85 test/unistd.c
86
87EXTRA_TEST_CFLAGS = -Wno-deprecated-declarations
88
89EXPORT_CPPFLAGS = \
90 -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs \
91 -isystem $$(HELENOS_EXPORT_ROOT)/include
92
93EXPORT_LDFLAGS = \
94 -L$$(HELENOS_EXPORT_ROOT)/lib \
95 -T link.ld \
96 $$(HELENOS_EXPORT_ROOT)/lib/crt0.o \
97 $$(HELENOS_EXPORT_ROOT)/lib/crt1.o
98
99EXPORT_LDLIBS = \
100 -Wl,--start-group -lposix -lmath -lc -lsoftfloat -lsoftint -Wl,--end-group
101
102EXPORT_CFLAGS = \
103 -specs $$(HELENOS_EXPORT_ROOT)/lib/gcc.specs
104
105include $(USPACE_PREFIX)/Makefile.common
106
107$(SPECS): $(CONFIG_MAKEFILE)
108 echo '*self_spec:' > $@.new
109 echo '+ $(COMMON_CFLAGS)' >> $@.new
110 echo >> $@.new
111 echo '*cpp:' >> $@.new
112 echo '+ $(COMMON_CPPFLAGS)' >> $@.new
113 echo >> $@.new
114 echo '*lib:' >> $@.new
115 echo '$(EXPORT_LDLIBS)' >> $@.new
116 mv $@.new $@
117
118$(EXPORT_LINKER_SCRIPT): $(LIBC_LINKER_SCRIPT)
119 cp $< $@
120
121$(EXPORT_STARTUP_FILE): $(LIBC_STARTUP_FILE)
122 cp $< $@
123
124$(INCLUDE_LIBC): $(shell find ../c/include -name '*.h')
125 cp -r -L --remove-destination -T ../c/include $@
126 find ../c/include -type f -and -not -name '*.h' -delete
127
128export: $(EXPORT_DIR)/config.mk $(EXPORT_DIR)/config.rc
129
130$(EXPORT_DIR)/config.mk: export-libs export-includes
131 echo '# Generated file, do not modify.' >> $@.new
132 echo '# Do not forget to set HELENOS_EXPORT_ROOT.' >> $@.new
133 echo 'HELENOS_CROSS_PATH="$(shell dirname "$(CC)")"' >> $@.new
134 echo 'HELENOS_ARCH="$(firstword $(subst -, ,$(TARGET)))"' >> $@.new
135 echo 'HELENOS_TARGET="$(TARGET)"' >> $@.new
136 echo 'HELENOS_CPPFLAGS="$(EXPORT_CPPFLAGS)"' >> $@.new
137 echo 'HELENOS_CFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
138 echo 'HELENOS_CXXFLAGS="$(EXPORT_CFLAGS)"' >> $@.new
139 echo 'HELENOS_LDFLAGS="$(EXPORT_LDFLAGS)"' >> $@.new
140 echo 'HELENOS_LDLIBS="$(EXPORT_LDLIBS)"' >> $@.new
141 mv $@.new $@
142
143$(EXPORT_DIR)/config.rc: $(EXPORT_DIR)/config.mk
144 sed 's:$$(HELENOS_EXPORT_ROOT):$$HELENOS_EXPORT_ROOT:g' < $< >$@
145
146export-libs: $(EXPORT_FILES) export-includes
147 mkdir -p $(EXPORT_DIR)/lib
148 cp -L $(EXPORT_FILES) $(EXPORT_DIR)/lib
149
150export-includes: $(INCLUDE_LIBC) $(shell find ./include ../c/arch/$(UARCH)/include $(ROOT_PATH)/abi/include -name '*.h')
151 mkdir -p $(EXPORT_DIR)/include
152 rm -rf $(EXPORT_DIR)/include.new
153 cp -r -L -T ./include/posix $(EXPORT_DIR)/include.new
154 cp -r -L -T ./include/libc $(EXPORT_DIR)/include.new/libc
155 cp -r -L ../c/arch/$(UARCH)/include/* $(EXPORT_DIR)/include.new/libc
156 cp -r -L $(ROOT_PATH)/abi/include/* $(EXPORT_DIR)/include.new
157 mkdir -p $(EXPORT_DIR)/include.new/libclui
158 cp -L ../clui/tinput.h $(EXPORT_DIR)/include.new/libclui
159
160 find "$(EXPORT_DIR)/include.new/libc" "$(EXPORT_DIR)/include.new/libclui" -name '*.h' -exec sed \
161 -e 's:#include <:#include <libc/:' \
162 -e 's:#include <libc/abi/:#include <abi/:' \
163 -e 's:#include <libc/_bits/:#include <_bits/:' \
164 -e 's:#include <libc/libc/:#include <libc/:' \
165 -i {} \;
166 find "$(EXPORT_DIR)/include.new" -name '*.h' -exec sed \
167 -e 's:#include "posix/:#include ":' \
168 -e 's:#include <posix/:#include <:' \
169 -i {} \;
170
171 rm -rf $(EXPORT_DIR)/include
172 mv $(EXPORT_DIR)/include.new $(EXPORT_DIR)/include
Note: See TracBrowser for help on using the repository browser.