clarify the purpose of this project
[nyanglibc.git] / make_x86_64_libs.sh
blobb42e0a4cc1a4477fe16106f94a1ed791eb102a74
1 #!/bin/sh
2 set -e
3 ################################################################################
4 #### CONFIGURATION
5 conf_prefix=/nyan/glibc/nyan/1
6 # does not account for the terminating 0
7 conf_prefix_bytes_n=$(printf "$conf_prefix" | wc -c)
8 as="/nyan/toolchains/current/bin/as"
9 ld="/nyan/toolchains/current/bin/ld"
10 ar="/nyan/toolchains/current/bin/ar"
11 cpp="/nyan/toolchains/current/bin/x86_64-nyan-linux-gnu-gcc -E"
12 ################################################################################
14 src_dir=$(readlink -f $(dirname $0))
15 printf "SRC_DIR=$src_dir\n"
16 build_dir=$(readlink -f .)
17 printf "BUILD_DIR=$build_dir\n"
19 # order matters
21 . $src_dir/make/csu.sh
22 . $src_dir/make/iconv.sh
23 . $src_dir/make/locale.sh
24 . $src_dir/make/assert.sh
25 . $src_dir/make/ctype.sh
26 . $src_dir/make/intl.sh
27 . $src_dir/make/catgets.sh
28 . $src_dir/make/math.sh
29 . $src_dir/make/setjmp.sh
30 . $src_dir/make/signal.sh
31 . $src_dir/make/stdlib.sh
32 . $src_dir/make/stdio-common.sh
33 . $src_dir/make/libio.sh
34 . $src_dir/make/dlfcn.sh
35 . $src_dir/make/nptl.sh
36 . $src_dir/make/malloc.sh
37 . $src_dir/make/string.sh
38 . $src_dir/make/wcsmbs.sh
39 . $src_dir/make/time.sh
40 . $src_dir/make/dirent.sh
41 . $src_dir/make/grp.sh
42 . $src_dir/make/pwd.sh
43 . $src_dir/make/posix.sh
44 . $src_dir/make/io.sh
45 . $src_dir/make/termios.sh
46 . $src_dir/make/resource.sh
47 . $src_dir/make/misc.sh
48 . $src_dir/make/socket.sh
49 . $src_dir/make/sysvipc.sh
50 . $src_dir/make/gmon.sh
51 . $src_dir/make/wctype.sh
52 . $src_dir/make/shadow.sh
53 . $src_dir/make/gshadow.sh
54 . $src_dir/make/argp.sh
55 . $src_dir/make/debug.sh
56 . $src_dir/make/inet.sh
57 . $src_dir/make/resolv.sh
58 . $src_dir/make/nss.sh
59 # sunrpc is dead, should remove it
60 . $src_dir/make/sunrpc.sh
61 . $src_dir/make/login.sh
62 . $src_dir/make/elf.sh
63 printf 'CREATING LIBC PIC/SHARED ARCHIVE\n'
64 cd $build_dir
65 $ar cruv $build_dir/libc_pic.a $(cat csu/stamp.os iconv/stamp.os locale/stamp.os assert/stamp.os ctype/stamp.os intl/stamp.os catgets/stamp.os math/stamp.os setjmp/stamp.os signal/stamp.os stdlib/stamp.os stdio-common/stamp.os libio/stamp.os dlfcn/stamp.os nptl/stamp.os malloc/stamp.os string/stamp.os wcsmbs/stamp.os time/stamp.os dirent/stamp.os grp/stamp.os pwd/stamp.os posix/stamp.os io/stamp.os termios/stamp.os resource/stamp.os misc/stamp.os socket/stamp.os sysvipc/stamp.os gmon/stamp.os wctype/stamp.os shadow/stamp.os gshadow/stamp.os argp/stamp.os debug/stamp.os inet/stamp.os resolv/stamp.os nss/stamp.os sunrpc/stamp.os login/stamp.os elf/stamp.os)
66 #-------------------------------------------------------------------------------
67 . $src_dir/make/rtld/csu.sh
68 . $src_dir/make/rtld/dirent.sh
69 . $src_dir/make/rtld/elf.sh
70 . $src_dir/make/rtld/gmon.sh
71 . $src_dir/make/rtld/io.sh
72 . $src_dir/make/rtld/malloc.sh
73 . $src_dir/make/rtld/misc.sh
74 . $src_dir/make/rtld/nptl.sh
75 . $src_dir/make/rtld/posix.sh
76 . $src_dir/make/rtld/setjmp.sh
77 . $src_dir/make/rtld/signal.sh
78 . $src_dir/make/rtld/stdlib.sh
79 . $src_dir/make/rtld/string.sh
80 . $src_dir/make/rtld/time.sh
81 #-------------------------------------------------------------------------------
82 printf 'CREATING RTLD-LIBC.A\n'
83 $ar cqv $build_dir/elf/rtld-libc.a $build_dir/csu/rtld-check_fds.os $build_dir/csu/rtld-errno.os $build_dir/dirent/rtld-closedir.os $build_dir/dirent/rtld-rewinddir.os $build_dir/dirent/rtld-readdir64.os $build_dir/dirent/rtld-fdopendir.os $build_dir/dirent/rtld-getdents64.os $build_dir/elf/rtld-dl-addr-obj.os $build_dir/gmon/rtld-profil.os $build_dir/gmon/rtld-prof-freq.os $build_dir/io/rtld-stat64.os $build_dir/io/rtld-fstat64.os $build_dir/io/rtld-lstat64.os $build_dir/io/rtld-fstatat64.os $build_dir/io/rtld-openat64.os $build_dir/io/rtld-lseek64.os $build_dir/io/rtld-access.os $build_dir/io/rtld-close_nocancel.os $build_dir/io/rtld-fcntl_nocancel.os $build_dir/io/rtld-open64_nocancel.os $build_dir/io/rtld-read_nocancel.os $build_dir/io/rtld-pread64_nocancel.os $build_dir/io/rtld-write_nocancel.os $build_dir/malloc/rtld-scratch_buffer_set_array_size.os $build_dir/misc/rtld-mmap64.os $build_dir/misc/rtld-munmap.os $build_dir/misc/rtld-mprotect.os $build_dir/nptl/rtld-libc-lowlevellock.os $build_dir/nptl/rtld-libc-cancellation.os $build_dir/nptl/rtld-forward.os $build_dir/posix/rtld-uname.os $build_dir/posix/rtld-_exit.os $build_dir/posix/rtld-getpid.os $build_dir/posix/rtld-environ.os $build_dir/setjmp/rtld-setjmp.os $build_dir/setjmp/rtld-__longjmp.os $build_dir/signal/rtld-sigaction.os $build_dir/stdlib/rtld-exit.os $build_dir/stdlib/rtld-cxa_atexit.os $build_dir/stdlib/rtld-cxa_thread_atexit_impl.os $build_dir/string/rtld-strchr.os $build_dir/string/rtld-strcmp.os $build_dir/string/rtld-strcspn.os $build_dir/string/rtld-strdup.os $build_dir/string/rtld-strlen.os $build_dir/string/rtld-strnlen.os $build_dir/string/rtld-strncmp.os $build_dir/string/rtld-memchr.os $build_dir/string/rtld-memcmp.os $build_dir/string/rtld-memmove.os $build_dir/string/rtld-memset.os $build_dir/string/rtld-stpcpy.os $build_dir/string/rtld-rawmemchr.os $build_dir/string/rtld-cacheinfo.os $build_dir/time/rtld-setitimer.os
84 printf 'LINKING LIBRTLD.OS\n'
85 #XXX: we may need to extract some code from libgcc
86 $ld -nostdlib -r -o $build_dir/elf/librtld.os '-(' $build_dir/elf/dl-allobjs.os $build_dir/elf/rtld-libc.a '-)' -Map $build_dir/elf/librtld.os.map
87 printf 'CREATING LD.SO/ld-linux-x86-64.so.2\n'
88 $ld -s -nostdlib -shared -o $build_dir/elf/ld-linux-x86-64.so.2 \
89 -z combreloc --hash-style=both -z defs -z relro \
90 $build_dir/elf/librtld.os \
91 --version-script=$src_dir/ld.versions.map \
92 -soname=ld-linux-x86-64.so.2 \
93 -defsym=_begin=0
94 #-------------------------------------------------------------------------------
95 . $src_dir/make/elf-extra.sh
96 #-------------------------------------------------------------------------------
97 $ld -nostdlib -r -o $build_dir/libc_pic.os \
98 -d --whole-archive $build_dir/libc_pic.a
99 #-------------------------------------------------------------------------------
100 # the bits we need from libgcc (which has bits from glibc...)
101 . $src_dir/make/libgcc.sh
102 #-------------------------------------------------------------------------------
103 printf 'CREATING LIBC.SO\n'
104 $ld \
105 -s \
106 -shared -O1 -z defs \
107 --dynamic-linker=/lib64/ld-linux-x86-64.so.2 \
108 -L$build_dir/csu/ \
109 --version-script=$src_dir/libc.versions.map \
110 -soname=libc.so.6 \
111 -z combreloc -z relro --hash-style=both \
112 -nostdlib -e __libc_main \
113 -L$build_dir \
114 -L$build_dir/math \
115 -L$build_dir/elf \
116 -L$build_dir/dlfcn \
117 -L$build_dir/nss \
118 -L$build_dir/nis \
119 -L$build_dir/rt \
120 -L$build_dir/resolv \
121 -L$build_dir/mathvec \
122 -L$build_dir/support \
123 -L$build_dir/crypt \
124 -L$build_dir/nptl \
125 -L$build_dir/libgcc \
126 -rpath-link=$build_dir:$build_dir/math:$build_dir/elf:$build_dir/dlfcn:$build_dir/nss:$build_dir/nis:$build_dir/rt:$build_dir/resolv:$build_dir/mathvec:$build_dir/support:$build_dir/crypt:$build_dir/nptl \
127 -o $build_dir/libc.so \
128 -T $src_dir/shlib.lds \
129 $build_dir/csu/abi-note.o \
130 $build_dir/libc_pic.os \
131 $build_dir/elf/interp.os \
132 $build_dir/elf/ld-linux-x86-64.so.2 \
133 -lgcc \
134 $build_dir/elf/sofini.os
135 #-------------------------------------------------------------------------------
136 cd $build_dir
137 $ar cruv libc_nonshared.a $(cat csu/stamp.oS iconv/stamp.oS locale/stamp.oS localedata/stamp.oS iconvdata/stamp.oS assert/stamp.oS ctype/stamp.oS intl/stamp.oS catgets/stamp.oS math/stamp.oS setjmp/stamp.oS signal/stamp.oS stdlib/stamp.oS stdio-common/stamp.oS libio/stamp.oS dlfcn/stamp.oS nptl/stamp.oS malloc/stamp.oS string/stamp.oS wcsmbs/stamp.oS timezone/stamp.oS time/stamp.oS dirent/stamp.oS grp/stamp.oS pwd/stamp.oS posix/stamp.oS io/stamp.oS termios/stamp.oS resource/stamp.oS misc/stamp.oS socket/stamp.oS sysvipc/stamp.oS gmon/stamp.oS gnulib/stamp.oS wctype/stamp.oS manual/stamp.oS shadow/stamp.oS gshadow/stamp.oS po/stamp.oS argp/stamp.oS rt/stamp.oS conform/stamp.oS debug/stamp.oS mathvec/stamp.oS support/stamp.oS crypt/stamp.oS nptl_db/stamp.oS inet/stamp.oS resolv/stamp.oS nss/stamp.oS hesiod/stamp.oS sunrpc/stamp.oS nis/stamp.oS nscd/stamp.oS login/stamp.oS elf/stamp.oS stamp.oS)
138 #-------------------------------------------------------------------------------
139 $ld -s -shared --dynamic-linker=/lib64/ld-linux-x86-64.so.2 -z defs \
140 -L$build_dir/csu \
141 -z combreloc \
142 -z relro \
143 --hash-style=both \
144 -L$build_dir \
145 -L$build_dir/math \
146 -L$build_dir/elf \
147 -L$build_dir/dlfcn \
148 -L$build_dir/nss \
149 -L$build_dir/nis \
150 -L$build_dir/rt \
151 -L$build_dir/resolv \
152 -L$build_dir/mathvec \
153 -L$build_dir/support \
154 -L$build_dir/crypt \
155 -L$build_dir/nptl \
156 -rpath-link=$build_dir:$build_dir/math:$build_dir/elf:$build_dir/dlfcn:$build_dir/nss:$build_dir/nis:$build_dir/rt:$build_dir/resolv:$build_dir/mathvec:$build_dir/support:$build_dir/crypt:$build_dir/nptl \
157 -o $build_dir/elf/sotruss-lib.so \
158 -T $src_dir/shlib.lds \
159 $build_dir/csu/abi-note.o \
160 --as-needed \
161 $build_dir/elf/sotruss-lib.os \
162 --no-as-needed \
163 --start-group \
164 $build_dir/libc.so \
165 $build_dir/libc_nonshared.a \
166 --as-needed \
167 $build_dir/elf/ld-linux-x86-64.so.2 \
168 --no-as-needed \
169 --end-group
170 #-------------------------------------------------------------------------------
171 $ar cruv libc.a $(cat csu/stamp.o iconv/stamp.o locale/stamp.o localedata/stamp.o iconvdata/stamp.o assert/stamp.o ctype/stamp.o intl/stamp.o catgets/stamp.o math/stamp.o setjmp/stamp.o signal/stamp.o stdlib/stamp.o stdio-common/stamp.o libio/stamp.o dlfcn/stamp.o nptl/stamp.o malloc/stamp.o string/stamp.o wcsmbs/stamp.o timezone/stamp.o time/stamp.o dirent/stamp.o grp/stamp.o pwd/stamp.o posix/stamp.o io/stamp.o termios/stamp.o resource/stamp.o misc/stamp.o socket/stamp.o sysvipc/stamp.o gmon/stamp.o gnulib/stamp.o wctype/stamp.o manual/stamp.o shadow/stamp.o gshadow/stamp.o po/stamp.o argp/stamp.o rt/stamp.o conform/stamp.o debug/stamp.o mathvec/stamp.o support/stamp.o crypt/stamp.o nptl_db/stamp.o inet/stamp.o resolv/stamp.o nss/stamp.o hesiod/stamp.o sunrpc/stamp.o nis/stamp.o nscd/stamp.o login/stamp.o elf/stamp.o stamp.o)
172 #-------------------------------------------------------------------------------
173 . $src_dir/make/iconv-others.sh
174 . $src_dir/make/locale-others.sh
175 #-------------------------------------------------------------------------------
176 . $src_dir/make/iconvdata.sh
177 cp -f $src_dir/gconv-modules $build_dir/gconv-modules
178 #-------------------------------------------------------------------------------
179 . $src_dir/make/libgcc-libm.sh
180 . $src_dir/make/math-libm.sh
181 #-------------------------------------------------------------------------------
182 . $src_dir/make/dlfcn-libdl.sh
183 #-------------------------------------------------------------------------------
184 # crtbeginS.o crtendS.o
185 . $src_dir/make/libgcc-libpthread.sh
186 . $src_dir/make/libpthread.sh
187 . $src_dir/make/libmemusage.sh
188 . $src_dir/make/rt.sh
189 . $src_dir/make/libSegFault.sh
190 . $src_dir/make/libpcprofile.sh
191 . $src_dir/make/mathvec.sh
192 . $src_dir/make/crypt.sh
193 . $src_dir/make/nptl_db.sh
194 . $src_dir/make/resolv-libresolv.sh
195 . $src_dir/make/resolv-libnss_dns.sh
196 . $src_dir/make/resolv-libanl.sh
197 . $src_dir/make/nss-libnss_files.sh
198 . $src_dir/make/nss-libnss_db.sh
199 . $src_dir/make/nss-libnss_compat.sh
200 . $src_dir/make/hesiod.sh
201 # nis/libnsl (NIS/Network Information System) is dead, skipping
202 # libutils from login may be useless in the end
203 . $src_dir/make/login-libutil.sh
204 #-------------------------------------------------------------------------------
205 mkdir -p $build_dir/include
206 cp -rf $src_dir/include/* $build_dir/include
207 #-------------------------------------------------------------------------------
208 mkdir -p $build_dir
209 sed -e "s@CONF_PREFIX@$conf_prefix@g" $src_dir/libc.so.in >$build_dir/libc.so.ld