tdefault.mk - mkports - recipes for building multiple softwares with mk(1)
(HTM) git clone git://z3bra.org/mkports
(DIR) Log
(DIR) Files
(DIR) Refs
---
tdefault.mk (2588B)
---
1 # this file is sourced from within each pack directory
2 <../config.mk
3
4 srcdir = `{pwd}
5 destdir = `{printf '%s/%s/.rootfs' "$WORK" "$pkg-$ver"}
6 archive = `{basename $url 2>/dev/null || echo /dev/null}
7 tarball = ${REPO}/$pkg@$ver.tbz
8
9 # create a pack from an chroot install (see the "install" target)
10 $tarball:Q:
11 mk fetch patch build install cleanup
12 cd $destdir
13 mkdir -p $(dirname $tarball)
14 ${TAR} -cjf $tarball `ls -1`
15 printf '\n\t%s\n\n' "$tarball"
16
17 # recipe trying to follow the most common pattern in software
18 # building
19 # If it doesn't work, simply override it on a per pack basis
20 build:V: fetch patch
21 cd $WORK/$pkg-$ver
22 test -f configure && ./configure $CONFIGURE
23 make -j${NPROC} CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ${MAKEFLAGS}
24
25 # install the pack to a .rootfs directory
26 # this is where the "pack" target will chdir to create the pack
27 install:QV: build
28 mkdir -p $destdir
29 cd $WORK/$pkg-$ver
30 make -j${NPROC} ${MAKEFLAGS} DESTDIR=$destdir install
31
32 cleanup:V: install
33 cd $destdir
34 test -n "$CLEANUP" && rm -r $CLEANUP
35 find . -name '*.la' | xargs -r rm
36 find . -name '*.so' | xargs -r rm
37 find . -name '*.so.*' | xargs -r rm
38 find . -name 'info' -type d | xargs -r rm -r
39 find . -name 'doc' -type d | xargs -r rm -r
40 find . -name 'pkgconfig' -type d | xargs -r rm -r
41 { test -d ./share && test -z "$(ls ./share)" && rmdir ./share; } || true
42
43 # patch your software using everything in ./patches
44 patch:QV: fetch
45 if [ -d "$srcdir/patches" ]; then
46 cd $WORK/$pkg-$ver
47 cat $srcdir/patches/*.diff | patch -Np1
48 fi
49
50 # fetch the source
51 fetch:QV: fetch-git fetch-archive
52
53 # if $git is set, clone the repo, and checkout $ver
54 fetch-git:QV:
55 if [ -n "$git" ]; then
56 mkdir -p $WORK
57 cd $WORK
58 test -d $pkg-$ver || git clone -q $git $pkg-$ver
59 cd $pkg-$ver
60 git reset -q --hard
61 git checkout -q $ver
62 fi
63
64 # if $url is set, download/extract the archive, and move its
65 # content to a directory named $pkg-$ver
66 fetch-archive:QV: $WORK/$archive
67 if [ -n "$url" ]; then
68 cd $WORK
69 rm -rf $pkg-$ver
70 case $archive in
71 *.tar.bz2|*.tbz) method="-j" ;;
72 *.tar.gz|*.tgz) method="-z" ;;
73 *.tar.xz|*.txz) method="-J" ;;
74 *) echo "$archive: format not recognized" >&2; exit 1
75 esac
76 ${TAR} $method -xvf $archive
77 src=$(${TAR} $method -tf $archive|sed -n 1p|cut -f1 -d/)
78 if [ "$src" != "$pkg-$ver" ]; then
79 mv "$src" "$pkg-$ver"
80 fi
81 fi
82
83 $WORK/$archive:Q:
84 if [ -n "$url" ]; then
85 mkdir -p $WORK
86 cd $WORK
87 curl -k -L# $url > $archive
88 fi
89
90 # delete everything but the pack
91 clean:V:
92 rm -rf $WORK
93
94 # remove the pack
95 distclean:V: clean
96 rm -f $tarball