gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 9ef8ced 3/3: Version function for library alon


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 9ef8ced 3/3: Version function for library along with a test
Date: Sat, 3 Sep 2016 16:31:32 +0000 (UTC)

branch: master
commit 9ef8cedff121ba2573d789e048f3bd1d9a1ebf69
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Version function for library along with a test
    
    The new `gnuastro.c' and `gnuastro/gnuastro.h' were added to the
    libraries. Currently they just contain a `gal_gnuastro_version' function.
    This function can be used to get the version of Gnuastro within a C
    program. The `gnuastro/gnuastro.h' header is mainly for such functions that
    are to do with Gnuastro its self. A test was also written for this library
    function.
    
    This test can be used as a template to add future library tests. Since this
    test doesn't have any dependencies, no dependencies were defined for it for
    parallel tests. However if future library tests have dependencies, their
    dependencies can be included exactly like the `.sh' dependencies.
    
    In the process, an indentation was added to the multi-line values of some
    automake variables in `lib/Makefile.am' and `tests/Makefile.am' to make
    them more readable.
---
 lib/Makefile.am         |   26 ++++++++--------
 lib/gnuastro.c          |   42 ++++++++++++++++++++++++++
 lib/gnuastro/gnuastro.h |   31 +++++++++++++++++++
 tests/Makefile.am       |   76 +++++++++++++++++++++++++++++++++++------------
 tests/lib/version.c     |   45 ++++++++++++++++++++++++++++
 5 files changed, 187 insertions(+), 33 deletions(-)

diff --git a/lib/Makefile.am b/lib/Makefile.am
index aa64c58..822d9bf 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -19,26 +19,24 @@
 ## along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
 
 
-
-
-# Define the main library file
+# Define the main compiled library file
 lib_LTLIBRARIES = libgnuastro.la
 
 
 # Specify the library .c files
-libgnuastro_la_SOURCES = arraymanip.c box.c checkset.c configfiles.c     \
-  fits.c linkedlist.c mesh.c mode.c polygon.c qsort.c spatialconvolve.c        
  \
-  statistics.c threads.c timing.c txtarray.c wcs.c
+libgnuastro_la_SOURCES = arraymanip.c box.c checkset.c configfiles.c      \
+  fits.c gnuastro.c linkedlist.c mesh.c mode.c polygon.c qsort.c          \
+  spatialconvolve.c statistics.c threads.c timing.c txtarray.c wcs.c
 
 
 # Specify the installed headers, note that we are not blindly including all
-# `.h' files in the headersdir directory. Some of the header files don't
+# `.h' files in the $(headersdir) directory. Some of the header files don't
 # need to be installed.
 headersdir=$(top_srcdir)/lib/gnuastro
