Remove building with NOCRYPTO option
[minix.git] / tools / gcc / mknative-gcc
blob35f6d123ce05cdfd5c7a8ff57ce53a0018458a6a
1 #!/bin/sh
2 # $NetBSD: mknative-gcc,v 1.81 2015/01/31 08:50:01 mrg Exp $
4 # Shell script for generating all the constants needed for a native
5 # platform build of gcc.
8 # initialise
10 _TMPDIR=$2
11 _TOP=$3
12 _SRC=$4
13 _PLATFORM=$5
14 _DESTDIR=$6
15 _TOOLDIR=$7
16 _VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
17 _GNU_DIST=`cd ${_VPATH}; pwd`
19 if [ -z "$_DESTDIR" ]; then
20 echo "\$_DESTDIR is empty" 2>&1
21 exit 1
24 . $_TOP/tools/gcc/mknative.common
26 # default to GCC 4.1 for now
27 _OUTDIR="$_TOP/gnu"
28 _OUTDIRBASE="gnu"
30 sanitise_includes () {
31 sed \
32 -e "s,-I$_DESTDIR/usr/include,,g" \
33 -e "s,-I$_SRC/external/lgpl3/mpfr/dist/src,,g" \
34 -e "s,-I$_SRC/external/lgpl3/mpc/dist/src,,g" \
35 -e "s,-I$_SRC/external/lgpl3/gmp/lib/libgmp/arch/[a-z_0-9-]*,,g" \
36 -e "s,-I$_TOOLDIR/include,,g" \
37 -e "s,-I/usr/include/[^ ]*,,"
40 ##### lib/crtstuff #####
42 get_crtstuff () {
43 _subdir="$1"
44 mkdir -p $_OUTDIR/lib/$_subdir/arch
46 getvars gcc/Makefile \
47 INCLUDES CRTSTUFF_CFLAGS CRTSTUFF_T_CFLAGS CRTSTUFF_T_CFLAGS_S \
48 tm_defines xm_file xm_defines \
49 | sanitise_includes \
50 | write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH.mk
53 ##### lib/libg2c #####
55 get_libg2c () {
56 mkdir -p $_OUTDIR/lib/libg2c3/arch/$MACHINE_ARCH
58 write_c $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/config.h <$_TMPDIR/$_PLATFORM/libf2c/libU77/config.h
59 write_c $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/g2c.h <$_TMPDIR/$_PLATFORM/libf2c/g2c.h
62 getvars $_PLATFORM/libf2c/Makefile \
63 F2CEXT
64 getvars $_PLATFORM/libf2c/libF77/Makefile \
65 ALL_CFLAGS OBJS
66 getvars $_PLATFORM/libf2c/libI77/Makefile \
67 ALL_CFLAGS OBJS | sed 's,=,+=,'
68 getvars $_PLATFORM/libf2c/libU77/Makefile \
69 ALL_CFLAGS OBJS | sed 's,=,+=,'
70 } | write_mk $_OUTDIRBASE/lib/libg2c3/arch/$MACHINE_ARCH/defs.mk
73 ##### lib/libgcc #####
75 get_libgcc () {
76 _subdir="$1"
77 mkdir -p $_OUTDIR/lib/lib$_subdir/arch
79 # DPBIT, FPBIT only used on mn10[23]00, we don't need them.
80 # XXX we should probably grab everything Just In Case for
81 # the future.
83 mkdir -p $_OUTDIR/lib/lib$_subdir/arch/$MACHINE_ARCH
84 cd $_TMPDIR/$_PLATFORM/libgcc
86 getvars $_PLATFORM/libgcc/Makefile \
87 INCLUDES LIB2ADD LIB2ADDEH LIB2ADD_ST \
88 LIB1ASMFUNCS LIB1ASMSRC \
89 LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
90 LIB2FUNCS_EXTRA \
91 LIBGCC2_CFLAGS \
92 SHLIB_MKMAP SHLIB_MKMAP_OPTS \
93 SHLIB_MAPFILES SHLIB_NM_FLAGS
94 getvars gcc/Makefile \
95 NOEXCEPTION_FLAGS EXTRA_HEADERS
96 getlinks config.status libgcc
97 } | sanitise_includes \
98 | write_mk $_OUTDIRBASE/lib/lib$_subdir/arch/$MACHINE_ARCH/defs.mk
100 if [ "${MACHINE_ARCH}" = "m68000" ]
101 then
102 ex <<__EOF__ $_OUTDIR/lib/lib$_subdir/arch/$MACHINE_ARCH/defs.mk
103 /G_LIBGCC2_CFLAGS/ s/-fPIC//
105 __EOF__
108 for f in auto-target.h; do
109 write_c $_OUTDIRBASE/lib/lib$_subdir/arch/$MACHINE_ARCH/$f \
110 <$_TMPDIR/$_PLATFORM/libgcc/$f
111 done
114 ##### lib/libgcov #####
116 get_libgcov () {
117 _subdir="$1"
118 _mf="$2"
120 mkdir -p $_OUTDIR/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH
123 getvars $_mf \
124 LIBGCOV
125 } | write_mk $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/defs.mk
127 write_c $_OUTDIRBASE/lib/lib$_subdir/libgcov/arch/$MACHINE_ARCH/gcov-iov.h \
128 <$_TMPDIR/gcc/gcov-iov.h
132 ##### lib/libiberty #####
134 get_gcc_libiberty () {
135 _subdir="$1"
136 _libibertydir="lib/libiberty"
137 mkdir -p $_OUTDIR/$_libibertydir/arch/$MACHINE_ARCH
139 getvars libiberty/Makefile \
140 ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
141 | write_mk $_OUTDIRBASE/$_libibertydir/defs.mk
143 write_c $_OUTDIRBASE/$_libibertydir/arch/$MACHINE_ARCH/config.h \
144 <$_TMPDIR/libiberty/config.h
147 ##### lib/libdecnumber #####
149 get_libdecnumber () {
150 _subdir="$1"
152 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
153 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/config.h \
154 <$_TMPDIR/libdecnumber/config.h
157 ##### lib/libgomp #####
159 get_libgomp () {
160 _subdir="$1"
162 mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
163 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/config.h \
164 <$_TMPDIR/$_PLATFORM/libgomp/config.h
165 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/libgomp_f.h \
166 <$_TMPDIR/$_PLATFORM/libgomp/libgomp_f.h
167 write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/libgomp.spec \
168 <$_TMPDIR/$_PLATFORM/libgomp/libgomp.spec
169 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/omp.h \
170 <$_TMPDIR/$_PLATFORM/libgomp/omp.h
173 ##### lib/libbacktrace #####
175 get_libbacktrace () {
176 _subdir="$1"
178 mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
179 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/config.h \
180 <$_TMPDIR/$_subdir/config.h
181 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/backtrace-supported.h \
182 <$_TMPDIR/$_subdir/backtrace-supported.h
185 ##### lib/libobjc #####
187 get_libobjc () {
188 _subdir="$1/arch/$MACHINE_ARCH"
189 _options="ALL_OPT_FILES"
191 mkdir -p $_OUTDIR/lib/$_subdir
194 if [ -n "$_options" ]; then
195 getvars gcc/Makefile $_options
197 getvars $_PLATFORM/libobjc/Makefile \
198 ALL_CFLAGS INCLUDES OBJC_SOURCE_FILES C_SOURCE_FILES OBJC_H \
199 | sed "s,$_GNU_DIST,\${GNUHOSTDIST},g"
200 getlinks $_TMPDIR/$_PLATFORM/libgcc/config.status libgcc
201 } | sanitise_includes \
202 | write_mk $_OUTDIRBASE/lib/$_subdir/defs.mk
204 write_c $_OUTDIRBASE/lib/$_subdir/config.h \
205 <$_TMPDIR/$_PLATFORM/libobjc/config.h
208 ##### lib/libstdc++-v3 #####
210 get_libstdcxx_v3 () {
211 _subdir="$1"
212 _ver="$2"
214 mkdir -p $_OUTDIR/lib/$_subdir/arch/$MACHINE_ARCH
216 _build_headers="c++config.h cxxabi_tweaks.h gthr-posix.h gthr-single.h gthr.h"
217 _headers1="c_base_headers_extra_install"
218 _headers1="$_headers1 tr1_headers tr2_headers decimal_headers c_compatibility_headers_install"
219 _headers1="$_headers1 debug_headers parallel_headers"
220 _headers2="host_headers thread_host_headers"
221 _pf_headers="profile_headers profile_impl_headers"
222 _pb_headers="pb_headers1 pb_headers2 pb_headers3 pb_headers4 pb_headers5 pb_headers6 pb_headers7"
224 # build files
225 for h in $_build_headers; do
226 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/$h \
227 <$_TMPDIR/$_PLATFORM/libstdc++-v3/include/$_PLATFORM/bits/$h
228 done
230 write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/gstdint.h \
231 <$_TMPDIR/$_PLATFORM/libstdc++-v3/include/gstdint.h
234 # libsupc++
235 getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
236 sources | sed 's/^G_sources=/G_LIBSUPCXX_SOURCES=/'
237 getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
238 c_sources | sed 's/^G_c_sources=/G_LIBSUPCXX_C_SOURCES=/'
240 # includes
241 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
242 c_base_headers std_headers | sed -e 's#/[^ ][^ ]*/##g' -e 's/\${GNUHOSTDIST}//g'
244 # src
245 getvars $_PLATFORM/libstdc++-v3/src/Makefile \
246 libstdc___la_SOURCES | sed 's/^G_libstdc___la_SOURCES=/G_SRC_SOURCES=/'
247 getvars $_PLATFORM/libstdc++-v3/src/c++11/Makefile \
248 libc__11convenience_la_SOURCES | sed 's/^G_libc__11convenience_la_SOURCES=/G_CPP11_SOURCES=/'
249 getvars $_PLATFORM/libstdc++-v3/src/c++98/Makefile \
250 libc__98convenience_la_SOURCES | sed 's/^G_libc__98convenience_la_SOURCES=/G_CPP98_SOURCES=/'
251 getvars $_PLATFORM/libstdc++-v3/Makefile ATOMICITY_SRCDIR \
252 BASIC_FILE_CC CLOCALE_CC CCODECVT_CC CCOLLATE_CC \
253 CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_CC \
254 CPU_OPT_BITS_RANDOM
256 # includes
257 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
258 backward_headers c_base_headers_extra $_headers1 $_pb_headers | \
259 sed -e 's#\${GNUHOSTDIST}/libstdc++-v3/include/##g'
260 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
261 bits_headers ext_headers $_headers2 | \
262 sed -e 's#\${GNUHOSTDIST}/libstdc++-v3/include/##g' -e 's#\${GNUHOSTDIST}/libstdc++-v3/config/##g'
263 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
264 $_pf_headers | sed -e 's#\${GNUHOSTDIST}/libstdc++-v3/include/profile/##g'
265 getvars $_PLATFORM/libstdc++-v3/include/Makefile \
266 BASIC_FILE_H ALLOCATOR_H CSTDIO_H CLOCALE_H CMESSAGES_H CTIME_H
267 getlinks $_TMPDIR/$_PLATFORM/libgcc/config.status libgcc
268 } | sanitise_includes \
269 | write_mk $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/defs.mk
272 ##### usr.bin/gcc* #####
274 get_gcc_bootstrap () {
275 _subdir="$1"
276 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
277 for f in auto-host tm config; do
278 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
279 done
282 get_gcc () {
283 _subdir="$1"
284 mkdir -p $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH
285 mkdir -p $_OUTDIR/usr.bin/libcpp/arch/$MACHINE_ARCH
286 mkdir -p $_OUTDIR/usr.bin/include/arch
287 _buildname="BUILD_"
288 _libcppsubdir=""
289 _extravars="TM_H ALL_OPT_FILES"
290 _hconfig_h=""
291 _extravars2="tm_file_list build_xm_include_list"
292 _extravars3="tm_p_include_list"
295 getvars gcc/Makefile \
296 ${_buildname}EARLY_SUPPORT ${_buildname}ERRORS ${_buildname}PRINT \
297 ${_buildname}RTL ${_buildname}SUPPORT ${_buildname}VARRAY \
298 ${_buildname}MD | \
299 sed -e 's#build/errors.o#build-errors.o#g' \
300 -e 's#build/print-rtl.o#build-print-rtl.o#g' \
301 -e 's#build/rtl.o#build-rtl.o#g' \
302 -e 's#build/varray.o#build-varray.o#g' \
303 -e 's#build/ggc-none.o#build-ggc-none.o#g' \
304 -e 's#build/##g'
305 getvars gcc/Makefile \
306 ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
307 GCC_OBJS GCOV_OBJS GXX_OBJS GTM_H PROTO_OBJS ${_extravars1} \
308 INCLUDES md_file OBJC_OBJS OBJS out_file version \
309 BUILD_PREFIX RTL_H RTL_BASE_H TREE_H ${_hconfig_h} BASIC_BLOCK_H GCC_H \
310 GTFILES_SRCDIR GTFILES_FILES_FILES GTFILES_FILES_LANGS \
311 GTFILES GTFILES_LANG_DIR_NAMES NOEXCEPTION_FLAGS \
312 NATIVE_SYSTEM_HEADER_DIR \
313 tm_defines host_xm_file host_xm_defines tm_p_file \
314 target_cpu_default ${_extravars} ${_extravars2} \
315 lang_specs_files ${_extravars3} \
316 common_out_file \
317 | sanitise_includes
318 getvars gcc/Makefile \
319 LIB2ADDEHDEP | sed 's/unwind.inc//'
320 getvars gcc/Makefile \
321 CXX_OBJS CXX_C_OBJS | sed 's/cp\///g'
322 getvars gcc/Makefile \
323 F77_OBJS | sed 's/f\///g'
324 getvars libcpp/Makefile \
325 libcpp_a_OBJS
326 getvars gcc/Makefile \
327 ENABLE_SHARED
328 echo G_SHLIB_LINK="$CC -shared"
329 echo G_SHLIB_MULTILIB=.
330 } | write_mk $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/defs.mk
332 getvars gcc/Makefile \
333 EXTRA_HEADERS \
334 | write_mk $_OUTDIRBASE/usr.bin/include/arch/$MACHINE_ARCH.mk
336 write_c $_OUTDIRBASE/usr.bin/libcpp/arch/$MACHINE_ARCH/config.h <$_TMPDIR/libcpp/config.h
337 hfiles='auto-host configargs config bconfig bversion plugin-version multilib tm'
338 for f in $hfiles; do
339 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h <$_TMPDIR/gcc/$f.h
340 if [ "${MACHINE_ARCH}" = "powerpc" -a "${f}" = "configargs" ]
341 then
342 ex <<__EOF__ $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
343 /configuration_arguments/ s/$//
346 #ifdef _SOFT_FLOAT
349 s/";$/ -with-float=soft";/
351 #else
352 #endif
354 . m +1
355 /configure_default_options/ s/{ NULL.*$//
357 #ifdef _SOFT_FLOAT
358 { "float", "soft" },
359 #endif
360 { NULL, NULL }
364 __EOF__
366 if [ "${f}" = "configargs" ]
367 then
368 _srcquoted=$(echo "$_SRC" | sed 's/\//\\\//g')
369 ex <<__EOF__ $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
370 /static const char configuration_arguments/ s/$_srcquoted/\/usr\/src/g
372 __EOF__
374 done
376 # keep identical
377 for f in all-tree.def; do
378 cp $_TMPDIR/gcc/$f $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
379 done
381 # special transforms
382 for f in gtyp-input.list; do
383 sed -e 's/^.*external\/gpl3\/gcc\/dist/SRCDIR/' < $_TMPDIR/gcc/$f > $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f
384 done
386 # special platforms
387 if [ "${MACHINE_ARCH}" = "sh3el" -o "${MACHINE_ARCH}" = "sh3eb" ]; then
388 write_c $_OUTDIRBASE/usr.bin/$_subdir/arch/$MACHINE_ARCH/sysroot-suffix.h <$_TMPDIR/gcc/sysroot-suffix.h
392 ##### main #####
394 case "$1" in
395 # .mk and .h files for libgcc bootstrap (from host build)
397 libgcc*-bootstrap)
398 _OUTDIR="$_TOP/external/gpl3/gcc"
399 _OUTDIRBASE="external/gpl3/gcc"
400 get_libgcc gcc
401 get_libgcov gcc $_PLATFORM/libgcc/Makefile
402 get_crtstuff crtstuff
403 get_gcc_bootstrap gcc
404 exit 0
407 libstdc++-bootstrap)
408 _OUTDIR="$_TOP/external/gpl3/gcc"
409 _OUTDIRBASE="external/gpl3/gcc"
410 get_libstdcxx_v3 libstdc++-v3 gcc
411 exit 0
414 gcc*)
415 _OUTDIR="$_TOP/external/gpl3/gcc"
416 _OUTDIRBASE="external/gpl3/gcc"
417 get_gcc gcc
418 get_libgcc gcc
419 get_libgcov gcc $_PLATFORM/libgcc/Makefile
420 get_crtstuff crtstuff
421 get_gcc_libiberty gcc
422 get_libobjc libobjc
423 get_libstdcxx_v3 libstdc++-v3 gcc
424 get_libdecnumber libdecnumber
425 get_libgomp libgomp
426 get_libbacktrace libbacktrace
427 exit 0
432 echo invalid arguments;
433 exit 1
435 esac