lib/musl: add STATIC option

Tue, 08 Oct 2019 20:04:00 +0200

author
David Demelier <markand@malikania.fr>
date
Tue, 08 Oct 2019 20:04:00 +0200
changeset 1164
872dc291306a
parent 1163
d3090b82aea1
child 1165
8d2032c88258

lib/musl: add STATIC option

lib/musl/musl.sh file | annotate | diff | comparison | revisions
--- a/lib/musl/musl.sh	Mon Oct 07 20:10:00 2019 +0200
+++ b/lib/musl/musl.sh	Tue Oct 08 20:04:00 2019 +0200
@@ -23,11 +23,18 @@
 PKGLICENSE="MIT"
 PKGSUMMARY="a new lightweight, fast, simple, free and correct C library"
 PKGDOWNLOAD="https://www.musl-libc.org/releases/$PKGNAME-$PKGVERSION.tar.gz"
+PKGOPTIONS="STATIC"
 PKGDEPENDS="linux-headers:build"
-PKGPRESERVE="lib/ld-musl-x86_64.so.1"
 
 : ${CC:=clang}
 : ${CFLAGS:=-O2}
+: ${STATIC:=no}
+
+if [ "$STATIC" = "yes" ]; then
+	with_static="--disable-shared"
+else
+	PKGPRESERVE="lib/ld-musl-x86_64.so.1"
+fi
 
 build()
 {
@@ -37,11 +44,19 @@
 
 	CC="$CC" \
 	CFLAGS="$CFLAGS" \
-	./configure --prefix=
-	make
-	make install DESTDIR=$DESTDIR
-	mkdir -p $DESTDIR/bin
-	ln -sf /lib/ld-musl-x86_64.so.1 $DESTDIR/bin/ldd
+	./configure \
+		--prefix= \
+		$with_static
+	make \
+		AR=llvm-ar \
+		RANLIB=llvm-ranlib \
+		DESTDIR=$DESTDIR \
+		all install
+
+	if [ "$STATIC" != "yes" ]; then
+		mkdir -p $DESTDIR/bin
+		ln -sf /lib/ld-musl-x86_64.so.1 $DESTDIR/bin/ldd
+	fi
 
 	cd ..
 	rm -rf $PKGNAME-$PKGVERSION

mercurial