odysseasg
odysseasg

Reputation: 121

Make distcheck doesn't copy all sources

My project is structured as followed:

/ subdir1 subdir2 subdir3 common_include

Each subdir compiles different binaries and libs for my project. common_include includes .h (C++ headers) included by all my subdirs.

These headers files are NOT added to each Makefile.am in the SOURCES attribute. But I add the following path -I../common_include to the CPPFLAGS attribute

I use GNU build system for configuration. Everything is working.

But when I want to release the project by typing: make distcheck in order to create: my-project-1.0.tar.gz, the archive is successfully created.

But it contains all subdirs and not the common_include directory. So the final user can't compile..

Any help ?

Thank you

Upvotes: 2

Views: 2923

Answers (2)

rra
rra

Reputation: 3887

It sounds like you have a hierarchy of Makefile.am files, one in each directory. One simple fix to this problem would be to edit the Makefile.am at the top level of your whole project and add to it:

EXTRA_DIST = common_include/header.h common_include/other-header.h # ...

and so on, listing all of the headers. EXTRA_DIST is used by Automake to name other files that should be included in the distribution even if they're not referenced by any other rule that Automake is aware of, and is a good general mechanism to use to solve problems of this sort.

Upvotes: 4

ldav1s
ldav1s

Reputation: 16315

You need to add the header files in common_include to your SOURCES somewhere. Otherwise they won't be packaged in the tarball for make dist. In this case make distcheck should fail. As stated in my comment, I think make distcheck is indeed failing. You should check around in your working directory for evidence of this. There'll probably be a directory _build and a directory _inst and probably a directory my-project-1.0 that aren't part of your directory structure.

EDIT: Here's how I'd do it:

configure.ac

AC_PREREQ([2.62])
AC_INIT([my-project], [1.0.0], [[email protected]], [my-project])
AC_CONFIG_SRCDIR([subdir1/foo.cc])
LT_PREREQ([2.2.4])
AC_CANONICAL_SYSTEM

AM_INIT_AUTOMAKE
LT_INIT

AC_PROG_CXX
AC_PROG_MAKE_SET
AC_SUBST([LIBTOOL_DEPS])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Typical boilerplate stuff. Not much to see, except for the C++ compiler.

Makefile.am

AUTOMAKE_OPTIONS = 1.11 foreign

bin_PROGRAMS = baz
lib_LTLIBRARIES=libfoo.la libbar.la

baz_SOURCES=$(top_srcdir)/subdir3/baz.cc \
$(top_srcdir)/common_include/bar.hpp \
$(top_srcdir)/common_include/foo.hpp
baz_CXXFLAGS=-I$(top_srcdir)/common_include
baz_LDADD=libfoo.la libbar.la

libfoo_la_CXXFLAGS=-I$(top_srcdir)/common_include
libfoo_la_SOURCES=$(top_srcdir)/subdir1/foo.cc \
$(top_srcdir)/common_include/foo.hpp

libbar_la_CXXFLAGS=-I$(top_srcdir)/common_include
libbar_la_SOURCES=$(top_srcdir)/subdir2/bar.cc \
$(top_srcdir)/common_include/bar.hpp

Made two libraries and a program that depends on them with headers in common_include. In order to package things you really only need to reference the header files once for some object. I always explicitly list them mainly for documenting them. The autoconf system is smart enough to build the correct dependencies for headers.

In case you were wondering, make distcheck does indeed work:

my-project-1.0.0.tar.gz

my-project-1.0.0/
my-project-1.0.0/ltmain.sh
my-project-1.0.0/configure.ac
my-project-1.0.0/install-sh
my-project-1.0.0/missing
my-project-1.0.0/subdir2/
my-project-1.0.0/subdir2/bar.cc
my-project-1.0.0/subdir3/
my-project-1.0.0/subdir3/baz.cc
my-project-1.0.0/Makefile.in
my-project-1.0.0/subdir1/
my-project-1.0.0/subdir1/foo.cc
my-project-1.0.0/common_include/
my-project-1.0.0/common_include/bar.hpp
my-project-1.0.0/common_include/foo.hpp
my-project-1.0.0/config.sub
my-project-1.0.0/configure
my-project-1.0.0/config.guess
my-project-1.0.0/aclocal.m4
my-project-1.0.0/Makefile.am
my-project-1.0.0/depcomp

Upvotes: 2

Related Questions