Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Sep 2007 13:42:26 +0200
From:      Karol Kwiatkowski <karol.kwiat@gmail.com>
To:        freebsd-ports@freebsd.org
Subject:   Re: How to get a static binary from ports
Message-ID:  <46E13922.4060004@gmail.com>
In-Reply-To: <46DEF93B.5050902@gmail.com>
References:  <46DEF93B.5050902@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigBBAD6BB49E258888BB520B0C
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable

Karol Kwiatkowski wrote:
> Hi all,
>=20
> to keep it short:
>=20
> is there any ports knob to statically link binaries?
> If not, what steps should I take to modify a port?
>=20
> longer version:
>=20
> I'm trying to get a static binary out of the port. I thought it should
> be straight and easy, but I'm lost right now.
>=20
> The port in question is databases/rrdtool, uses libtool:15, gnu
> configure, gmake, etc.
>=20
> Normally, this port builds rrdtool binary which is dynamically linked
> (full path removed for brevity):
>=20
> # ldd (...)/work/rrdtool-1.2.23/src/.libs/rrdtool
> (...)/work/rrdtool-1.2.23/src/.libs/rrdtool:
>     librrd.so.2 =3D> not found (0x0)
>     libfreetype.so.9 =3D> /usr/local/lib/libfreetype.so.9 (0x28085000)
>     libpng.so.5 =3D> /usr/local/lib/libpng.so.5 (0x280ef000)
>     libz.so.4 =3D> /lib/libz.so.4 (0x28115000)
>     libart_lgpl_2.so.5 =3D> /usr/local/lib/libart_lgpl_2.so.5 (0x281270=
00)
>     libm.so.5 =3D> /lib/libm.so.5 (0x2813c000)
>     libc.so.7 =3D> /lib/libc.so.7 (0x28151000)
>=20
> With 'make CFLAGS+=3D-static' I get:
>=20
> # ldd (...)/work/rrdtool-1.2.23/src/rrdtool
> (...)/work/rrdtool-1.2.23/src/rrdtool:
>     libfreetype.so.9 =3D> /usr/local/lib/libfreetype.so.9 (0x280cb000)
>     libpng.so.5 =3D> /usr/local/lib/libpng.so.5 (0x28135000)
>     libz.so.4 =3D> /lib/libz.so.4 (0x2815b000)
>     libart_lgpl_2.so.5 =3D> /usr/local/lib/libart_lgpl_2.so.5 (0x2816d0=
00)
>     libm.so.5 =3D> /lib/libm.so.5 (0x28182000)
>     libc.so.7 =3D> /lib/libc.so.7 (0x28197000)
>=20
> librrd.so.2 is now included statically, but the rest is not. I tried
> various configure options like --enable-static, --disable-shared, also
> added '-static' to CFLAGS and/or LDFLAGS in Makefile plus various
> combinations of the above but that doesn't make a difference.
>=20
> How can I include the rest of the libraries in the binary?

OK, it seems it's a problem with rrdtool's build suite, and not only
I've got problems with it[1].

For the archives, in case of rrdtool's port, a simple workaround is to
patch src/Makefile (exists after 'configure' part, so those patches are
host's dependent):

# cat src_Makefile.patch
--- src/Makefile.orig   2007-09-06 14:01:07.000000000 +0200
+++ src/Makefile        2007-09-06 15:13:15.000000000 +0200
@@ -183,7 +183,7 @@
 INSTALL_PROGRAM =3D install  -s -o root -g wheel -m 555
 INSTALL_SCRIPT =3D install  -o root -g wheel -m 555
 INSTALL_STRIP_PROGRAM =3D ${SHELL} $(install_sh) -c -s
-LDFLAGS =3D -L/usr/local/lib
+LDFLAGS =3D -all-static -L/usr/local/lib
 LIBOBJS =3D
 LIBS =3D
 LIBTOOL =3D $(SHELL) /usr/local/bin/libtool


And while we're here it might be worth changing path to default font so
the binary can work as a 'standalone' (here to 'current'):

@@ -301,7 +301,7 @@
 #
 #ACLOCAL_M4       =3D $(top_srcdir)/config/aclocal.m4
 #AUTOHEADER =3D ${SHELL}
/mnt/big/FreeBSD/work/usr/ports/databases/rrdtool/work/rrdtool-1.2.23/mis=
sing
--run autoheader --localdir=3D$(top_srcdir)/config
-fontsdir =3D $(datadir)/rrdtool/fonts
+fontsdir =3D .
 fonts_DATA =3D DejaVuSansMono-Roman.ttf
 AM_CPPFLAGS =3D -DRRD_DEFAULT_FONT=3D\"$(RRD_DEFAULT_FONT)\" -DNUMVERS=3D=
1.2023
 UPD_C_FILES =3D \


Cheers and thanks for the pointers.

Karol

[1] http://ramblingfoo.blogspot.com/2007/08/softfloat-rrdtool-sequel.html=


--=20
Karol Kwiatkowski   <karol.kwiat at gmail dot com>
OpenPGP 0x06E09309


--------------enigBBAD6BB49E258888BB520B0C
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBRuE5IghgT0HIecD5AQjaLwf+NIw0pb+QGSlwMgL65TTZP8WmQDrvgi2Z
Fb76QUaJwXYClrnXgC5Rhf038Ns3MDMyeoE/jEEwbGQAhCfDgOGI3BKSuY9m5J7Z
KSMt8Kihp3S36wGDWpWqE1z8AxdGSnTTbvO7u5VCVtAIviAqIujnTirXxGUAg4KP
2kQw3n7C1it0leqNB9Ce1N848UZbisMiKjF/mcbKHZ8Vcu8giVvGe/EnYlaD5j55
SD0WIpZTtRJut5/sC4w8dwrwKoAICL5T9yqS1A0PH126X2xDSMBly8+HQuAdVDIx
3tC4PeOQIT95xTG910Xd09+smpLNIrEIzjhLHIl7WYMuMM0Hm786mw==
=M8SZ
-----END PGP SIGNATURE-----

--------------enigBBAD6BB49E258888BB520B0C--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46E13922.4060004>