automake: process a configuration file - automake

I'm wondering how to process a data template so as to install properly configurations files
accordingly to "make distcheck".
For instance I try severals ways like this but either the template (here rsyslog.conf) is finally installed by "make install" or it leaks for "make distcheck".
The one bellow is based on this thread :
Install data directory tree with massive number of files using automake
rsyslogdir = $(sysconfdir)/rsyslog.d
dist_rsyslog_DATA = $(name).conf
install-data-hook: rsyslog.conf
cp rsyslog.conf $(name)$.conf
sed $(rsyslogdir)$(name).conf -i -e \
"s!TEMPLATE!$(name)!"
Do I have to process my template file like a source file even if it concern a configuration file ?
Thanks for your advices.

So, I continue on my first tries and it finaly works.
Thanks William.
EXTRA_DIST = rsyslog.conf
rsyslogdir = $(sysconfdir)/rsyslog.d
dist_rsyslog_DATA = $(name).conf
$(name).conf: rsyslog.conf
sed rsyslog.conf \
-e "s!TEMPLATE!$(name)!" \
> $#
clean-local:
rm -f $(name).conf

Related

Looping through files defined by `*` in a variable in BASH

I want to be able to specify a directory with fastq files with a script that will loop through all the files and do some stuff. Here is my attempt:
threads=24
current_path=`pwd`
input_file=${current_path}/raw/
files=${current_path}/raw/*
for file in ${files}; do
output_file=${current_path}/${file}_out/
mkdir -m gu=wrx,o=rx ${output_file}
spades.py \
--s1 ${input_file}${file} \
-t ${threads} \
--plasmid \
--careful \
-o ${output_file}
done
So in this script I get an error: cannot make directory, directory does not exist The script generates a /home folder. I don't know if I am specifying the files incorrectly or if I am using the for loop incorrectly.
Thank you!
you concatenate full path to file with folder in line
output_file=${current_path}/${file}_out/
it should be
output_file=${file}_out/

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.
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.
EXTRA_DIST variable sounds like the thing.

Why command "go clean -n -r -i github.com/ethereum/go-ethereum..." does not work?

What I did were as follows step by step:
Git clone go-ethereum project to my local PC. It is located in
D:\GOPATH\src\github.com\ethereum\go-ethereum. It is the source code
of go-ethereum
Note: The OS is windows 7. Go has already been installed. And GOPATH env has already been set to "D:\GOPATH"
cd /d D:\GOPATH\src\github.com\ethereum\go-ethereum. Then execute
"go install". Some exe files were genereated under D:\GOPATH\bin
directory, and many pkg file with suffix .a were generated under
D:\GOPATH\pkg directory. Everything seems no problem.
Execute "go clean -n -r -i github.com/ethereum/go-ethereum..." to
remove all the generated exe files and .a files. But something very
interesting happened:
In the command's log, it showed that some files are deleted, but actually they are not deleted from disk.
For example, event.a exists under D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum, but the log of "git clean" shows:"rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\event.a"
The detailed information is in the attached images.
It is very strange. The log does not match with the actual result:
A small segment of go clean command is as follows(since there are more than 1300 lines in log, I can not paste all of it):
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\event
rm -f event.test event.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\event.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\common\mclock
rm -f mclock.test mclock.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\common\mclock.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\vendor\github.com\aristanetworks\goarista\monotime
rm -f monotime.test monotime.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\vendor\github.com\aristanetworks\goarista\monotime.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\accounts\abi
rm -f abi.test abi.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\accounts\abi.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\accounts\abi\bind
rm -f bind.test bind.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\accounts\abi\bind.a
But some of the files remain:
The correct answer is actually provided by #Peter in comment. As Peter said "The -n flag causes clean to print the remove commands it would execute, but not run them."
I tried "-x" instead of "-n", and it works well. Thanks Peter. But you posted your answer in comment section, so I have to post your answer here and close this question.

How to execute a make target on file change automatically?

How do I write a make target that will watch for any file changes in specific folders and execute some other make target to compile files? I am looking for a way that can do this with minimal dependency on tools in addition to make itself to keep things simple.
For the watching you can use fswatch. (There's also a go version of this program which may be easier to install: fswatch) For example:
fswatch -ext cpp,c,h make -f Makefile
Anytime you change a cpp, c or h file it will run make again.
Make can be a bit slow for this, so I tend to use ninja instead, but that really depends on the size of your project.
Another option is tup, which has watching built-in:
tup monitor
But, sadly, only for linux.
You can use entr and adjust your Makefile similar to this one
.DEFAULT_GOAL := run
SHELL := /bin/bash
run:
clear && \
cp one.txt two.txt && \
rm -f _* *.l2m *.o2m && \
Ganlib < testgan2.x2m
watch:
while sleep 1 ; do find . -name '*.x2m' -o -name '*.c2m' \
| entr -d make -f ./Makefile ; done
.PHONY: run watch
followed by
$ make watch

Download data from FTP Website

There is something which I am missing or might be the whole case. So I am trying to download NCDC data from NCDC Datasets and unable to do it the unix box.
The command which I have used this far are
wget ftp://ftp.ncdc.noaa.gov:21/pub/data/noaa/1901/029070-99999-1901.gz">029070-99999-1901.gz
This is for one file, but will be very happy if I can downlaod the entire parent directory.
You seem to have a lonely " just before the >
to download everything you can try this command to get the whole directory content
wget -r ftp://ftp.ncdc.noaa.gov:21/pub/data/noaa/1901/*
for i in {1990..1993}
do
echo "$i"
cd /home/chile/data
# -nH Disable generation of host-prefixed directories
# -nd all files will get saved to the current directory
# -np Do not ever ascend to the parent directory when retrieving recursively.
# -R index.html*,227070*.gz* don't download files with this regex
wget -r -nH -nd -np -R *.html,999999-99999-$i.gz* http://www1.ncdc.noaa.gov/pub/data/noaa/$i/
/data/noaa/$i/
done

Resources