newapkbuild: add support for meson

This commit is contained in:
Sören Tempel 2017-10-19 10:32:59 +02:00
parent 0f9d333305
commit f91242fe39

View File

@ -74,6 +74,25 @@ build_cmake() {
__EOF__ __EOF__
} }
build_meson() {
# References:
# http://mesonbuild.com/Reference-manual.html
# http://mesonbuild.com/Cross-compilation.html
# TODO For cross compilation a cross_file needs to be created.
sed -i -e 's/^\(makedepends="\)/\1meson /' APKBUILD
cat >>APKBUILD<<__EOF__
meson \\
--prefix=/usr \\
--sysconfdir=/etc \\
--mandir=/usr/share/man \\
--localstatedir=/var \\
--buildtype=release \\
. output
ninja -C output
__EOF__
}
build_perl() { build_perl() {
cat >>APKBUILD<<__EOF__ cat >>APKBUILD<<__EOF__
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
@ -98,6 +117,12 @@ package_autotools() {
package_make package_make
} }
package_meson() {
cat >>APKBUILD<<__EOF__
DESTDIR="$pkgdir" ninja -C output install
__EOF__
}
package_perl() { package_perl() {
cat >>APKBUILD<<__EOF__ cat >>APKBUILD<<__EOF__
make DESTDIR="\$pkgdir" install make DESTDIR="\$pkgdir" install
@ -208,7 +233,7 @@ __EOF__
| head -n 1 | grep -q ".*" \ | head -n 1 | grep -q ".*" \
|| sed -i -e '/^depends_dev=.*/d' -e 's/\$depends_dev\s*//' APKBUILD || sed -i -e '/^depends_dev=.*/d' -e 's/\$depends_dev\s*//' APKBUILD
# Check if its autotools # Try to autodetect the buildtype
if [ -z "$buildtype" ]; then if [ -z "$buildtype" ]; then
if [ -x "$sdir"/configure ]; then if [ -x "$sdir"/configure ]; then
buildtype="autotools" buildtype="autotools"
@ -216,6 +241,8 @@ __EOF__
buildtype="perl" buildtype="perl"
elif [ -r "$sdir"/waf ]; then elif [ -r "$sdir"/waf ]; then
buildtype="waf" buildtype="waf"
elif [ -r "$sdir"/meson.build ]; then
buildtype="meson"
elif [ -d "$sdir"/cmake ] || [ -r "$sdir/CMakeLists.txt" ]; then elif [ -d "$sdir"/cmake ] || [ -r "$sdir/CMakeLists.txt" ]; then
buildtype="cmake" buildtype="cmake"
elif [ -r "$sdir"/Makefile ]; then elif [ -r "$sdir"/Makefile ]; then
@ -236,6 +263,8 @@ __EOF__
build_make;; build_make;;
cmake) cmake)
build_cmake;; build_cmake;;
meson)
build_meson;;
autotools) autotools)
build_autotools;; build_autotools;;
perl) perl)
@ -260,6 +289,8 @@ __EOF__
package_make;; package_make;;
autotools) autotools)
package_autotools;; package_autotools;;
meson)
package_meson;;
perl) perl)
package_perl;; package_perl;;
python) python)
@ -293,8 +324,9 @@ usage() {
-d Set package description (pkgdesc) to DESC -d Set package description (pkgdesc) to DESC
-l Set package license to LICENSE -l Set package license to LICENSE
-u Set package URL -u Set package URL
-a Create autotools (use ./configure ...) -a Create autotools package (use ./configure ...)
-C Create CMake pakckage (Assume cmake/ is there) -C Create CMake pakckage (Assume cmake/ is there)
-m Create meson package (Assume meson.build is there)
-p Create perl package (Assume Makefile.PL is there) -p Create perl package (Assume Makefile.PL is there)
-y Create python package (Assume setup.py is there) -y Create python package (Assume setup.py is there)
-s Use sourceforge source URL -s Use sourceforge source URL
@ -305,11 +337,12 @@ usage() {
__EOF__ __EOF__
} }
while getopts "acd:fhl:n:pyu:s" opt; do while getopts "acmd:fhl:n:pyu:s" opt; do
case $opt in case $opt in
'a') buildtype="autotools";; 'a') buildtype="autotools";;
'c') cpinitd=1;; 'c') cpinitd=1;;
'C') buildtype="cmake";; 'C') buildtype="cmake";;
'm') buildtype="meson";;
'd') pkgdesc="$OPTARG";; 'd') pkgdesc="$OPTARG";;
'f') force=1;; 'f') force=1;;
'h') usage; exit;; 'h') usage; exit;;