Search code examples
shellmakefileautomake

How does "make dist" command work? I'm stuck on a script which I need to update to add new file and folder


I've to add a file and a folder to the zip that is created when I run make dist command. This is an open-source project.

After research, I understood I've to modify the Makefile.am but examples online don't work or match with my current Makefile.am

Makefile.am

SUBDIRS = bin data po src extensions docs

DISTCLEANFILES =        \
    intltool-extract    \
    intltool-merge      \
    intltool-update

EXTRA_DIST =                    \
    $(bin_SCRIPTS)      \
    intltool-merge.in       \
    intltool-update.in      \
    intltool-extract.in

DISTCHECK_CONFIGURE_FLAGS = --disable-update-mimedb

check-po:
    @for i in $(top_srcdir)/po/*.po ; do \
        if ! grep -q ^`basename $$i | \
        sed 's,.po,,'`$$ $(top_srcdir)/po/LINGUAS ; then \
            echo '***' `basename $$i | \
            sed 's,.po,,'` missing from po/LINGUAS '***' ; \
            exit 1; \
        fi; \
    done;

lint:
    flake8 --ignore E402 $(top_srcdir)/src $(top_srcdir)/extensions

test: lint check-po
    PYTHONPATH=$(pkgdatadir)/extensions:$(PYTHONPATH) \
    python -m sugar3.test.discover $(top_srcdir)/tests

configure.ac

AC_INIT([Sugar],[0.114],[],[sugar])

AC_PREREQ([2.59])

AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([configure.ac])

SUCROSE_VERSION="0.114"
AC_SUBST(SUCROSE_VERSION)

AM_INIT_AUTOMAKE([1.9 foreign dist-xz no-dist-gzip])

AM_MAINTAINER_MODE

PYTHON=python2
AM_PATH_PYTHON

AC_PATH_PROG([EMPY], [empy])
if test -z "$EMPY"; then
    AC_MSG_ERROR([python-empy is required])
fi

PKG_CHECK_MODULES(SHELL, gtk+-3.0)

IT_PROG_INTLTOOL([0.35.0])
GETTEXT_PACKAGE=sugar
AC_SUBST([GETTEXT_PACKAGE])
AM_GLIB_GNU_GETTEXT

AC_ARG_ENABLE(update-mimedb,
   AC_HELP_STRING([--disable-update-mimedb],
                   [disable the update-mime-database after install [default=no]]),,
    enable_update_mimedb=yes)
AM_CONDITIONAL(ENABLE_UPDATE_MIMEDB, test x$enable_update_mimedb = xyes)

GLIB_GSETTINGS


AC_CONFIG_FILES([
bin/Makefile
bin/sugar
data/icons/Makefile
data/Makefile
extensions/cpsection/aboutcomputer/Makefile
extensions/cpsection/aboutme/Makefile
extensions/cpsection/background/Makefile
extensions/cpsection/backup/Makefile
extensions/cpsection/backup/backends/Makefile
extensions/cpsection/datetime/Makefile
extensions/cpsection/frame/Makefile
extensions/cpsection/keyboard/Makefile
extensions/cpsection/language/Makefile
extensions/cpsection/modemconfiguration/Makefile
extensions/cpsection/Makefile
extensions/cpsection/network/Makefile
extensions/cpsection/power/Makefile
extensions/cpsection/updater/Makefile
extensions/cpsection/webaccount/services/Makefile
extensions/cpsection/webaccount/Makefile
extensions/deviceicon/Makefile
extensions/globalkey/Makefile
extensions/webservice/Makefile
extensions/Makefile
Makefile
po/Makefile.in
src/jarabe/config.py
src/jarabe/controlpanel/Makefile
src/jarabe/desktop/Makefile
src/jarabe/frame/Makefile
src/jarabe/intro/Makefile
src/jarabe/journal/Makefile
src/jarabe/Makefile
src/jarabe/model/Makefile
src/jarabe/model/update/Makefile
src/jarabe/util/Makefile
src/jarabe/util/telepathy/Makefile
src/jarabe/view/Makefile
src/jarabe/webservice/Makefile
src/Makefile
])

AC_OUTPUT

When I run the command make dist, the output zip doesn't include a file and folder which I now need to add. I'm not able to understand where in the code(Makefile.am or configure.ac) should I make changes.


Solution

  • I've to add a file and a folder to the zip that is created when I run make dist command.

    I take it that these are not already included in the distribution. If you're not sure, then check -- Automake-based build systems such as yours identify a lot of files automatically for inclusion in distribution packages.

    Supposing that these files are not already included, there are several ways to cause them to be. Easiest would be to add them to the EXTRA_DIST variable, yielding

    EXTRA_DIST =                \
        $(bin_SCRIPTS)          \
        intltool-merge.in       \
        intltool-update.in      \
        intltool-extract.in     \
        a_directory             \
        some_file.ext
    

    Don't forget the trailing backslashes if you continue with the multiline form (which I like, as I find it much easier to read). You can specify a path to the file, the directory, or both. Do note that in the case of the directory, it will be not just the directory itself but all its contents, recursively, that are included in the distribution. This is all documented in the manual.

    If you need finer control, then there is also an extension point for managing the contents of the distribution in the form of the "dist hook". This comprises a make target named dist-hook. Like any other literal make rule in your Makefile.am, any rule you provide for building that target is copied to the final generated Makefile, and if such a rule is present then its recipe is run as part of building the distribution, after the distribution directory is otherwise populated but before the archive file is built from that. You can write more or less arbitrary shell code in that target's recipe to tweak the distribution. Follow the above link to the documentation for the gory details.