-pkginclude_HEADERS = $(headersdir)/arraymanip.h $(headersdir)/box.h       \
-  $(headersdir)/checkset.h $(headersdir)/configfiles.h                    \
-  $(headersdir)/fits.h $(headersdir)/linkedlist.h $(headersdir)/mesh.h    \
-  $(headersdir)/mode.h $(headersdir)/polygon.h $(headersdir)/qsort.h      \
-  $(headersdir)/spatialconvolve.h $(headersdir)/statistics.h              \
-  $(headersdir)/threads.h $(headersdir)/timing.h $(headersdir)/txtarray.h \
-  $(headersdir)/wcs.h
+pkginclude_HEADERS = $(headersdir)/arraymanip.h $(headersdir)/box.h        \
+  $(headersdir)/checkset.h $(headersdir)/configfiles.h                     \
+  $(headersdir)/fits.h $(headersdir)/gnuastro.h $(headersdir)/linkedlist.h \
+  $(headersdir)/mesh.h $(headersdir)/mode.h $(headersdir)/polygon.h        \
+  $(headersdir)/qsort.h $(headersdir)/spatialconvolve.h                    \
+  $(headersdir)/statistics.h $(headersdir)/threads.h                       \
+  $(headersdir)/timing.h $(headersdir)/txtarray.h $(headersdir)/wcs.h
diff --git a/lib/gnuastro.c b/lib/gnuastro.c
new file mode 100644
index 0000000..578eef5
--- /dev/null
+++ b/lib/gnuastro.c
@@ -0,0 +1,42 @@
+/*********************************************************************
+Functions dealing with general aspects of all Gnuastro.
+
+Original author:
+     Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <string.h>
+
+#include "gnuastro/checkset.h"
+#include "gnuastro/gnuastro.h"
+
+
+/* Return the version of Gnuastro. If the input argument is pointing to a
+   NULL pointer, then allocate the necessary space and copy version into
+   it. Otherwise, assume that the user has allocated the necessary space
+   (either statically or dynamically) and just copy the PACKAGE_VERSION
+   macro into the given pointer. The returned value is the pointer that the
+   arument is pointing to, so both can be used.*/
+char *
+gal_gnuastro_version(void)
+{
+  char *version=NULL;
+  gal_checkset_allocate_copy(PACKAGE_VERSION, &version);
+  return version;
+}
diff --git a/lib/gnuastro/gnuastro.h b/lib/gnuastro/gnuastro.h
new file mode 100644
index 0000000..16426ac
--- /dev/null
+++ b/lib/gnuastro/gnuastro.h
@@ -0,0 +1,31 @@
+/*********************************************************************
+Functions dealing with general aspects of all Gnuastro.
+
+Original author:
+     Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef __GAL_GNUASTRO_H__
+#define __GAL_GNUASTRO_H__
+
+
+
+/* Report the Gnuastro version number. */
+char *
+gal_gnuastro_version(void);
+
+#endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b7793c6..fb5943d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,6 +18,12 @@
 ## You should have received a copy of the GNU General Public License
 ## along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
 
+
+
+
+
+# Translate conditions that came from `./configure' into variables that can
+# be used here.
 if COND_HASGHOSTSCRIPT
   MAYBE_HASGHOSTSCRIPT = "yes"
 endif
@@ -25,33 +31,66 @@ if COND_HASLIBJPEG
   MAYBE_HASLIBJPEG = "yes"
 endif
 
+
+
+
+
+# Environment variables for the test scripts.
 AM_TESTS_ENVIRONMENT =                              \
 export topsrc=$(top_srcdir);                        \
 export haslibjpeg=$(MAYBE_HASLIBJPEG);              \
 export hasghostscript=$(MAYBE_HASGHOSTSCRIPT);
 
+
+
+
+
+# Compilations that are to be done with `make check'.
+LDADD = -lgnuastro
+check_PROGRAMS = version
+version_SOURCES = lib/version.c
+
+
+
+
+# The actual test scripts that are run:
 TESTS = prepconf.sh mkprof/mosaic1.sh mkprof/mosaic2.sh mkprof/mosaic3.sh   \
