Fafaman
Fafaman

Reputation: 141

How to ease support for cross-compilation with autoconf

I maintain a package auto configuration that uses PKG_CHECK_MODULES to look for libraries my code depends on. I would like to make it easy for people aiming at cross-compiling my package: The main problem of PKG_CHECK_MODULES being that it gets BUILD system information and not HOST.

My approach is the following: I do not use a rootfs of the HOST system, but compile each packages my package depends on separately. Then, I would like to be able to force the values of DEPENDSON_LIBS or DEPENDSON_CFLAGS when calling the ./configure srcipt. Is this a good approach? How can configure.in be written to allow this?

NOTE: I tried AC_ARG_VAR without success...

Upvotes: 1

Views: 915

Answers (1)

marcin
marcin

Reputation: 3581

PKG_CHECK_MODULES first checks if host-prefix-pkg-config exists, and then fallbacks to unprefixed pkg-config (which may give confusing result).

I'm not sure if I understand your approach (the second paragraph), but anyway I'd leave setting correct paths to the user. You may add AC_CHECK_LIB after PKG_CHECK_MODULES to check if the picked library is for the same system as compiler.

The user who is cross-compiling may have host-prefix-pkg-config already installed, for example some linux distros have it packaged in addition to MinGW cross-compiler. If not, it's enough to set proper env. variables. Autotools Mythbuster recommends a wrapper that sets these variables.

As a last resort, the user can directly set *_CFLAGS and *_LIBS.

Upvotes: 1

Related Questions