6

Let's say I have a project like that:

(dev dir)
- README
- INSTALL
/ src
  - blah.cpp
  - blah.hpp
/ conf
  - blah_one.xml
  - blah_two.xml

I made out a configure.ac and Makefile.am to install binaries under (/usr/local)/bin . configure.ac is something like:

AC_INIT([blah], [0.1])
AC_PREREQ([2.67])
AM_INIT_AUTOMAKE([1.11])
AC_CONFIG_SRCDIR([src/blah.cpp])
AC_PROG_CXX
AC_LANG([C++])
AC_HEADER_STDC
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_OUTPUT

... Makefile is something like

SUBDIRS = src

...and src/Makefile.am is something like

bin_PROGRAMS = blah
blah_SOURCES = blah.cpp blah.hpp

It all works, and "make install" correctly install the binary under (/usr/local)/bin.

Now:

I want extend these to make the command "make install" (after configure, build and whatsoever) to install configuration files blah_one.xml and blah_two.xml under /etc/blah, and to "prepare" a log directory under /var/log/blah/

What is the correct way to do it?

ElementalStorm
  • 809
  • 12
  • 31

1 Answers1

10

Well, I'd do this:

blahconfdir=$(sysconfdir)/blah
blahconf_DATA = blah_one.xml blah_two.xml
blahlogdir = $(localstatedir)/log/blah

then when you configure:

./configure --sysconfdir=/etc --localstatedir=/var

Without knowing details of your "prepare" step, it's hard to know what needs to happen, and how to get it to happen.

ldav1s
  • 15,885
  • 2
  • 53
  • 56
  • Is it correct to assume that sysconfdir = /etc and localstatedir = /var on a "normal" linux system, and avoid the switches ? – ElementalStorm Aug 25 '11 at 23:18
  • You have to set them or invent some directories or they'll get installed under the prefix directory (/usr/local). – ldav1s Aug 25 '11 at 23:22
  • Isn't enough to specify --prefix=/ to avoid that ? – ElementalStorm Aug 25 '11 at 23:25
  • If you want. Your bin files will install in /bin, instead of /usr/bin though. – ldav1s Aug 25 '11 at 23:37
  • The autotools philosophy dictates that all files are installed under $prefix unless otherwise specified by the user, so it is necessary to specify sysconfdir and localstatedir. If you are using a package management system, you can put the switches in the build file (eg, *.spec or debian/rules). You could also specify sysconfdir and localstatedir in /usr/local/config.site. If you construct your package to always install files in /etc, you are violating the convention. – William Pursell Aug 31 '11 at 09:38