tMake default.mk more generic - mkports - recipes for building multiple softwares with mk(1)
(HTM) git clone git://z3bra.org/mkports
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 8902100346d5553b15c4e8164e399926d2e12ba6
(DIR) parent 97bbf28ff4ebe499b84d9ed774cc8edfaba32c17
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Fri, 15 Jan 2016 22:27:49 +0100
Make default.mk more generic
Diffstat:
M config.mk | 2 +-
A default.mk | 57 +++++++++++++++++++++++++++++++
D mk.build | 37 -------------------------------
A mkfile | 7 +++++++
4 files changed, 65 insertions(+), 38 deletions(-)
---
(DIR) diff --git a/config.mk b/config.mk
t@@ -1,4 +1,4 @@
-CROSS = /opt/cross/gcc-x86_64
+CROSS = /opt/cross/x86_64
PATH = ${CROSS}/bin:${PATH}
TOOLCHAIN_TRIPLET = x86_64-linux-musl
(DIR) diff --git a/default.mk b/default.mk
t@@ -0,0 +1,57 @@
+# create a pack from an chroot install (see the "install" target)
+$pkg\:$ver.tar.bz2:Q: install
+ cd $pkg-$ver/.rootfs
+ tar -c `ls` | bzip2 -c > ../../$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
+ test -f configure && ./configure $CONFIGURE
+ make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
+
+# install the pack to a .rootfs directory
+# this is where the "pack" target will chdir to create the pack
+install:QV: build
+ mkdir -p $pkg-$ver/.rootfs
+ cd $pkg-$ver
+ make PREFIX= DESTDIR=$(pwd)/.rootfs install
+
+# patch your software using everything in ./patches
+patch:QV: fetch
+ if [ -d ./patches ]; then
+ cd $pkg-$ver
+ cat ../patches/*.diff | patch -Np1
+ fi
+
+# fetch the source
+fetch:QV: fetch-git fetch-archive
+
+# if $git is set, clone the repo, and checkout $ver
+fetch-git:QV:
+ if [ -n "$git" ]; then
+ test -d $pkg-$ver && rm -r $pkg-$ver
+ git clone $git $pkg-$ver
+ cd $pkg-$ver; git checkout $ver
+ fi
+
+# if $url is set, download/extract the archive, and move its
+# content to a directory named $pkg-$ver
+fetch-archive:QV:
+ if [ -n "$url" ]; then
+ out=$(curl -LOw %{filename_effective} $url)
+ src=$(tar -xvf $out|sed -n 1p|tr -d /)
+ if [ "$src" != "$pkg-$ver" ]; then
+ mv "$src" "$pkg-$ver"
+ fi
+ fi
+
+# delete everything but the pack
+clean:V:
+ rm -rf $pkg-$ver
+ rm -f $pkg-$ver.*
+
+# remove the pack
+distclean:V: clean
+ rm -f $pkg:$ver.tar.bz2
(DIR) diff --git a/mk.build b/mk.build
t@@ -1,37 +0,0 @@
-all:QV: $pkg:$ver.tar.bz2
-
-$pkg\:$ver.tar.bz2: build
- cd $pkg-$ver/rootfs
- tar -c `ls` | bzip2 -c > ../../$pkg:$ver.tar.bz2
-
-build:QV: fetch
- mkdir -p $pkg-$ver/rootfs
- cd $pkg-$ver
- test -f configure && ./configure $CONFIGURE
- make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
- make PREFIX= DESTDIR=`pwd`/rootfs install
-
-fetch:QV: fetch-git fetch-archive
-
-fetch-git:QV:
- if [ "$git" != "" ]; then
- test -d $pkg-$ver && rm -r $pkg-$ver
- git clone $git $pkg-$ver
- (cd $pkg-$ver; git checkout $ver)
- fi
-
-fetch-archive:QV:
- if [ "$url" != "" ]; then
- echo downloading `basename $url`
- out=$(curl -sLOw %{filename_effective} $url)
- src=$(tar -xvf $out|sed -n 1p|tr -d /)
- test "$src" != "$pkg-$ver" && mv "$src" "$pkg-$ver" || true
- fi
-
-clean:V:
- rm -rf $pkg-$ver
- rm -f $pkg-$ver.*
-
-
-distclean:V: clean
- rm -f $pkg:$ver.tar.bz2
(DIR) diff --git a/mkfile b/mkfile
t@@ -0,0 +1,7 @@
+%:QV:
+ cd $stem; mk; mk clean
+
+clean:QV:
+ for p in ${ALL}; do (cd $p; mk clean); done
+distclean:QV:
+ for p in ${ALL}; do (cd $p; mk distclean); done