The extra creativity offered by libraries comes at a cost: you have to
actually write your main
function and get your hands dirty in
managing user inputs: are all the necessary parameters given a value? is
the input in the correct format? do the options and the inputs correspond?
and many other similar checks. So when an operation has well-defined inputs
and outputs and is commonly needed, it is much more worthwhile to simply do
use all the great features that Gnuastro has already defined for such
operations.
To make it easier to learn/apply the internal program infra-structure discussed in Mandatory source code files, in the Version controlled source, Gnuastro ships with a template program. This template program is not available in the Gnuastro tarball so it does not confuse people using the tarball. The bin/TEMPLATE directory in Gnuastro’s Git repository contains the bare-minimum files necessary to define a new program and all the basic/necessary files/functions are pre-defined there.
Below you can see a list of initial steps to take for customizing this template. We just assume that after cloning Gnuastro’s history, you have already bootstrapped Gnuastro, if not, please see Bootstrapping.
$ cp -R bin/TEMPLATE bin/myprog
AC_CONFIG_FILES
, only here the
ordering depends on the length of the name (it is not alphabetical).
SUBDIRS
.
dist_man_MANS
). Then scroll down and add a rule to build the
man-page similar to the other existing rules (in alphabetical order). Do Not
forget to add a short one-line description here, it will be displayed on
top of the man-page.
TEMPLATE.c
and TEMPLATE.h
to myprog.c
and
myprog.h
in the file names:
$ cd bin/myprog $ mv TEMPLATE.c myprog.c $ mv TEMPLATE.h myprog.h
TEMPLATE
in the input files to
myprog
(in short or long format). You can get a list of all
occurrences with the following command. If you use Emacs, it will be able to
parse the Grep output and open the proper file and line automatically. So
this step can be very easy.
$ grep --color -nHi -e template *
$ autoreconf -f $ ./configure $ make
make check
, see Test scripts. Finally, if you would like to
share it with all Gnuastro users, inform us so we merge it into Gnuastro’s
main history.
GNU Astronomy Utilities 0.20 manual, April 2023.