tPorts: create basic building recipe using mk(1) - distro - linux distribution experiments
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 66e9a35f4dce30dcc81e76ce668712f26a623306
(DIR) parent f34627581eef934be0039ce7d4ea527a7c0f7e77
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Mon, 22 Oct 2018 07:57:23 +0200
Ports: create basic building recipe using mk(1)
Diffstat:
A pkg/build.mk | 44 +++++++++++++++++++++++++++++++
A pkg/config.mk | 19 +++++++++++++++++++
A pkg/mkfile | 14 ++++++++++++++
3 files changed, 77 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/pkg/build.mk b/pkg/build.mk
t@@ -0,0 +1,44 @@
+<../config.mk
+
+# target name for the pack
+tarball = $pkg@$ver.tbz
+
+# name of downloaded archive (/dev/null for git repos)
+archive = `{basename $url 2>/dev/null || echo $pkg-$ver.tbz}
+
+# create tarball with installed files in .rootfs/
+$tarball: .rootfs
+ tar -C .rootfs -cvj . > $tarball
+
+# build and install software under .rootfs/
+.rootfs: $pkg-$ver
+ mkdir -p .rootfs
+ [ -f $pkg-$ver/configure ] && ( cd $pkg-$ver; ./configure $configureopts )
+ [ -d patches ] && cat patches/*.diff | ( cd $pkg-$ver; patch -Np1 )
+ make -e -C $pkg-$ver DESTDIR=$(pwd)/.rootfs $MAKEFLAGS install
+
+# download archive from remote site
+$archive:
+ mkdir -p $(dirname $archive)
+ if [ -n "$git" ]; then
+ git clone --bare $git .repo
+ (cd .repo; git archive --prefix $pkg-$ver/ $ver) | bzip2 > $archive
+ rm -rf .repo
+ elif [ -n "$url" ]; then
+ curl -L $url > $archive
+ fi
+
+# extract software (from either $url or $git)
+$pkg-$ver:Q: $archive
+ case $archive in
+ *.tgz|*.tar.gz) z=z ;;
+ *.txz|*.tar.xz) z=J ;;
+ *.tbz|*.tar.bz2) z=j ;;
+ esac
+ srcdir=$(tar -xv$z < $archive | sed -n 1p | cut -d/ -f1)
+ [ "$srcdir" = "$pkg-$ver" ] || mv $srcdir $pkg-$ver
+ touch $pkg-$ver
+
+# cleanup everything in the repo
+clean:V:
+ rm -rf $tarball .rootfs $pkg-$ver $archive
(DIR) diff --git a/pkg/config.mk b/pkg/config.mk
t@@ -0,0 +1,19 @@
+TRIPLET = x86_64-linux-musl
+NPROC = 8
+
+CC = x86_64-linux-musl-gcc -static
+CXX = x86_64-linux-musl-g++ -static
+LD = $CC -Bstatic
+
+CFLAGS =
+LDFLAGS = -static
+MAKEFLAGS = PREFIX=/ MANDIR=/man MANPREFIX=/man mandir=/man prefix=/
+configureopts = --prefix=/ \
+ --target=$TRIPLET \
+ --mandir=/man \
+ --libdir=/lib \
+ --includedir=/include \
+ --enable-static \
+ --disable-nls \
+ --disable-shared \
+ --disable-multilib
(DIR) diff --git a/pkg/mkfile b/pkg/mkfile
t@@ -0,0 +1,14 @@
+ALL = `{find . -mindepth 1 -maxdepth 1 -type d}
+
+<config.mk
+
+all:QV: ${ALL}
+ echo "you're done."
+
+%:QV:
+ test ! -d "$stem" && exit
+ cd $stem
+ env -i PATH=$PATH mk
+
+clean:QV:
+ for p in ${ALL}; do (cd $p; mk clean); done