Placing header files in a subdirectory of /usr/include with automake?

10,346

Solution 1

As well as pkginclude_HEADERS, which you mention, you can also install header files into an arbitrary subdirectory of /usr/include with any name you like, like this:

otherincludedir = $(includedir)/arbitrary_name
otherinclude_HEADERS = a.h b.h

The advantage of using pkginclude_HEADERS = publicHeader.h is that in a large system, each package stay in its own subdirectory of $prefix/include and avoids the chance of overwriting headers from different package with the same name. Furthermore, this naming convention helps users easily locate the header for a particular package.

Solution 2

Looks like I asked Stack Overflow too quickly ;)
With a little more searching, I found that if I use pkginclude_HEADERS instead of include_HEADERS, the headers go in /usr/include/[package name].

http://realmike.org/blog/2010/07/18/gnu-automake-by-example/

Share:
10,346

Related videos on Youtube

Delan Azabani
Author by

Delan Azabani

I’m a computer programmer based in Perth, Australia. My passions include all kinds of systems programming from Rust to x86 assembly and beyond, internationalisation and Unicode, digital preservation and archaeology, typography, cryptography, and above all, teaching. I’m also a trans woman (she/her pronouns)!

Updated on October 10, 2020

Comments

  • Delan Azabani
    Delan Azabani over 3 years

    If I write a library, and have header files for development included, and have a src/Makefile.am like this:

    AM_CFLAGS = -std=c99 -Wall -Werror -Os
    lib_LTLIBRARIES = libmylibrary.la
    libmylibrary_la_SOURCES = a.c b.c
    include_HEADERS = a.h b.h
    

    Everything works nicely. However, a.h and b.h are installed directly under /usr/include (or /usr/local/include). What should I do to get them installed, in a subdirectory specific to my library, e.g. /usr/include/mylibrary?

  • Mark Harviston
    Mark Harviston over 11 years
    I keep getting Makefile.am:9: error: 'otherinclude_HEADERS' is used but 'otherincludedir' is undefined (figured it out, I needed to use a name specified as a subdir, in this case 'include' instead of 'otherinclude')
  • Mark Harviston
    Mark Harviston over 11 years
    (nope that didn't work, it keeps going to include/PropID.h instead of includes/7zip/PropID.h)
  • Mark Harviston
    Mark Harviston over 11 years
    (derp, I'm dyslexic, otherincludedir not just otherinclude)
  • LPs
    LPs about 8 years
    Have you ever managed to avoid placing header into [package name]subdir? I mean: could be all headers installed directly into /usr/include/?
  • Vadim Kotov
    Vadim Kotov over 6 years
    @LPs Did not quite understand what you are asking about. As Delan said earlier, he used include_HEADERS and files were installed directly under /usr/include