-mkprof/mosaic4.sh mkprof/radeccat.sh imgcrop/imgcat.sh imgcrop/wcscat.sh    \
-imgcrop/xcyc.sh imgcrop/xcycnoblank.sh imgcrop/section.sh imgcrop/radec.sh  \
-imgcrop/imgpolygon.sh imgcrop/imgoutpolygon.sh imgcrop/wcspolygon.sh        \
-convertt/fitstotxt.sh convertt/fitstojpeg.sh convertt/blankch.sh            \
-convertt/jpegtotxt.sh convertt/fitstojpegcmyk.sh convertt/jpegtofits.sh     \
-convertt/fitstopdf.sh convolve/spatial.sh convolve/frequency.sh             \
-imgwarp/imgwarp_scale.sh imgwarp/homographic.sh mknoise/addnoise.sh         \
-mkprof/ellipticalmasks.sh mkprof/inputascanvas.sh header/write.sh           \
-header/print.sh header/update.sh header/delete.sh imgstat/basicstats.sh     \
-subtractsky/subtractsky.sh noisechisel/noisechisel.sh mkcatalog/simple.sh   \
-mkcatalog/aperturephot.sh arithmetic/snimage.sh arithmetic/onlynumbers.sh   \
-arithmetic/where.sh cosmiccal/simpletest.sh table/asciitobinary.sh          \
-table/binarytoascii.sh
-
-EXTRA_DIST = $(TESTS) during-dev.sh mkprof/mkprofcat1.txt                  \
-mkprof/ellipticalmasks.txt mkprof/inputascanvas.txt mkprof/mkprofcat2.txt  \
-mkprof/mkprofcat3.txt mkprof/mkprofcat4.txt mkprof/radeccat.txt            \
-imgcrop/cat.txt table/asciitobinary.txt
+  mkprof/mosaic4.sh mkprof/radeccat.sh imgcrop/imgcat.sh imgcrop/wcscat.sh  \
+  imgcrop/xcyc.sh imgcrop/xcycnoblank.sh imgcrop/section.sh                 \
+  imgcrop/radec.sh imgcrop/imgpolygon.sh imgcrop/imgoutpolygon.sh           \
+  imgcrop/wcspolygon.sh convertt/fitstotxt.sh convertt/fitstojpeg.sh        \
+  convertt/blankch.sh convertt/jpegtotxt.sh convertt/fitstojpegcmyk.sh      \
+  convertt/jpegtofits.sh convertt/fitstopdf.sh convolve/spatial.sh          \
+  convolve/frequency.sh imgwarp/imgwarp_scale.sh imgwarp/homographic.sh     \
+  mknoise/addnoise.sh mkprof/ellipticalmasks.sh mkprof/inputascanvas.sh     \
+  header/write.sh header/print.sh header/update.sh header/delete.sh         \
+  imgstat/basicstats.sh subtractsky/subtractsky.sh                          \
+  noisechisel/noisechisel.sh mkcatalog/simple.sh mkcatalog/aperturephot.sh  \
+  arithmetic/snimage.sh arithmetic/onlynumbers.sh arithmetic/where.sh       \
+  cosmiccal/simpletest.sh table/asciitobinary.sh table/binarytoascii.sh     \
+  $(check_PROGRAMS)
+
+
+
+
+
+# Files to distribute along with the tests.
+EXTRA_DIST = $(TESTS) during-dev.sh mkprof/mkprofcat1.txt                   \
+  mkprof/ellipticalmasks.txt mkprof/inputascanvas.txt                       \
+  mkprof/mkprofcat2.txt mkprof/mkprofcat3.txt mkprof/mkprofcat4.txt         \
+  mkprof/radeccat.txt imgcrop/cat.txt table/asciitobinary.txt
+
+
 
+
+
+# Files that must be cleaned with `make clean'.
 CLEANFILES = *.log *.txt *.jpg *.fits *.pdf *.eps
 
+
+
+
+
 # CLEANFILES is only for files, not directories. Therefore we are using
 # Automake's extending rules to clean the temporary `.gnuastro' directory
 # that was built by the `prepconf.sh' scripot. See "Extending Automake
@@ -73,7 +112,6 @@ clean-local:; rm -rf .gnuastro
 ## IMPORTANT: So even if the program fails, the .log file is created. The
 ## check if the input for a test exists or not should be checked in the
 ## test that depends on it, it can't be done here in the Makefile.
-
 mkprof/mosaic1.sh: prepconf.sh.log
 mkprof/mosaic2.sh: prepconf.sh.log
 mkprof/mosaic3.sh: prepconf.sh.log
diff --git a/tests/lib/version.c b/tests/lib/version.c
new file mode 100644
index 0000000..2044823
--- /dev/null
+++ b/tests/lib/version.c
@@ -0,0 +1,45 @@
+/*********************************************************************
+A test program to get and use the version number of Gnuastro within C.
+
+Original author:
+     Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2015, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gnuastro/gnuastro.h"
+
+int
+main(void)
+{
+  /* Pointer to the string version */
+  char *version=NULL;
+
+  /* Fill in both with the version string. */
+  version=gal_gnuastro_version();
+
+  /* Print the version. */
+  printf("Gnuastro version is: %s\n", version);
+
+  /* Free the allocated space for the version. */
+  free(version);
+
+  /* Cleanup and return */
+  return EXIT_SUCCESS;
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]