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

Delan Azabani picture Delan Azabani · Apr 9, 2011 · Viewed 9.8k times · Source

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?

Answer

ptomato picture ptomato · Apr 10, 2011

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.