Augustus icon indicating copy to clipboard operation
Augustus copied to clipboard

build system: Include and library paths hard-coded instead of using pkg-config

Open paulmenzel opened this issue 3 years ago • 1 comments

Instead of hard-coding the include and library paths, pkg-config should be used.

For example for SQLite:

https://github.com/Gaius-Augustus/Augustus/blob/47189535180344e8aa49731237f35ce30efa8395/src/Makefile#L55-L64

Instead pkg-config could be used:

INCL += $(pkg-config --cflags sqlite)
LIBS += $(pkg-config --libs sqlite)

More importantly, this should be used for the auxiliary tools, like bam2wig.

https://github.com/Gaius-Augustus/Augustus/blob/47189535180344e8aa49731237f35ce30efa8395/src/Makefile#L66-L72

For example, in our environment, the paths and arguments differ and could be detected automatically, with PKG_CONFIG_PATH set correctly.

$ PKG_CONFIG_PATH=/package/sequencer/samtools/current/lib/pkgconfig/ pkg-config --cflags htslib
-I/package/sequencer/samtools/1.10/include  
$ PKG_CONFIG_PATH=/package/sequencer/samtools/current/lib/pkgconfig/ pkg-config --libs htslib
-L/package/sequencer/samtools/1.10/lib -lhts

paulmenzel avatar Apr 12 '21 13:04 paulmenzel

It seems tempting to use pkg-config in Makefiles, but

  • pkg-config is not installed by default on all platforms (e.g. Windows, RHEL/CentOS)
  • not every library support pkg-config and provide .pc files
  • even if we use pkg-config consistently in Makefiles, we still need to adjust PKG_CONFIG_PATH for libraries that are not installed in the default locations

On the last point: It is of little use if PKG_CONFIG_PATH is edited within the Makefile, because we replace the change of variables (INCLS/LIBS) by that of PKG_CONFIG_PATH. Another possibility would be to change PKG_CONFIG_PATH outside the Makefile, but then we could also just use pkg-config outside (e.g. for the mentioned auxiliary tools bam2wig):

export PKG_CONFIG_PATH=/package/sequencer/samtools/current/lib/pkgconfig
make INCLUDES="$(pkg-config --cflags htslib)/htslib" HTSLIBS="$(pkg-config --libs htslib)"

Note: I see the problem with the "/htslib" appended to INCLUDES, but don't know a nice solution for it, because it seems that every library handles this path differently:

$ pkg-config --cflags mysqlclient
-I/usr/include/mysql
$ pkg-config --cflags htslib
-I/usr/include

hmehlan avatar Apr 16 '21 13:04 hmehlan