mkbuild

mk based build system
git clone git://git.2f30.org/mkbuild
Log | Files | Refs | LICENSE

commit d6f63014eebda55c0596d7467fb9a201559f5bfa
Author: Daniel Bainton <dpb@driftaway.org>
Date:   Fri,  4 Apr 2014 12:23:11 +0100

Initial copy from the morpheus repo

Diffstat:
Aconfig.mk | 32++++++++++++++++++++++++++++++++
Amk.3rdparty | 35+++++++++++++++++++++++++++++++++++
Amk.build | 27+++++++++++++++++++++++++++
Amk.clean | 13+++++++++++++
Amk.common | 7+++++++
Amk.common-noinst | 6++++++
Amk.default | 2++
Amk.deps | 21+++++++++++++++++++++
Amk.fetch | 15+++++++++++++++
Amk.install | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amk.parent | 31+++++++++++++++++++++++++++++++
Amk.target | 4++++
12 files changed, 259 insertions(+), 0 deletions(-)

diff --git a/config.mk b/config.mk @@ -0,0 +1,32 @@ +arch = i486 +version = 0.0 +mirror = http://dl.2f30.org/morpheus-pkgs/${arch}/${version} +ports = $mkbuild/../ports +nprocs = 2 + +TOOLCHAIN_TRIPLET = ${arch}-musl-linux +CC = ${TOOLCHAIN_TRIPLET}-gcc +HOSTCC = $CC -static +LD = $CC +AR = ${TOOLCHAIN_TRIPLET}-ar +RANLIB = ${TOOLCHAIN_TRIPLET}-ranlib +STRIP = ${TOOLCHAIN_TRIPLET}-strip +#STRIP = true +SHELL = /bin/sh + +PREFIX = +BINDIR = ${PREFIX}/bin +LIBDIR = ${PREFIX}/lib +ETCDIR = ${PREFIX}/etc +DFLDIR = ${ETCDIR}/default +MANDIR = ${PREFIX}/share/man + +INSTALL = /usr/bin/install + +# these don't work for all packages yet... +optldflags = -s -Wl,--gc-sections -Wl,-z,relro,-z,now +optcflags = -fdata-sections -ffunction-sections -Os -g0 -fno-unwind-tables -fno-asynchronous-unwind-tables -Wa,--noexecstack + +CPPFLAGS = -D_BSD_SOURCE -D_GNU_SOURCE +CFLAGS = ${CPPFLAGS} # ${optcflags} +LDFLAGS = -static ${optldflags} diff --git a/mk.3rdparty b/mk.3rdparty @@ -0,0 +1,35 @@ +<$mkbuild/config.mk + +all:QV: build + + +build:QV: fetch + mkdir -p $src + oldpwd=`pwd` + cd $src + t=$(cmp -s $mkfile $oldpwd/.cache || echo $?) + if test "$t" != ""; then + if test "${targ}" != ""; then + env -i PATH="$PATH" mkbuild="$mkbuild" TARG="${targ}" mk -f $mkfile + else + env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile + fi + cp $mkfile $oldpwd/.cache + fi + +install:QV: all + cd $src + if test "${targ}" != ""; then + env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile install TARG="${targ}" ROOT="${ROOT}" + else + env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile install ROOT="${ROOT}" + fi + +clean:QV: + rm -f .cache + if test -d $src; then + cd $src + env -i PATH="$PATH" mkbuild="$mkbuild" mk -f $mkfile clean + fi + +<$mkbuild/mk.fetch diff --git a/mk.build b/mk.build @@ -0,0 +1,27 @@ +all:QV: $DEPS $TARG $BIN $LIB + +TARG = `{ if test "$TARG" != ""; then echo $TARG; else echo "NOTARG"; fi } +BIN = `{ if test "$BIN" != ""; then echo $BIN; else echo "NOBIN"; fi } +LIB = `{ if test "$LIB" != ""; then echo $LIB; else echo "NOLIB"; fi } + +`{ printf "# Auto-generated file by mk, do not edit\n\n" > .targs.mk } +`{ for i in $BIN; do tobj=$(echo $i|tr '.' '_'); printf "$i:Q: \$"$tobj"_OBJ\n\techo LD \$target\n\t\$LD \$prereq \$LDFLAGS \$DEPS_LDFLAGS \$LOCAL_LDFLAGS \$LOCAL_BIN_LDFLAGS -o \$target\n\n" ; done >> .targs.mk } +<.targs.mk + +<$mkbuild/mk.deps + +&.a:Q: + echo AR $target + $AR -rv $target $prereq + echo RANLIB $target + $RANLIB $target + +%.o:Q: %.c + echo CC $stem.o + $CC $CFLAGS $DEPS_CFLAGS $LOCAL_CFLAGS $CPPFLAGS -c $stem.c -o $stem.o + +%.c:Q: %.y + echo YACC $stem.y + $YACC $stem.y + mv -f y.tab.c $stem.c + diff --git a/mk.clean b/mk.clean @@ -0,0 +1,13 @@ + +clean:QV: + t=`if test "$TARG" = "NOTARG"; then echo; else echo $TARG; fi ` + b=`if test "$BIN" = "NOBIN"; then echo; else echo $BIN; fi ` + l=`if test "$LIB" = "NOLIB"; then echo; else echo $LIB; fi ` + bin_obj= + for i in $BIN; do + bobj=$(echo $i|tr '.' '_') + bin_obj="$bin_obj \$${bobj}_OBJ" + done + bin_obj=$(eval echo $bin_obj) + echo rm -f $t $b $OBJ $bin_obj $l $LOBJ $CLEAN_FILES .targs.mk .deps.mk + rm -f $t $b $OBJ $bin_obj $l $LOBJ $CLEAN_FILES .targs.mk .deps.mk diff --git a/mk.common b/mk.common @@ -0,0 +1,7 @@ +<$mkbuild/config.mk +<$mkbuild/mk.build +<$mkbuild/mk.install +<$mkbuild/mk.clean + +fetch:VQ: + # Nothing to download diff --git a/mk.common-noinst b/mk.common-noinst @@ -0,0 +1,6 @@ +<$mkbuild/config.mk +<$mkbuild/mk.build +<$mkbuild/mk.clean + +fetch:VQ: + # Nothing to download diff --git a/mk.default b/mk.default @@ -0,0 +1,2 @@ +<$mkbuild/mk.common +<$mkbuild/mk.target diff --git a/mk.deps b/mk.deps @@ -0,0 +1,21 @@ + +`{ printf "# Auto-generated file by mk, do not edit\n\n" > .deps.mk } + +paths = `{ find $ports -type f -name mkfile } +`{ for i in $DEPS; do \ + for path in $paths; do \ + dir=$(dirname $path); \ + pkg=$(basename $dir); \ + if test "$i" = "$pkg"; then \ + printf "${i}_DEPDIR = $dir\n\n"; \ + printf "<$dir/depsinc.mk\n\n"; \ + printf "$pkg:QV:\n\tcd $dir\n\tenv -i PATH=\"$PATH\" mkbuild=\"$mkbuild\" mk\n\n"; \ + fi; \ + done; \ +done >> .deps.mk } + +<.deps.mk + + +deps:V: $DEPS + diff --git a/mk.fetch b/mk.fetch @@ -0,0 +1,15 @@ + +fetch:QV: fetch-git fetch-http + +fetch-git:QV: + if test "$git" = ""; then + return + fi + test -d $src || git clone $git $src + +fetch-http:QV: + if test "$url" = ""; then + return + fi + wget -c $url + tar -xf `basename $url` diff --git a/mk.install b/mk.install @@ -0,0 +1,66 @@ + +install:QV: install_bin install_lib install_man install_other \ + install_symlinks install_dirs + if test "$INSTALL_PERMISSIONS" = ""; then + return + fi + eval `echo $INSTALL_PERMISSIONS | tr ' ' '\n' | paste -d ' ' - - | \ + awk '{ printf("echo \"CHMOD %s ${ROOT}${PREFIX}%s\"; \ + chmod %s ${ROOT}${PREFIX}%s;\n", $1, $2, $1, $2) }'` + +install_bin:QV: all + for f in $INSTALL_BIN; do + mkdir -p ${ROOT}${PREFIX}$BINDIR + echo INSTALL ${ROOT}${PREFIX}$BINDIR/`basename $f` + $INSTALL -m 755 $f ${ROOT}${PREFIX}$BINDIR/`basename $f` + type=`file -b $f | cut -d ' ' -f 1` + if test "$type" = "ELF"; then + $STRIP ${ROOT}${PREFIX}$BINDIR/`basename $f` + fi + done + +install_lib:QV: all + for f in $INSTALL_LIB; do + mkdir -p ${ROOT}${PREFIX}$LIBDIR + echo INSTALL ${ROOT}${PREFIX}$LIBDIR/`basename $f` + $INSTALL -m 644 $f ${ROOT}${PREFIX}$LIBDIR/`basename $f` + done + +install_dirs:QV: all + for f in $INSTALL_DIRS; do + echo MKDIR ${ROOT}${PREFIX}$f + mkdir -p ${ROOT}${PREFIX}$f + done + +install_man:QV: all + for i in 1 1b 2 3 4 5 6 7 8; do + a=`echo '\$INSTALL_MAN'$i` + a=`eval echo $a` + for f in $a; do + mkdir -p ${ROOT}${PREFIX}$MANDIR/man$i + echo INSTALL ${ROOT}${PREFIX}$MANDIR/man$i/`basename $f` + $INSTALL -m 644 $f ${ROOT}${PREFIX}$MANDIR/man$i/`basename $f` + done + done + +install_other:QV: all + for i in 1 2 3 4 5 6 7 8; do + a=`echo '\$INSTALL_OTHER'$i` + a=`eval echo $a` + d=`echo '\$INSTALL_OTHER'${i}'_DIR'` + d=`eval echo $d` + mkdir -p ${ROOT}$d + for f in $a; do + echo INSTALL ${ROOT}${PREFIX}$d/`basename $f` + $INSTALL -m 644 $f ${ROOT}${PREFIX}$d/`basename $f` + done + done + +install_symlinks:QV: all + if test "$INSTALL_SYMLINK" = ""; then + return + fi + eval `echo $INSTALL_SYMLINK | tr ' ' '\n' | paste -d ' ' - - | \ + awk '{ printf("echo \"LN %s ${ROOT}${PREFIX}%s\"; \ + ln -sf %s ${ROOT}${PREFIX}%s;\n", $1, $2, $1, $2) }'` + diff --git a/mk.parent b/mk.parent @@ -0,0 +1,31 @@ +<$mkbuild/config.mk + +all:QV: $TARG + + +`{ echo "# Auto-generated file by mk, do not edit" > .targs.mk } +`{ for i in $TARG; do printf "$i:QV:\n\tcd $i\n\tenv -i PATH=\"$PATH\" mkbuild=\"$mkbuild\" mk\n\n" ; done >> .targs.mk } +<.targs.mk + +install:QV: + for t in $TARG; do + cd $t + env -i PATH="$PATH" mkbuild="$mkbuild" mk install ROOT="${ROOT}" + cd .. + done + +clean:QV: + rm .targs.mk + for t in $TARG; do + cd $t + env -i PATH="$PATH" mkbuild="$mkbuild" mk clean + cd .. + done + +fetch:QV: + for t in $TARG; do + cd $t + env -i PATH="$PATH" mkbuild="$mkbuild" mk fetch + cd .. + done + diff --git a/mk.target b/mk.target @@ -0,0 +1,4 @@ + +$BIN: $OBJ + +$LIB: $LOBJ