jehanne/arch/rc/lib/build/utils.rc

132 lines
2.3 KiB
Plaintext

# Utility functions designed to simplify build scripts.
#
# They react to environment variables
BUILD_INITIALIZED=true
CFLAGS=( \
-9 \
-g \
-gdwarf-2 \
-ggdb \
'-mcmodel=small' \
-O0 \
-Wall \
-Werror \
-Wno-main \
-Wno-missing-braces \
-Wno-parentheses \
-Wno-unknown-pragmas \
)
KLIB_CFLAGS=( \
-DKERNEL \
-c \
'-mcmodel=kernel' \
-O0 \
-fplan9-extensions \
-ffreestanding \
-fstack-protector-all \
-fno-builtin \
-Wall \
-Wno-missing-braces \
-Wno-parentheses \
-Wno-unknown-pragmas \
-Wuninitialized \
-g \
)
STACKCHECK_CFLAGS=( \
-fstack-check \
-fstack-protector-all \
)
CMD_OFLAGS=( \
-static \
-lavl \
-lcomplete \
-lcontrol \
-ldisk \
-lflate \
-lframe \
-lmemdraw \
-lmemlayer \
-lmemdraw \
-ldraw \
-lplumb \
-lregexp \
-lString \
-l9p \
-lauth \
-lauthsrv \
-lndb \
-lip \
-lsec \
-lauth \
-lmp \
-lthread \
-lbio \
-l9p2000 \
-ljehanne \
)
CC=gcc
CC=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$CC
AR=ar
AR=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$AR
RANLIB=ranlib
RANLIB=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$RANLIB
STRIP=strip
STRIP=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$STRIP
LD=ld
LD=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$LD
OBJCOPY=objcopy
OBJCOPY=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$OBJCOPY
OBJDUMP=objdump
OBJDUMP=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$OBJDUMP
READELF=readelf
READELF=$JEHANNE_TOOLCHAIN/cross/posix/bin/$TOOLPREFIX$READELF
fn debuggable {
# echo $*
eval $*
}
fn prependLibraryName {
LIBRARY_NAME=$1
if ( ! ~ 0 $#LIBRARY_NAME ) {
for (i in *.o) {
# rename object files to ease library merge
debuggable mv $i $LIBRARY_NAME-$i
}
}
}
fn compileCommands {
EXT=$1
DESTINATION=$2
shift 2
LIST=$*
if ( ~ 0 $#LIST ) {
LIST=*.$EXT
}
mkdir -p $DESTINATION
for (f in $LIST) {
BINARY=`{basename $f|sed 's/\.'$EXT'//'}
debuggable $CC $f -o $BINARY -O2 '-std=gnu11' $STACKCHECK_CFLAGS $CFLAGS $CMD_OFLAGS
debuggable mv $BINARY $DESTINATION
}
}
fn safemove {
mkdir -p $*($#*)
mv $*
}