Comment: | switch over to new build mechanism and formally deprecate makefiles |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
34c625a47b56572efa5b2f4f599318d6 |
User & Date: | lexi on 2019-08-19 05:42:02 |
Other Links: | manifest | tags |
2019-08-19
| ||
22:40 | add documentation compilation check-in: 8d6d792515 user: lexi tags: trunk | |
05:42 | switch over to new build mechanism and formally deprecate makefiles check-in: 34c625a47b user: lexi tags: trunk | |
04:51 | begin move away from legacy build system check-in: 26c340d29e user: lexi tags: trunk | |
Modified build.sh from [75da38cbfd] to [e19ff3649f].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 .. 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 .. 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 ... 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
#!/usr/bin/env bash . global/common.sh noimpl() { say "$1 is not currently implemented on your system. an exciting chance for you to contribute, no?" exit 1 } if test "$os$arch$bits" = ""; then say "set the following environment variables to the appropriate atoms describing your system. for help determining the appropriate atoms, see libk.md" say ' - $os={lin|fbsd|hai|osx…}' say ' - $arch={x86|arm|ia64|mips…}' say ' - $bits={|32|64…}' exit 1 fi # TODO: make it possible for user to change # default set with environment vars modules=(kcore kmem kstr kio kgraft kfile) target=$arch.$os if test "$bits" != ""; then ................................................................................ case $os.$bits in win.32) bin_fmt=win32;; win.64) bin_fmt=win64;; osx.32|dar.32) bin_fmt=macho32;; osx.64|dar.64) bin_fmt=macho64;; dos.*) bin_fmt=dosexe;; none.*) bin_fmt=bin;; 32) bin_fmt=elf32;; 64) bin_fmt=elf64;; esac # first, we establish the # parameters of the build has gcc && _cc=gcc has clang && _cc=clang has cc && _cc=cc cc=${cc:-$_cc} has m4 && _m4=m4 m4=${m4:-$_m4} has yasm && asm=yasm has nasm && asm=nasm export out=${out:-out} export gen=${gen:-gen} library=${libkind:-static} # {static|shared|both} case $library in static) build_static_library=yes build_shared_library=no;; ................................................................................ macro_compile_env="-Datom_target_arch=$arch -Datom_target_os=$os -Dtarget_posix=$posix -Dtarget_unix=$unix" if test "$bits" != ""; then macro_compile_env="$macro_compile_env -Datom_target_bits=$bits" fi for mod in ${modules[@]}; do say "building [1mlibk[21m with [1m$mod[21m" done comp_mac() { $m4 $macro_compile_env -I "$gen" $3 "$1" > "$2"; } comp_asm() { $asm "-f$bin_fmt" "-i$gen" $1 -o "$2"; } comp_co() { comp_clib $1 $2 -c; } comp_clib(){ src=$1 output=$2 flags=$3 $cc $src $3 -std=c11 -isystem "$out" -isystem "$gen" -isystem "arch/" -fPIC -nostdlib "-L$out" "-o$output" } scan() { find "$1" -name "$2"; } # now we make sure all the appropriate # directories exist set -x # get type data mkdir -p $gen $cc -D_emit_m4_include arch/typesize.c -o $gen/typesize $gen/typesize > gen/typesize.m ................................................................................ # generate symbol tables for error handling functions mkdir -p $out/k awk -f global/gen-conds.awk <global/modules >$out/k/internal.egroup.h awk -f global/gen-ident.awk <global/modules >$gen/internal.ident.c comp_co $gen/internal.ident.c $out/internal.ident.o # first pass: copy all raw headers into place for mod in ${modules[@]}; do for h in $(scan $mod '*.h'); do base=$(basename $h) cp "$h" "$out/k/$base" done done # second pass: run macro headers through m4 and # copy the resulting file into place for mod in ${modules[@]}; do for h in $(scan $mod '*.h.m'); do base=$(basename $h) dest=${base%%.m} comp_mac "$h" "$out/k/$dest" done done # third pass: generate manpage, html, and pdf # versions of the documentation from the md src mkdir -p $out/doc/{man,html,pdf} global/build-manpage.sh libk.md for mod in ${modules[@]}; do for doc in $(scan $mod '*.md'); do base="$(basename $doc)" stem="${base%%.md}" global/build-manpage.sh "$doc" # TODO html # TODO pdf done done # fourth pass: compile sources and save the # resulting object files to $out, tracking # which is a runtime or function unit. exe's # will not be compiled until a later pass fn_objects=() rt_objects=() data_objects=( $out/internal.ident.o ) for mod in ${modules[@]}; do for fn in $(scan $mod '*.fn.c'); do base="$(basename $fn)" dest="$out/$mod.${base%%.c}.o" comp_co "$fn" "$dest" fn_objects+="$dest" done for rt in $(scan $mod '*.rt.c'); do base="$(basename $rt)" dest="$out/$mod.${base%%.c}.o" comp_co "$rt" "$dest" rt_objects+="$dest" done for fn in $(scan $mod "*.fn.$target.s"); do base="$(basename $fn)" dest="$out/$mod.${base%%.s}.o" comp_asm "$fn" "$dest" fn_objects+="$dest" done for rt in $(scan $mod "*.rt.$target.s"); do base="$(basename $rt)" dest="$out/$mod.${base%%.s}.o" comp_asm "$rt" "$dest" rt_objects+="$dest" done done echo fns: ${fn_objects[@]} echo rts: ${rt_objects[@]} |
> > > > > > > | | > | | | < < > < < < | | | | | < < | > > < < < < < | | | | | | | | | > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 .. 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 .. 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 ... 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
#!/usr/bin/env bash export out=${out:-out} . global/common.sh noimpl() { say "$1 is not currently implemented on your system. an exciting chance for you to contribute, no?" exit 1 } timestamp() { date "+%H:%M:%S %A"; } if test "$os$arch$bits" = ""; then say "set the following environment variables to the appropriate atoms describing your system. for help determining the appropriate atoms, see libk.md" say ' - $os={lin|fbsd|hai|osx…}' say ' - $arch={x86|arm|ia64|mips…}' say ' - $bits={|32|64…}' exit 1 fi if test "$1" = "-C"; then say "precleaning repo" ./clean.sh fi # TODO: make it possible for user to change # default set with environment vars modules=(kcore kmem kstr kio kgraft kfile) target=$arch.$os if test "$bits" != ""; then ................................................................................ case $os.$bits in win.32) bin_fmt=win32;; win.64) bin_fmt=win64;; osx.32|dar.32) bin_fmt=macho32;; osx.64|dar.64) bin_fmt=macho64;; dos.*) bin_fmt=dosexe;; none.*) bin_fmt=bin;; *.32) bin_fmt=elf32;; *.64) bin_fmt=elf64;; *) say "cannot determine correct binary format to use for target $target"; exit 1;; esac # first, we establish the # parameters of the build has cc && _cc=cc has clang && _cc=clang has gcc && _cc=gcc cc=${cc:-$_cc} has m4 && _m4=m4 m4=${m4:-$_m4} has nasm && asm=nasm has yasm && asm=yasm export gen=${gen:-gen} library=${libkind:-static} # {static|shared|both} case $library in static) build_static_library=yes build_shared_library=no;; ................................................................................ macro_compile_env="-Datom_target_arch=$arch -Datom_target_os=$os -Dtarget_posix=$posix -Dtarget_unix=$unix" if test "$bits" != ""; then macro_compile_env="$macro_compile_env -Datom_target_bits=$bits" fi comp_mac() { $m4 $macro_compile_env -I "$gen" $3 "$1" > "$2"; } comp_asm() { $asm "-f$bin_fmt" -i "$gen" $1 -o "$2"; } comp_co() { comp_c $1 $2 "-c -fPIC"; } comp_c(){ src=$1 output=$2 flags=$3 $cc $src $3 -std=c11 -isystem "$out" -isystem "$gen" -isystem "arch/" -nostdlib "-L$out" "-o$output" } scan() { find "$1" -name "$2"; } say "commencing libk build $build at $(timestamp)" set -x # get type data mkdir -p $gen $cc -D_emit_m4_include arch/typesize.c -o $gen/typesize $gen/typesize > gen/typesize.m ................................................................................ # generate symbol tables for error handling functions mkdir -p $out/k awk -f global/gen-conds.awk <global/modules >$out/k/internal.egroup.h awk -f global/gen-ident.awk <global/modules >$gen/internal.ident.c comp_co $gen/internal.ident.c $out/internal.ident.o # first pass: copy all headers into place, # including ones we need to generate for mod in ${modules[@]}; do for h in $(scan $mod '*.h'); do base=$(basename $h) cp "$h" "$out/k/$base" done for h in $(scan $mod '*.h.m'); do base=$(basename $h) dest=${base%%.m} comp_mac "$h" "$out/k/$dest" done done # second pass: generate manpage, html, and pdf # versions of the documentation from the md src mkdir -p $out/doc/{man,html,pdf} global/build-manpage.sh libk.md for mod in ${modules[@]}; do for doc in $(scan $mod '*.md'); do base="$(basename $doc)" stem="${base%%.md}" global/build-manpage.sh "$doc" global/build-html.sh "$doc" global/build-pdf.sh "$doc" done done # third pass: compile sources and save the # resulting object files to $out, tracking # which is a runtime or function unit. exe's # will not be compiled until a later pass fn_objects=() rt_objects=() data_objects=( $out/internal.ident.o ) for mod in ${modules[@]}; do for fn in $(scan $mod '*.fn.c'); do base="$(basename $fn)" dest="$out/$mod.${base%%.c}.o" comp_co "$fn" "$dest" fn_objects+=("$dest") done for rt in $(scan $mod '*.rt.c'); do base="$(basename $rt)" dest="$out/$mod.${base%%.c}.o" comp_co "$rt" "$dest" rt_objects+=("$dest") done for fn in $(scan $mod "*.fn.$target.s"); do base="$(basename $fn)" dest="$out/$mod.${base%%.s}.o" comp_asm "$fn" "$dest" fn_objects+=("$dest") done for rt in $(scan $mod "*.rt.$target.s"); do base="$(basename $rt)" dest="$out/$mod.${base%%.s}.o" comp_asm "$rt" "$dest" rt_objects+=("$dest") done done # fourth pass: link the libraries that are # configured to be built if test $build_static_library == yes; then for obj in ${fn_objects[@]} ${rt_objects[@]} ${data_objects[@]}; do ar rc $out/libk.a $obj done ranlib $out/libk.a fi if test $build_shared_library == yes; then ld -r ${rt_objects[@]} -o $out/boot.o ld -shared ${fn_objects[@]} -o $out/libk.so fi # fifth pass: compile the executable tools # against the libraries created in pass 5 for mod in ${modules[@]}; do for exe in $(scan $mod '*.exe.c'); do base="$(basename $exe)" dest="$out/$mod.${base%%.exe.c}" if test $build_shared_library == yes; then comp_c "$out/boot.o $exe" "$dest" -lk else comp_c "$exe" "$dest" -lk fi done done set +x say "all passes finished; build $build complete at $(timestamp)" |
Modified clean.sh from [61a9f12cd8] to [67375a0380].
1 2 3 4 5 6 7 8 9 10 11 |
#!/usr/bin/env bash
. global/common.sh
out=${out:-out}
gen=${gen:-gen}
say "cleaning libk build artifacts"
set -x
rm -r $out
rm -r $gen
|
< < > |
1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/env bash
out=${out:-out}
gen=${gen:-gen}
. global/common.sh
say "cleaning libk build artifacts"
set -x
rm -r $out
rm -r $gen
|
Added global/build-html.sh version [045bd446a1].
> > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 |
#!/usr/bin/env bash (test -d global && test -f build.sh) || { echo >&2 "($0) run [1m$me[21m from root of [1mlibk[21m source directory" exit 1 } . global/common.sh reqpack cmark "generate documentation" say "facility under construction" exit 0 |
Modified global/build-manpage.sh from [fbe8d4ad27] to [b795aa8a1c].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#!/usr/bin/env sh (test -d global && test -f build.sh) || { echo >&2 "($0) run [1m$me[21m from root of [1mlibk[21m source directory" exit 1 } . global/common.sh test "$out" = "" && { say "\$out environment variable must be set to your build directory - are you running this script by hand? run [1mmake doc[21m in the root directory instead!" exit 2 } if ! has cmark; then say "to generate documentation for [1mlibk[21m, install the [1mcmark[21m package and try again" exit 3 fi file="$1" filename="$(basename "$file")" stem=${filename%%.md} mandest="$out/doc/man" section=${section:-4} out="$mandest/$stem.$section" desc_rec="$(grep -m1 "^$name:" global/modules)" if test $? -eq 0; then desc=" - $(echo $desc_rec | cut -d: -f4)" else desc="" fi date="$(date -r"$file" "+%d %A %Y")" mkdir -p "$mandest" echo >"$out" ".TH ${name^^} \"$section\" \"$date\" \"hale.su libk [r$build]\" \"modules\"" echo >>"$out" ".SH NAME" echo >>"$out" "$stem$desc" echo >>"$out" ".SH SYNOPSIS" dhead=$(grep -m1 -n "^# description$" "$file") if test $? -eq 0; then |
| < < < < < < < < | | | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/usr/bin/env sh (test -d global && test -f build.sh) || { echo >&2 "($0) run [1m$me[21m from root of [1mlibk[21m source directory" exit 1 } . global/common.sh reqpack cmark "generate documentation" file="$1" filename="$(basename "$file")" stem=${filename%%.md} mandest="$out/doc/man" section=${section:-4} out="$mandest/$stem.$section" desc_rec="$(grep -m1 "^$stem:" global/modules)" if test "$desc_rec" != ""; then desc=" - $(echo $desc_rec | cut -d: -f4)" else desc="" fi date="$(date -r"$file" "+%d %A %Y")" mkdir -p "$mandest" echo >"$out" ".TH ${stem^^} \"$section\" \"$date\" \"hale.su libk [r$build]\" \"modules\"" echo >>"$out" ".SH NAME" echo >>"$out" "$stem$desc" echo >>"$out" ".SH SYNOPSIS" dhead=$(grep -m1 -n "^# description$" "$file") if test $? -eq 0; then |
Added global/build-pdf.sh version [045bd446a1].
> > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 |
#!/usr/bin/env bash (test -d global && test -f build.sh) || { echo >&2 "($0) run [1m$me[21m from root of [1mlibk[21m source directory" exit 1 } . global/common.sh reqpack cmark "generate documentation" say "facility under construction" exit 0 |
Modified global/common.sh from [4d96b9fc79] to [85eaa3b261].
3 4 5 6 7 8 9 |
has() { which $1 >/dev/null 2>&1; return $?; } check() { var=$1 test "${!var}" == "" || return 0 say "we were not able to detect a default value for the configuration variable \$$var. please set this variable to $2 and try again." exit 1 } |
> > > > > > > > > > > > |
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
has() { which $1 >/dev/null 2>&1; return $?; } check() { var=$1 test "${!var}" == "" || return 0 say "we were not able to detect a default value for the configuration variable \$$var. please set this variable to $2 and try again." exit 1 } test "$out" = "" && { say "\$out environment variable must be set to your build directory - are you running this script by hand? run [1m./build.sh[21m in the root directory instead!" exit 2 } reqpack() { if ! has "$1"; then say "to $2 for [1mlibk[21m, install the [1m$1[21m package and try again" exit 3 fi } |
Name change from arch/makefile to legacy/arch.makefile.
Name change from kbuild/makefile to legacy/kbuild.makefile.
Name change from kconf/makefile to legacy/kconf.makefile.
Name change from kcore/makefile to legacy/kcore.makefile.
Name change from kdb/makefile to legacy/kdb.makefile.
Name change from kdbg/makefile to legacy/kdbg.makefile.
Name change from kfile/makefile to legacy/kfile.makefile.
Name change from kgraft/makefile to legacy/kgraft.makefile.
Name change from kio/makefile to legacy/kio.makefile.
Name change from kmem/makefile to legacy/kmem.makefile.
Name change from kmsg/makefile to legacy/kmsg.makefile.
Name change from knet/makefile to legacy/knet.makefile.
Name change from knum/makefile to legacy/knum.makefile.
Name change from kproc/makefile to legacy/kproc.makefile.
Name change from kstr/makefile to legacy/kstr.makefile.
Name change from kterm/makefile to legacy/kterm.makefile.
Name change from legacy/makefile to legacy/legacy.makefile.