aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-29 15:44:02 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit42898f7d59e215434fa2aead84223f64b30fcee8 (patch)
tree5cdfb4c0c279c766efcbbc6c455ee58a5c8741f1 /src
parent6105a7797b96418d940ced7d88c6cf2b308b9711 (diff)
New way of injecting version information
Also, this fixes some incorrect headers and adds --version flags to programs which didn't yet have them.
Diffstat (limited to 'src')
-rw-r--r--src/ambigator.c11
-rw-r--r--src/cell_explorer.c7
-rw-r--r--src/cell_tool.c19
-rw-r--r--src/check_hkl.c18
-rw-r--r--src/compare_hkl.c17
-rw-r--r--src/crystfel_gui.c10
-rw-r--r--src/geoptimiser.c21
-rw-r--r--src/get_hkl.c18
-rw-r--r--src/indexamajig.c6
-rw-r--r--src/list_events.c14
-rw-r--r--src/make_pixelmap.c16
-rw-r--r--src/partial_sim.c25
-rw-r--r--src/partialator.c7
-rw-r--r--src/pattern_sim.c28
-rw-r--r--src/process_hkl.c28
-rw-r--r--src/render_hkl.c20
-rw-r--r--src/version.c.cmake.in13
-rw-r--r--src/version.h2
-rw-r--r--src/whirligig.c16
19 files changed, 196 insertions, 100 deletions
diff --git a/src/ambigator.c b/src/ambigator.c
index a172df48..2b59bd1e 100644
--- a/src/ambigator.c
+++ b/src/ambigator.c
@@ -55,6 +55,8 @@
#include <cell-utils.h>
#include <thread-pool.h>
+#include "version.h"
+
static void show_help(const char *s)
{
@@ -765,7 +767,8 @@ static void write_reindexed_stream(const char *infile, const char *outfile,
done = 1;
/* Add our own header */
- fprintf(ofh, "Re-indexed by ambigator "CRYSTFEL_VERSIONSTRING"\n");
+ fprintf(ofh, "Re-indexed by ambigator %s\n",
+ crystfel_version_string());
if ( argc > 0 ) {
for ( i=0; i<argc; i++ ) {
if ( i > 0 ) fprintf(ofh, " ");
@@ -1094,8 +1097,10 @@ int main(int argc, char *argv[])
return 0;
case 10 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'o' :
diff --git a/src/cell_explorer.c b/src/cell_explorer.c
index 88c23dc3..2eec4a19 100644
--- a/src/cell_explorer.c
+++ b/src/cell_explorer.c
@@ -48,6 +48,7 @@
#include "cell-utils.h"
#include "multihistogram.h"
+#include "version.h"
static void show_help(const char *s)
@@ -1958,8 +1959,10 @@ int main(int argc, char *argv[])
return 0;
case 1 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
default :
diff --git a/src/cell_tool.c b/src/cell_tool.c
index 8170b27b..bcfb326f 100644
--- a/src/cell_tool.c
+++ b/src/cell_tool.c
@@ -39,10 +39,12 @@
#include <getopt.h>
#include <assert.h>
-#include "cell.h"
-#include "cell-utils.h"
-#include "reflist-utils.h"
-#include "reflist.h"
+#include <cell.h>
+#include <cell-utils.h>
+#include <reflist-utils.h>
+#include <reflist.h>
+
+#include "version.h"
static void show_help(const char *s)
@@ -54,6 +56,7 @@ static void show_help(const char *s)
" -h, --help Display this help message.\n"
" -p, --pdb=<file> Get unit cell from <file> (PDB or CrystFEL format).\n"
" -o <file> Output unit cell file.\n"
+" --version Print CrystFEL version number and exit.\n"
"\n"
" Actions:\n"
" --find-ambi Find indexing ambiguities for the cell.\n"
@@ -487,6 +490,7 @@ int main(int argc, char *argv[])
{"pdb", 1, NULL, 'p'},
{"tolerance", 1, NULL, 2},
{"output", 1, NULL, 'o'},
+ {"version", 0, NULL, 6},
/* Modes of operation */
{"find-ambi", 0, &mode, CT_FINDAMBI},
@@ -546,6 +550,13 @@ int main(int argc, char *argv[])
rmax = 1.0 / (highres/1e10);
break;
+ case 6 :
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
+ return 0;
+
case 0 :
break;
diff --git a/src/check_hkl.c b/src/check_hkl.c
index f36c9ed4..f743d575 100644
--- a/src/check_hkl.c
+++ b/src/check_hkl.c
@@ -40,11 +40,13 @@
#include <gsl/gsl_fit.h>
#include <assert.h>
-#include "utils.h"
-#include "symmetry.h"
-#include "reflist.h"
-#include "reflist-utils.h"
-#include "cell-utils.h"
+#include <utils.h>
+#include <symmetry.h>
+#include <reflist.h>
+#include <reflist-utils.h>
+#include <cell-utils.h>
+
+#include "version.h"
static void show_help(const char *s)
@@ -761,8 +763,10 @@ int main(int argc, char *argv[])
return 0;
case 9 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'y' :
diff --git a/src/compare_hkl.c b/src/compare_hkl.c
index 5b0c6aa8..2a89596e 100644
--- a/src/compare_hkl.c
+++ b/src/compare_hkl.c
@@ -43,10 +43,13 @@
#include <gsl/gsl_statistics.h>
#include <gsl/gsl_fit.h>
-#include "utils.h"
-#include "symmetry.h"
-#include "reflist-utils.h"
-#include "cell-utils.h"
+#include <utils.h>
+#include <symmetry.h>
+#include <reflist-utils.h>
+#include <cell-utils.h>
+
+#include "version.h"
+
enum fom
{
@@ -1185,8 +1188,10 @@ int main(int argc, char *argv[])
return 0;
case 10 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'y' :
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index fc7e265f..e291bc16 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -50,6 +50,7 @@
#include "gui_index.h"
#include "gui_backend_local.h"
#include "gui_project.h"
+#include "version.h"
static void show_help(const char *s)
@@ -602,7 +603,8 @@ static gint about_sig(GtkWidget *widget, struct crystfelproject *proj)
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(window),
"CrystFEL graphical user interface");
- gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window), CRYSTFEL_VERSIONSTRING);
+ gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),
+ crystfel_version_string());
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(window),
"© 2020 Deutsches Elektronen-Synchrotron DESY, "
"a research centre of the Helmholtz Association.");
@@ -797,8 +799,10 @@ int main(int argc, char *argv[])
return 0;
case 1 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
default :
diff --git a/src/geoptimiser.c b/src/geoptimiser.c
index 385a85d4..16c59f3c 100644
--- a/src/geoptimiser.c
+++ b/src/geoptimiser.c
@@ -54,12 +54,15 @@
#endif /* HAVE_GDK */
#endif /* HAVE_CAIRO */
-#include "detector.h"
-#include "stream.h"
-#include "crystal.h"
-#include "image.h"
-#include "utils.h"
-#include "colscale.h"
+#include <detector.h>
+#include <stream.h>
+#include <crystal.h>
+#include <image.h>
+#include <utils.h>
+#include <colscale.h>
+
+#include "version.h"
+
struct imagefeature;
@@ -2730,8 +2733,10 @@ int main(int argc, char *argv[])
return 0;
case 10 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'o' :
diff --git a/src/get_hkl.c b/src/get_hkl.c
index 3f3d6637..31d04181 100644
--- a/src/get_hkl.c
+++ b/src/get_hkl.c
@@ -38,11 +38,13 @@
#include <unistd.h>
#include <getopt.h>
-#include "utils.h"
-#include "reflist-utils.h"
-#include "symmetry.h"
-#include "cell.h"
-#include "cell-utils.h"
+#include <utils.h>
+#include <reflist-utils.h>
+#include <symmetry.h>
+#include <cell.h>
+#include <cell-utils.h>
+
+#include "version.h"
static void show_help(const char *s)
@@ -503,8 +505,10 @@ int main(int argc, char *argv[])
return 0;
case 5 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 't' :
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 68b293f6..98573839 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -64,6 +64,8 @@
#include <datatemplate.h>
#include "im-sandbox.h"
+#include "version.h"
+
struct indexamajig_arguments
{
@@ -102,8 +104,8 @@ struct indexamajig_arguments
static void show_version(FILE *fh, struct argp_state *state)
{
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n", crystfel_version_string());
+ printf("%s\n", crystfel_licence_string());
}
diff --git a/src/list_events.c b/src/list_events.c
index 84465dc5..c9a0ae40 100644
--- a/src/list_events.c
+++ b/src/list_events.c
@@ -38,9 +38,11 @@
#include <unistd.h>
#include <getopt.h>
-#include "utils.h"
-#include "image.h"
-#include "datatemplate.h"
+#include <utils.h>
+#include <image.h>
+#include <datatemplate.h>
+
+#include "version.h"
static void show_help(const char *s)
@@ -92,8 +94,10 @@ int main(int argc, char *argv[])
return 0;
case 2 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'o' :
diff --git a/src/make_pixelmap.c b/src/make_pixelmap.c
index eedcb439..cb5afcac 100644
--- a/src/make_pixelmap.c
+++ b/src/make_pixelmap.c
@@ -43,9 +43,11 @@
#include <assert.h>
#include <hdf5.h>
-#include "utils.h"
-#include "datatemplate.h"
-#include "detgeom.h"
+#include <utils.h>
+#include <datatemplate.h>
+#include <detgeom.h>
+
+#include "version.h"
static void show_help(const char *s)
@@ -190,6 +192,7 @@ int main(int argc, char *argv[])
{"badmap", 0, &badmap, 1},
{"good-pixel", 1, NULL, 301},
{"bad-pixel", 1, NULL, 302},
+ {"version", 0, NULL, 2},
{0, 0, NULL, 0}
};
@@ -207,6 +210,13 @@ int main(int argc, char *argv[])
output_file = strdup(optarg);
break;
+ case 2 :
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
+ return 0;
+
case 301:
if (sscanf(optarg, "%d", &good_pixel_val) != 1)
{
diff --git a/src/partial_sim.c b/src/partial_sim.c
index 9e774431..5d1a79e8 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -42,14 +42,17 @@
#include <pthread.h>
#include <gsl/gsl_rng.h>
-#include "image.h"
-#include "utils.h"
-#include "reflist-utils.h"
-#include "symmetry.h"
-#include "geometry.h"
-#include "stream.h"
-#include "thread-pool.h"
-#include "cell-utils.h"
+#include <image.h>
+#include <utils.h>
+#include <reflist-utils.h>
+#include <symmetry.h>
+#include <geometry.h>
+#include <stream.h>
+#include <thread-pool.h>
+#include <cell-utils.h>
+
+#include "version.h"
+
/* Number of bins for partiality graph */
#define NBINS 50
@@ -589,8 +592,10 @@ int main(int argc, char *argv[])
return 0;
case 'v' :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'b' :
diff --git a/src/partialator.c b/src/partialator.c
index 1f87e6b8..f35d7cf8 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -58,6 +58,7 @@
#include "post-refinement.h"
#include "merge.h"
#include "rejection.h"
+#include "version.h"
struct csplit_hash_entry
@@ -1037,8 +1038,10 @@ int main(int argc, char *argv[])
return 0;
case 'v' :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'i' :
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index 2f9a228e..916257e3 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -42,19 +42,21 @@
#include <getopt.h>
#include <hdf5.h>
-#include "image.h"
+#include <image.h>
+#include <cell.h>
+#include <cell-utils.h>
+#include <utils.h>
+#include <detector.h>
+#include <peaks.h>
+#include <symmetry.h>
+#include <reflist.h>
+#include <reflist-utils.h>
+#include <stream.h>
+
#include "diffraction.h"
#include "diffraction-gpu.h"
-#include "cell.h"
-#include "cell-utils.h"
-#include "utils.h"
-#include "detector.h"
-#include "peaks.h"
-#include "symmetry.h"
-#include "reflist.h"
-#include "reflist-utils.h"
#include "pattern_sim.h"
-#include "stream.h"
+#include "version.h"
enum spectrum_type {
@@ -588,8 +590,10 @@ int main(int argc, char *argv[])
return 0;
case 'v' :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'b' :
diff --git a/src/process_hkl.c b/src/process_hkl.c
index b840f4ce..352bea4a 100644
--- a/src/process_hkl.c
+++ b/src/process_hkl.c
@@ -43,16 +43,18 @@
#include <unistd.h>
#include <getopt.h>
-#include "utils.h"
-#include "reflist-utils.h"
-#include "symmetry.h"
-#include "stream.h"
-#include "reflist.h"
-#include "image.h"
-#include "crystal.h"
-#include "thread-pool.h"
-#include "geometry.h"
-#include "cell-utils.h"
+#include <utils.h>
+#include <reflist-utils.h>
+#include <symmetry.h>
+#include <stream.h>
+#include <reflist.h>
+#include <image.h>
+#include <crystal.h>
+#include <thread-pool.h>
+#include <geometry.h>
+#include <cell-utils.h>
+
+#include "version.h"
static void show_help(const char *s)
@@ -664,8 +666,10 @@ int main(int argc, char *argv[])
break;
case 7 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case '?' :
diff --git a/src/render_hkl.c b/src/render_hkl.c
index f2ffa211..3f539cb2 100644
--- a/src/render_hkl.c
+++ b/src/render_hkl.c
@@ -45,13 +45,15 @@
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
-#include "utils.h"
-#include "symmetry.h"
-#include "colscale.h"
+#include <utils.h>
+#include <symmetry.h>
+#include <colscale.h>
+#include <reflist.h>
+#include <reflist-utils.h>
+#include <cell-utils.h>
+
#include "render_hkl.h"
-#include "reflist.h"
-#include "reflist-utils.h"
-#include "cell-utils.h"
+#include "version.h"
#define KEY_FILENAME "key.pdf"
@@ -811,8 +813,10 @@ int main(int argc, char *argv[])
return 0;
case 5 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 'p' :
diff --git a/src/version.c.cmake.in b/src/version.c.cmake.in
new file mode 100644
index 00000000..a22b4143
--- /dev/null
+++ b/src/version.c.cmake.in
@@ -0,0 +1,13 @@
+const char *crystfel_version_string()
+{
+ return "${CRYSTFEL_VERSION}";
+}
+
+const char *crystfel_licence_string()
+{
+ return "License GPLv3+: GNU GPL version 3 or later" \
+ " <http://gnu.org/licenses/gpl.html>.\n" \
+ "This is free software: you are free to change and redistribute it.\n" \
+ "There is NO WARRANTY, to the extent permitted by law.\n\n" \
+ "Written by Thomas White and others.";
+}
diff --git a/src/version.h b/src/version.h
new file mode 100644
index 00000000..0ecac74a
--- /dev/null
+++ b/src/version.h
@@ -0,0 +1,2 @@
+extern const char *crystfel_version_string(void);
+extern const char *crystfel_licence_string(void);
diff --git a/src/whirligig.c b/src/whirligig.c
index 6c007f0b..16688559 100644
--- a/src/whirligig.c
+++ b/src/whirligig.c
@@ -42,11 +42,13 @@
#include <image.h>
#include <utils.h>
#include <stream.h>
+#include <cell-utils.h>
+#include <integer_matrix.h>
+#include <reflist.h>
+#include <reflist-utils.h>
+
+#include "version.h"
-#include "cell-utils.h"
-#include "integer_matrix.h"
-#include "reflist.h"
-#include "reflist-utils.h"
/* Maximum number of series which can overlap at once */
#define MAX_SER 8
@@ -634,8 +636,10 @@ int main(int argc, char *argv[])
break;
case 3 :
- printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n");
- printf(CRYSTFEL_BOILERPLATE"\n");
+ printf("CrystFEL: %s\n",
+ crystfel_version_string());
+ printf("%s\n",
+ crystfel_licence_string());
return 0;
case 4 :