You are not logged in.

#1 2023-11-19 22:08:56

UweSauter
Member
Registered: 2021-02-10
Posts: 7

[Solved] Remove LDFLAGS from makepkg.conf in PKGBUILD

I'm trying to write a PKGBUILD for the LinuxCNC EtherCAT HAL driver:

pkgname=linuxcnc-ethercat-git
pkgver=r310.0a82ed9
pkgrel=1
pkgdesc="HAL glue code between Etherlab's EtherCAT driver and LinuxCNC"
url="https://github.com/linuxcnc-ethercat/linuxcnc-ethercat"
license=('GPL2')
source=("${pkgname%-git}::git+${url}.git")
md5sums=('SKIP')
arch=('aarch64' 'armv7h' 'x86_64')
depends=('etherlab-ethercat-tools' 'linuxcnc')
makedepends=('git')
conflicts=("${pkgname%-git}")
provides=("${pkgname%-git}")

pkgver() {
	cd "${srcdir}/${pkgname%-git}"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
	cd "${srcdir}/${pkgname%-git}"
	make V=1
}

package() {
	cd "${srcdir}/${pkgname%-git}"
	make DESTDIR="${pkgdir}/" install
}

This works in principle but I had to learn that the LDFLAGS from makepkg.conf cause linker problems.

If I build the package with makepkg the shared library lcec.so is only linked against a bare minimum of libraries:

$ ldd src/linuxcnc-ethercat/src/lcec.so
ldd: warning: you do not have execution permission for `src/linuxcnc-ethercat/src/lcec.so'
	linux-vdso.so.1 (0x00007ffcf554b000)
	libm.so.6 => /lib/libm.so.6 (0x00007ffa9bb1f000)
	libc.so.6 => /lib/libc.so.6 (0x00007ffa9b93d000)
	/usr/lib64/ld-linux-x86-64.so.2 (0x00007ffa9bc38000)

On the other hand if I build the software by either running make manually or by setting LDFLAGS="" in makepkg.conf the library is linked correctly:

$ ldd src/linuxcnc-ethercat/src/lcec.so
ldd: warning: you do not have execution permission for `src/linuxcnc-ethercat/src/lcec.so'
	linux-vdso.so.1 (0x00007ffc857b3000)
	liblinuxcnchal.so.0 => /lib/liblinuxcnchal.so.0 (0x00007f02dc094000)
	libethercat.so.1 => /lib/libethercat.so.1 (0x00007f02dc089000)
	libm.so.6 => /lib/libm.so.6 (0x00007f02dbf9c000)
	libc.so.6 => /lib/libc.so.6 (0x00007f02dbdba000)
	libtirpc.so.3 => /usr/lib/libtirpc.so.3 (0x00007f02dbd66000)
	libgpiod.so.2 => /usr/lib/libgpiod.so.2 (0x00007f02dbd5b000)
	/usr/lib64/ld-linux-x86-64.so.2 (0x00007f02dc0ce000)
	libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007f02dbd05000)
	libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007f02dbc2d000)
	libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007f02dbbff000)
	libcom_err.so.2 => /usr/lib/libcom_err.so.2 (0x00007f02dbbf9000)
	libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007f02dbbeb000)
	libkeyutils.so.1 => /usr/lib/libkeyutils.so.1 (0x00007f02dbbe4000)
	libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007f02dbbd1000)

Now, the correct way to resolve the issue is probably to rewrite the Makefile provided by the package. Having no experience at all in writing Makefiles I think the easier way would be to remove or overwrite the LDFLAGS provided by makepkg.conf if possible.

So the question is: Is it possible to ignore the LDFLAGS from makepkg.conf?

I'd be grateful for any hints for either ignoring the options or rewriting the Makefiles.

Last edited by UweSauter (2023-11-19 22:41:13)

Offline

#2 2023-11-19 22:11:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [Solved] Remove LDFLAGS from makepkg.conf in PKGBUILD

UweSauter wrote:

Now, the correct way to resolve the issue is probably to rewrite the Makefile provided by the package... I think the easier way would be to remove or overwrite the LDFLAGS provided by makepkg.conf if possible.

It's not really easier.  But it's certainly no harder either.  Forget about makepkg.conf, you're not really doing anything with that file - you just need to set an environment variable.  That's is.  So in the build function before any call to make:

   export LDFLAGS=""

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2023-11-19 22:39:48

UweSauter
Member
Registered: 2021-02-10
Posts: 7

Re: [Solved] Remove LDFLAGS from makepkg.conf in PKGBUILD

You are absolutely right.

Once you realize that this all is done in Bash and all the settings are just variables that are sourced at the beginning of the makepkg process this all becomes simpler.

Thank you.

Offline

Board footer

Powered by FluxBB