File init.c changed (mode: 100644) (index 1c397a0..7ca926a) |
... |
... |
static void sysstart(void) |
110 |
110 |
l r; |
l r; |
111 |
111 |
|
|
112 |
112 |
pid = sysstart_clone(); |
pid = sysstart_clone(); |
113 |
|
r = waitid(P_PID, pid, 0, WEXITED); |
|
|
113 |
|
r = waitid(P_PID, pid, 0, WEXITED|WALL); |
114 |
114 |
if (ISERR(r)) { |
if (ISERR(r)) { |
115 |
115 |
OUT("ERROR(%ld):unable to wait for /bin/sysstart to exit\n", r); |
OUT("ERROR(%ld):unable to wait for /bin/sysstart to exit\n", r); |
116 |
116 |
exit_group(-1); |
exit_group(-1); |
|
... |
... |
static void main_loop(void) |
124 |
124 |
loop { |
loop { |
125 |
125 |
l r; |
l r; |
126 |
126 |
|
|
127 |
|
r = waitid(P_ALL, 0, 0, WEXITED); |
|
|
127 |
|
r = waitid(P_ALL, 0, 0, WEXITED|WALL); |
128 |
128 |
if (ISERR(r)) { |
if (ISERR(r)) { |
129 |
129 |
OUT("ERROR(%ld):unable to wait on orphan process terminations\n", r); |
OUT("ERROR(%ld):unable to wait on orphan process terminations\n", r); |
130 |
130 |
} |
} |
|
... |
... |
static void main_loop(void) |
144 |
144 |
struct siginfo siginfo; |
struct siginfo siginfo; |
145 |
145 |
l r; |
l r; |
146 |
146 |
|
|
147 |
|
r = waitid(P_ALL, 0, &siginfo, WEXITED); |
|
|
147 |
|
r = waitid(P_ALL, 0, &siginfo, WEXITED|WALL); |
148 |
148 |
if(ISERR(r)) { |
if(ISERR(r)) { |
149 |
149 |
OUT("ERROR(%ld):unable to wait on /bin/agetty clone and orphan process terminations\n", r); |
OUT("ERROR(%ld):unable to wait on /bin/agetty clone and orphan process terminations\n", r); |
150 |
150 |
exit_group(-1); |
exit_group(-1); |
File make deleted (index 293e6df..0000000) |
1 |
|
#!/bin/sh |
|
2 |
|
|
|
3 |
|
# this script is brutal and verbose, has no tricks and is quite linear, then |
|
4 |
|
# quite easy to deal with |
|
5 |
|
# for the moment, it's hardcoded for a gcc toolchain... BAD! Since now |
|
6 |
|
# gcc is c++ diareha |
|
7 |
|
|
|
8 |
|
# stolen from ffmpeg configure |
|
9 |
|
set -e |
|
10 |
|
|
|
11 |
|
# prevent locale nonsense from breaking basic text processing |
|
12 |
|
LC_ALL=C |
|
13 |
|
export LC_ALL |
|
14 |
|
|
|
15 |
|
init_file_name=init |
|
16 |
|
|
|
17 |
|
#------------------------------------------------------------------------------- |
|
18 |
|
# default source files in the binary |
|
19 |
|
init_ulinux_src_files="\ |
|
20 |
|
ulinux/utils/mem.c \ |
|
21 |
|
ulinux/utils/ascii/string/vsprintf.c" |
|
22 |
|
init_src_files=init.c |
|
23 |
|
#------------------------------------------------------------------------------- |
|
24 |
|
sep_start() |
|
25 |
|
{ |
|
26 |
|
printf "\ |
|
27 |
|
################################################################################\ |
|
28 |
|
\n" |
|
29 |
|
} |
|
30 |
|
|
|
31 |
|
sep_end() |
|
32 |
|
{ |
|
33 |
|
printf "\ |
|
34 |
|
################################################################################\ |
|
35 |
|
\n\n" |
|
36 |
|
} |
|
37 |
|
|
|
38 |
|
subsep_start() |
|
39 |
|
{ |
|
40 |
|
printf "\ |
|
41 |
|
********************************************************************************\ |
|
42 |
|
\n" |
|
43 |
|
} |
|
44 |
|
|
|
45 |
|
subsep_end() |
|
46 |
|
{ |
|
47 |
|
printf "\ |
|
48 |
|
********************************************************************************\ |
|
49 |
|
\n" |
|
50 |
|
} |
|
51 |
|
|
|
52 |
|
################################################################################ |
|
53 |
|
|
|
54 |
|
is_in() |
|
55 |
|
{ |
|
56 |
|
value=$1 |
|
57 |
|
shift |
|
58 |
|
for var in $*; do |
|
59 |
|
[ $var = $value ] && return 0 |
|
60 |
|
done |
|
61 |
|
return 1 |
|
62 |
|
} |
|
63 |
|
|
|
64 |
|
set_default() |
|
65 |
|
{ |
|
66 |
|
for opt; do |
|
67 |
|
eval : \${$opt:=\$${opt}_default} #1 level of indirection |
|
68 |
|
done |
|
69 |
|
} |
|
70 |
|
|
|
71 |
|
CMDLINE_SET=' |
|
72 |
|
init_cpp |
|
73 |
|
init_cc |
|
74 |
|
init_ld |
|
75 |
|
init_ulinux_arch |
|
76 |
|
' |
|
77 |
|
|
|
78 |
|
################################################################################ |
|
79 |
|
|
|
80 |
|
# command line set defaults |
|
81 |
|
#------------------------------------------------------------------------------- |
|
82 |
|
init_cpp_default='gcc -E -Wall -Wextra' |
|
83 |
|
init_cc_default='gcc -nostdinc -Wall -Wextra -std=gnu99 -O0 -c' |
|
84 |
|
init_ld_default='ld -nostdlib -O10 -s' |
|
85 |
|
#------------------------------------------------------------------------------- |
|
86 |
|
init_ulinux_arch_default=$(uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/) |
|
87 |
|
|
|
88 |
|
set_default $CMDLINE_SET |
|
89 |
|
|
|
90 |
|
################################################################################ |
|
91 |
|
|
|
92 |
|
show_help() |
|
93 |
|
{ |
|
94 |
|
cat <<EOF |
|
95 |
|
Usage: make [options] |
|
96 |
|
|
|
97 |
|
Help options: |
|
98 |
|
--help print this message |
|
99 |
|
|
|
100 |
|
Standard options: |
|
101 |
|
--quiet init will be silenced (output code compiled out) |
|
102 |
|
--no-tty init won't respawn login processes on ttys |
|
103 |
|
|
|
104 |
|
Advanced options: |
|
105 |
|
--init-cpp=CPP use CPP compiler command line CPP for target init process [$init_cpp] |
|
106 |
|
--init-cc=CC use C compiler command line CC for target init process objects [$init_cc] |
|
107 |
|
--init-ld=LD use linker command line LD for target init process [$init_ld] |
|
108 |
|
--init-ulinux-arch=ARCH use ulinux ARCH for target init process [$init_ulinux_arch] |
|
109 |
|
EOF |
|
110 |
|
exit 0 |
|
111 |
|
} |
|
112 |
|
|
|
113 |
|
################################################################################ |
|
114 |
|
|
|
115 |
|
sep_start;printf 'paths:\n' |
|
116 |
|
src_path=$(readlink -f $(dirname "$0")) |
|
117 |
|
build_path=$(readlink -f .) |
|
118 |
|
printf "source path is $src_path\n" |
|
119 |
|
printf "build path is $build_path\n" |
|
120 |
|
sep_end |
|
121 |
|
|
|
122 |
|
################################################################################ |
|
123 |
|
|
|
124 |
|
|
|
125 |
|
show_help_do= |
|
126 |
|
for opt do |
|
127 |
|
optval="${opt#*=}" |
|
128 |
|
case "$opt" in |
|
129 |
|
--help|-h) |
|
130 |
|
show_help_do=yes #defer until we have all our options |
|
131 |
|
;; |
|
132 |
|
--quiet) |
|
133 |
|
CPPFLAGS="$CPPFLAGS -DQUIET" |
|
134 |
|
init_ulinux_src_files= |
|
135 |
|
;; |
|
136 |
|
--no-tty) |
|
137 |
|
CPPFLAGS="$CPPFLAGS -DNO_TTY" |
|
138 |
|
;; |
|
139 |
|
*) |
|
140 |
|
optname=${opt%%=*} |
|
141 |
|
optname=${optname#--} |
|
142 |
|
optname=$(printf "$optname" | sed 's/-/_/g') |
|
143 |
|
if is_in $optname $CMDLINE_SET; then |
|
144 |
|
eval $optname='$optval' # 1 level indirection |
|
145 |
|
else |
|
146 |
|
printf "unknown option \"$opt\"\n" |
|
147 |
|
printf "see $0 --help for available options\n" |
|
148 |
|
exit 1 |
|
149 |
|
fi |
|
150 |
|
;; |
|
151 |
|
esac |
|
152 |
|
done |
|
153 |
|
if test $show_help_do; then |
|
154 |
|
show_help |
|
155 |
|
fi |
|
156 |
|
|
|
157 |
|
################################################################################ |
|
158 |
|
|
|
159 |
|
sep_start;printf 'configure ulinux src tree for target arch:\n' |
|
160 |
|
rm -f $build_path/ulinux/arch |
|
161 |
|
mkdir -p $build_path/ulinux |
|
162 |
|
ln -sTf $src_path/ulinux/archs/$init_ulinux_arch $build_path/ulinux/arch |
|
163 |
|
printf "init ulinux arch is $init_ulinux_arch\n" |
|
164 |
|
sep_end |
|
165 |
|
|
|
166 |
|
################################################################################ |
|
167 |
|
|
|
168 |
|
#from here we merge all source files |
|
169 |
|
all_init_src_files="$init_src_files $init_ulinux_src_files" |
|
170 |
|
|
|
171 |
|
################################################################################ |
|
172 |
|
|
|
173 |
|
sep_start;printf 'C preprocess init src files:\n' |
|
174 |
|
for init_src_file in $all_init_src_files |
|
175 |
|
do |
|
176 |
|
init_pp_c_file=${init_src_file%.c}.pp.c |
|
177 |
|
printf "INIT_CPP $src_path/$init_src_file->$build_path/$init_pp_c_file\n" |
|
178 |
|
mkdir -p $(dirname $init_pp_c_file) |
|
179 |
|
$init_cpp $CPPFLAGS -I$build_path -I$src_path \ |
|
180 |
|
-o $build_path/$init_pp_c_file $src_path/$init_src_file |
|
181 |
|
init_pp_c_files="$init_pp_c_file $init_pp_c_files" |
|
182 |
|
done |
|
183 |
|
sep_end |
|
184 |
|
|
|
185 |
|
################################################################################ |
|
186 |
|
|
|
187 |
|
sep_start;printf 'compile init preprocessed src files:\n' |
|
188 |
|
for init_pp_c_file in $init_pp_c_files |
|
189 |
|
do |
|
190 |
|
init_obj_file=${init_pp_c_file%.pp.c}.o |
|
191 |
|
printf "INIT_CC $build_path/$init_pp_c_file-->$build_path/$init_obj_file\n" |
|
192 |
|
$init_cc $CFLAGS -o $build_path/$init_obj_file \ |
|
193 |
|
$build_path/$init_pp_c_file |
|
194 |
|
init_obj_files="$init_obj_file $init_obj_files" |
|
195 |
|
done |
|
196 |
|
sep_end |
|
197 |
|
|
|
198 |
|
################################################################################ |
|
199 |
|
|
|
200 |
|
sep_start;printf 'link the init objects to produce the init binary:\n' |
|
201 |
|
printf "INIT_LD $init_file_name\n" |
|
202 |
|
printf "$init_ld -o $build_path/$init_file_name $build_path/$init_obj_files\n" |
|
203 |
|
$init_ld -o $build_path/$init_file_name $build_path/$init_obj_files |
|
204 |
|
sep_end |
|
205 |
|
# vim: set ts=8 sw=0 noexpandtab: |
|
File make_x86_64.sh added (mode: 100755) (index 0000000..8802703) |
|
1 |
|
#!/bin/sh |
|
2 |
|
build_dir=$(readlink -f .) |
|
3 |
|
printf "BUILD_DIR=$build_dir\n" |
|
4 |
|
src_dir=$(dirname $(readlink -f $0)) |
|
5 |
|
printf "SRC_DIR=$src_dir\n" |
|
6 |
|
|
|
7 |
|
cpp=/opt/toolchains/x64/elf/binutils-gcc/current/bin/cpp |
|
8 |
|
cc=/opt/toolchains/x64/elf/binutils-gcc/current/bin/gcc |
|
9 |
|
ld=/opt/toolchains/x64/elf/binutils-gcc/current/bin/ld |
|
10 |
|
|
|
11 |
|
rm -Rf $build_dir/ulinux |
|
12 |
|
mkdir -p $build_dir/ulinux |
|
13 |
|
ln -sTf $src_dir/ulinux/archs/x86_64 $build_dir/ulinux/arch |
|
14 |
|
|
|
15 |
|
# Those are the ulinux files to build for a non-quiet/talkative init: |
|
16 |
|
# - ulinux/utils/mem.c |
|
17 |
|
# - utils/ascii/string/vsprintf.c |
|
18 |
|
printf 'CPP init.c->init.cpp.c\n' |
|
19 |
|
$cpp -DQUIET -DNO_TTY -I$build_dir -I$src_dir -o $build_dir/init.cpp.c $src_dir/init.c |
|
20 |
|
printf 'CC init.cpp.c->init.cpp.c.o\n' |
|
21 |
|
$cc -O0 -c -o $build_dir/init.cpp.c.o $build_dir/init.cpp.c |
|
22 |
|
printf 'LD init.cpp.c.o->init\n' |
|
23 |
|
$ld -nostdlib -s -o $build_dir/init $build_dir/init.cpp.c.o |
|
24 |
|
|