mkports

recipes for building multiple softwares with mk(1)
git clone git://z3bra.org/mkports
Log | Files | Refs

commit 4e2f8329fd1026289306f60e231fdb8dd2b42a47
parent da0781e453cdb212d86bc21bd8f6bd455dde4dfd
Author: z3bra <willyatmailoodotorg>
Date:   Wed Apr 13 08:22:58 2016

Build software in $workdir instead of $PWD

Diffstat:
 binutils/mkfile |  2 +-
 config.mk       |  1 +
 curl/mkfile     |  2 +-
 dash/mkfile     |  2 +-
 default.mk      | 45 ++++++++++++++++++++++++++-------------------
 gcc/mkfile      |  4 ++--
 init/mkfile     | 12 ++++++------
 iputils/mkfile  |  2 +-
 libpcc/mkfile   |  4 ----
 libz/mkfile     |  2 --
 mkfile          |  2 +-
 mksh/mkfile     |  4 ++--
 12 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/binutils/mkfile b/binutils/mkfile @@ -8,7 +8,7 @@ url = ftp://ftp.gnu.org/gnu/$pkg/$pkg-$ver.tar.bz2 MAKEFLAGS = ${MAKEFLAGS} tooldir='' build:QV: fetch patch - cd $pkg-$ver + cd $workdir/$pkg-$ver ./configure $CONFIGURE make configure-host make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS -all-static" ${MAKEFLAGS} diff --git a/config.mk b/config.mk @@ -3,6 +3,7 @@ CROSS = /opt/cross/${TOOLCHAIN_TRIPLET} ROOT = ${CROSS}/${TOOLCHAIN_TRIPLET} PATH = ${CROSS}/bin:${PATH} NPROC = 8 +workdir = `{printf '/tmp/mkports/%s-%s' "$pkg" "$(id -u)"} CC = ${TOOLCHAIN_TRIPLET}-gcc -static CXX = ${TOOLCHAIN_TRIPLET}-g++ -static diff --git a/curl/mkfile b/curl/mkfile @@ -25,7 +25,7 @@ CONFIGURE = ${CONFIGURE} \ --disable-smtps build:QV: fetch patch - cd $pkg-$ver + cd $workdir/$pkg-$ver ./configure ${CONFIGURE} make ${MAKEFLAGS} # static build: http://curl.haxx.se/mail/archive-2003-03/0115.html diff --git a/dash/mkfile b/dash/mkfile @@ -7,6 +7,6 @@ url=http://gondor.apana.org.au/~herbert/dash/files/$pkg-$ver.tar.gz install:V: build mkdir -p $destdir - cd $pkg-$ver + cd $workdir/$pkg-$ver make PREFIX= DESTDIR=$destdir install ln -sf /bin/dash $destdir/bin/sh diff --git a/default.mk b/default.mk @@ -1,27 +1,31 @@ -destdir = `{printf '%s/%s/.rootfs' "$(pwd)" "$pkg-$ver"} +srcdir = `{pwd} +workdir = `{printf '/tmp/%s-%s' "$pkg" "$(id -u)"} +destdir = `{printf '%s/%s/.rootfs' "$workdir" "$pkg-$ver"} archive = `{basename $url 2>/dev/null || echo /dev/null} + # create a pack from an chroot install (see the "install" target) -$pkg\#$ver.tar.bz2:Q: fetch patch build install cleanup +$pkg\#$ver.tar.bz2: fetch patch build install cleanup cd $destdir - tar -c `ls` | bzip2 -c > ../../$pkg\#$ver.tar.bz2 + tar -c `ls` | bzip2 -c > $srcdir/$pkg\#$ver.tar.bz2 # recipe trying to follow the most common pattern in software # building # If it doesn't work, simply override it on a per pack basis -build:QV: fetch patch - cd $pkg-$ver +build:V: fetch patch + cd $workdir/$pkg-$ver test -f configure && ./configure $CONFIGURE make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ${MAKEFLAGS} # install the pack to a .rootfs directory # this is where the "pack" target will chdir to create the pack -install:QV: build +install:V: build + echo $destdir mkdir -p $destdir - cd $pkg-$ver + cd $workdir/$pkg-$ver make ${MAKEFLAGS} DESTDIR=$destdir install -cleanup:QV: install +cleanup:V: install cd $destdir find . -name '*.la' | xargs -r rm find . -name '*.so' | xargs -r rm @@ -34,18 +38,20 @@ cleanup:QV: install fi # patch your software using everything in ./patches -patch:QV: fetch - if [ -d ./patches ]; then - cd $pkg-$ver - cat ../patches/*.diff | patch -Np1 +patch:V: fetch + if [ -d "$srcdir/patches" ]; then + cd $workdir/$pkg-$ver + cat $srcdir/patches/*.diff | patch -Np1 fi # fetch the source -fetch:QV: fetch-git fetch-archive +fetch:V: fetch-git fetch-archive # if $git is set, clone the repo, and checkout $ver -fetch-git:QV: +fetch-git:V: if [ -n "$git" ]; then + mkdir -p $workdir + cd $workdir test -d $pkg-$ver || git clone $git $pkg-$ver cd $pkg-$ver git reset --hard @@ -54,9 +60,9 @@ fetch-git:QV: # if $url is set, download/extract the archive, and move its # content to a directory named $pkg-$ver -fetch-archive:QV: $archive +fetch-archive:V: $archive if [ -n "$url" ]; then - rm -rf $pkg-$ver + cd $workdir case $archive in *.tar.bz2) opt="-xvj" ;; *.tar.gz|*.tgz) opt="-xvz" ;; @@ -71,14 +77,15 @@ fetch-archive:QV: $archive $archive:Q: if [ -n "$url" ]; then + mkdir -p $workdir + cd $workdir curl -LO $url > $archive fi # delete everything but the pack clean:V: - rm -rf $pkg-$ver - test -z "$url" || rm -f $archive + rm -rf $workdir # remove the pack distclean:V: clean - rm -f $pkg#$ver.tar.bz2 + rm -f $srcdir/$pkg#$ver.tar.bz2+ \ No newline at end of file diff --git a/gcc/mkfile b/gcc/mkfile @@ -18,12 +18,12 @@ CONFIGURE = ${CONFIGURE} \ --with-pkgversion="SPOINK-x86_64-static" #build:QV: fetch patch -# cd $pkg-$ver +# cd $workdir/$pkg-$ver # ./configure $CONFIGURE # make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ${MAKEFLAGS} all-gcc all-target-libgcc install:QV: build mkdir -p $destdir - cd $pkg-$ver + cd $workdir/$pkg-$ver make ${MAKEFLAGS} DESTDIR=$destdir install-gcc install-target-libgcc diff --git a/init/mkfile b/init/mkfile @@ -5,17 +5,17 @@ ver = 0.1 <../default.mk build:QV: fetch patch - mkdir -p $pkg-$ver - cp init.c $pkg-$ver/init.c - cd $pkg-$ver + mkdir -p $workdir/$pkg-$ver + cp init.c $workdir/$pkg-$ver/init.c + cd $workdir/$pkg-$ver $CC $CFLAGS init.c $LDFLAGS -o init install:QV: build mkdir -p $destdir/sbin mkdir -p $destdir/libexec - cp $pkg-$ver/init $destdir/sbin/init - cp rc $destdir/sbin/rc - cp power.subr $destdir/libexec/power.subr + cp $workdir/$pkg-$ver/init $destdir/sbin/init + cp $srcdir/rc $destdir/sbin/rc + cp $srcdir/power.subr $destdir/libexec/power.subr chmod 750 $destdir/sbin/rc chmod 750 $destdir/libexec/power.subr ln -sf /libexec/power.subr $destdir/sbin/reboot diff --git a/iputils/mkfile b/iputils/mkfile @@ -10,7 +10,7 @@ MAKEFLAGS = ${MAKEFLAGS} USE_GNUTLS=no USE_CAP=no install:QV: build mkdir -p $destdir/bin mkdir -p $destdir/sbin - cd $pkg-$ver + cd $workdir/$pkg-$ver cp ping ping6 $destdir/bin cp arping tracepath tracepath6 traceroute6 clockdiff rarpd rdisc $destdir/sbin/ chmod u+s $destdir/bin/ping $destdir/sbin/traceroute6 diff --git a/libpcc/mkfile b/libpcc/mkfile @@ -6,7 +6,3 @@ url = ftp://pcc.ludd.ltu.se/pub/pcc-libs/pcc-libs-$ver.tgz <../config.mk <../default.mk - -clean:V: - rm -rf $pkg-$ver - rm -f pcc-libs-$ver.* diff --git a/libz/mkfile b/libz/mkfile @@ -5,6 +5,4 @@ url = http://zlib.net/zlib-$ver.tar.gz <../config.mk <../default.mk -prefix = -mandir = /man CONFIGURE = --static diff --git a/mkfile b/mkfile @@ -1,4 +1,4 @@ -ALL = `{ls | grep -vE '[a-z]*\.mk|mkfile'} +ALL = `{ls | grep -vE '[A-Z]+|[a-z]*\.mk|mkfile'} <config.mk <deps.mk diff --git a/mksh/mkfile b/mksh/mkfile @@ -8,11 +8,11 @@ url = http://www.mirbsd.org/MirOS/dist/mir/mksh/$pkg-$ver.tgz CFLAGS = ${CFLAGS} -DMKSH_S_NOVI=1 -DMKSH_SMALL_BUT_FAST build:QV: fetch patch - cd $pkg-$ver + cd $workdir/$pkg-$ver /bin/sh Build.sh -r install:QV: build - cd $pkg-$ver + cd $workdir/$pkg-$ver mkdir -p $destdir/bin mkdir -p $destdir/etc mkdir -p $destdir/man/man1