1## Process this file with automake to produce Makefile.in
2##
3## Original author:
4##     Mohammad Akhlaghi <mohammad@akhlaghi.org>
5## Contributing author(s):
6## Copyright (C) 2015-2021, Free Software Foundation, Inc.
7##
8## Gnuastro is free software: you can redistribute it and/or modify it
9## under the terms of the GNU General Public License as published by
10## the Free Software Foundation, either version 3 of the License, or
11## (at your option) any later version.
12##
13## Gnuastro is distributed in the hope that it will be useful, but
14## WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16## General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
20
21
22
23
24
25## Necessary flags.
26##
27##   $(top_builddir)/bootstrapped/lib: Gnulib headers that are customized
28##   for the running system.
29##
30##   $(top_srcdir)/bootstrapped/lib: Gnulib headers that are generic (don't
31##   need any customization).
32##
33##   SYSCONFIG_DIR: only necessary in 'options.c' to get the system
34##       installation directory.
35AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
36              -I\$(top_srcdir)/bootstrapped/lib \
37              -DSYSCONFIG_DIR=\"$(sysconfdir)\"
38
39
40
41
42
43# Define the main compiled library file, its Libtool version and also link
44# with Gnulib's compiled library for this system. We are doing this so the
45# Gnuastro library functions can also benefit from Gnulib's many great
46# features. This also avoids the need for the programs to link separately
47# with Gnulib, they only need to link with the Gnuastro library.
48lib_LTLIBRARIES = libgnuastro.la
49libgnuastro_la_LDFLAGS = -version-info $(GAL_LT_VERSION) $(CONFIG_LDADD) \
50                         -lc -no-undefined
51libgnuastro_la_LIBADD = $(top_builddir)/bootstrapped/lib/libgnu.la
52
53
54
55
56# Conditional compilation
57if COND_HASWCSDIS_H
58  MAYBE_WCSDISTORTION = wcsdistortion.c
59endif
60
61
62
63
64
65# Specify the library .c files
66libgnuastro_la_SOURCES = $(MAYBE_WCSDISTORTION) arithmetic.c \
67  arithmetic-and.c arithmetic-bitand.c arithmetic-bitlsh.c \
68  arithmetic-bitor.c arithmetic-bitrsh.c arithmetic-bitxor.c \
69  arithmetic-divide.c arithmetic-eq.c arithmetic-ge.c arithmetic-gt.c \
70  arithmetic-le.c arithmetic-lt.c arithmetic-minus.c arithmetic-modulo.c \
71  arithmetic-multiply.c arithmetic-ne.c arithmetic-or.c \
72  arithmetic-plus.c arithmetic-set.c array.c binary.c blank.c box.c \
73  checkset.c convolve.c cosmology.c data.c ds9.c eps.c fits.c git.c \
74  interpolate.c jpeg.c kdtree.c label.c list.c match.c options.c pdf.c \
75  permutation.c pointer.c polygon.c qsort.c dimension.c speclines.c \
76  statistics.c table.c tableintern.c threads.c tiff.c tile.c \
77  tile-internal.c timing.c txt.c type.c units.c wcs.c
78
79
80
81
82
83# Installed headers, note that we are not blindly including all '.h' files
84# in the $(headersdir) directory. Some of the header files don't need to be
85# installed.
86headersdir=$(top_srcdir)/lib/gnuastro
87pkginclude_HEADERS = gnuastro/config.h $(headersdir)/arithmetic.h \
88  $(headersdir)/array.h $(headersdir)/binary.h $(headersdir)/blank.h \
89  $(headersdir)/box.h $(headersdir)/convolve.h $(headersdir)/cosmology.h \
90  $(headersdir)/data.h $(headersdir)/dimension.h $(headersdir)/ds9.h \
91  $(headersdir)/eps.h $(headersdir)/fits.h $(headersdir)/git.h \
92  $(headersdir)/interpolate.h $(headersdir)/jpeg.h $(headersdir)/kdtree.h \
93  $(headersdir)/label.h $(headersdir)/list.h $(headersdir)/match.h \
94  $(headersdir)/pdf.h $(headersdir)/permutation.h $(headersdir)/pointer.h \
95  $(headersdir)/polygon.h $(headersdir)/qsort.h $(headersdir)/speclines.h \
96  $(headersdir)/statistics.h $(headersdir)/table.h $(headersdir)/threads.h \
97  $(headersdir)/tiff.h $(headersdir)/tile.h $(headersdir)/txt.h \
98  $(headersdir)/type.h $(headersdir)/units.h $(headersdir)/wcs.h
99
100
101
102
103
104# Files to distribute in the tarball. These are internal headers and don't
105# need to be installed. Headers are only mentioned within the source files,
106# and if they are not explicitly mentioned somewhere in the Makefile, they
107# will not distributed, so we need to explicitly tell Automake to
108# distribute them here.
109internaldir=$(top_srcdir)/lib/gnuastro-internal
110EXTRA_DIST = gnuastro.pc.in $(headersdir)/README $(internaldir)/README \
111  $(internaldir)/arithmetic-and.h $(internaldir)/arithmetic-binary.h \
112  $(internaldir)/arithmetic-bitand.h $(internaldir)/arithmetic-bitlsh.h \
113  $(internaldir)/arithmetic-bitor.h $(internaldir)/arithmetic-bitrsh.h \
114  $(internaldir)/arithmetic-bitxor.h $(internaldir)/arithmetic-divide.h \
115  $(internaldir)/arithmetic-eq.h $(internaldir)/arithmetic-ge.h \
116  $(internaldir)/arithmetic-gt.h $(internaldir)/arithmetic-internal.h \
117  $(internaldir)/arithmetic-le.h $(internaldir)/arithmetic-lt.h \
118  $(internaldir)/arithmetic-minus.h $(internaldir)/arithmetic-modulo.h \
119  $(internaldir)/arithmetic-multiply.h $(internaldir)/arithmetic-ne.h \
120  $(internaldir)/arithmetic-or.h $(internaldir)/arithmetic-plus.h \
121  $(internaldir)/arithmetic-set.h $(internaldir)/checkset.h \
122  $(internaldir)/commonopts.h $(internaldir)/config.h.in \
123  $(internaldir)/fixedstringmacros.h $(internaldir)/options.h \
124  $(internaldir)/tableintern.h $(internaldir)/tile-internal.h \
125  $(internaldir)/timing.h $(internaldir)/wcsdistortion.h
126
127
128
129
130
131# Definitions for Gnuastro's the pkg-config file (inspired from GSL's
132# Makefile.am)
133pkgconfig_DATA = gnuastro.pc
134pkgconfigdir = $(libdir)/pkgconfig
135CLEANFILES = gnuastro.pc gnuastro/config.h
136
137
138
139
140
141# Build 'gnuastro/config.h' based on the information in the Makefile after
142# the Makefile has been built.
143gnuastro/config.h: Makefile $(internaldir)/config.h.in
144	rm -f $@ $@.tmp
145	$(MKDIR_P) gnuastro
146	$(SED) -e 's|@VERSION[@]|$(VERSION)|g' \
147	       -e 's|@SIZEOF_LONG[@]|$(SIZEOF_LONG)|g' \
148	       -e 's|@HAVE_LIBGIT2[@]|$(HAVE_LIBGIT2)|g' \
149	       -e 's|@SIZEOF_SIZE_T[@]|$(SIZEOF_SIZE_T)|g' \
150	       -e 's|@HAVE_WCSLIB_DIS_H[@]|$(HAVE_WCSLIB_DIS_H)|g' \
151	       -e 's|@HAVE_WCSLIB_MJDREF[@]|$(HAVE_WCSLIB_MJDREF)|g' \
152	       -e 's|@HAVE_WCSLIB_OBSFIX[@]|$(HAVE_WCSLIB_OBSFIX)|g' \
153	       -e 's|@HAVE_WCSLIB_WCSCCS[@]|$(HAVE_WCSLIB_WCSCCS)|g' \
154	       -e 's|@HAVE_WCSLIB_VERSION[@]|$(HAVE_WCSLIB_VERSION)|g' \
155	       -e 's|@HAVE_PTHREAD_BARRIER[@]|$(HAVE_PTHREAD_BARRIER)|g' \
156	       -e 's|@RESTRICT_REPLACEMENT[@]|$(RESTRICT_REPLACEMENT)|g' \
157	       -e 's|@HAVE_FITS_IS_REENTRANT[@]|$(HAVE_FITS_IS_REENTRANT)|g' \
158               $(internaldir)/config.h.in >> $@.tmp
159	chmod a-w $@.tmp
160	mv $@.tmp $@
161
162
163
164
165
166# Build Gnuastro's pkg-config file similar to 'gnuastro/config.h'.
167gnuastro.pc: Makefile $(srcdir)/gnuastro.pc.in
168	rm -f $@ $@.tmp
169	ol=""; \
170	if [ x"$(HAVE_LIBJPEG)" = xyes ]; then ol="$$ol libjpeg"; fi; \
171	if [ x"$(HAVE_LIBLZMA)" = xyes ]; then ol="$$ol liblzma"; fi; \
172	if [ x"$(HAVE_LIBGIT2)" = xyes ]; then ol="$$ol libgit2"; fi; \
173	if [ x"$(HAVE_LIBTIFF)" = xyes ]; then ol="$$ol libtiff-4"; fi; \
174	$(SED) -e's|@prefix[@]|$(prefix)|g' \
175	       -e"s|@optional_libs[@]|$$ol|g" \
176	       -e's|@exec_prefix[@]|$(exec_prefix)|g' \
177	       -e's|@libdir[@]|$(libdir)|g' \
178	       -e's|@includedir[@]|$(includedir)|g' \
179	       -e's|@LIBS[@]|$(LIBS)|g' \
180	       -e's|@VERSION[@]|$(VERSION)|g' \
181	       '$(srcdir)/$@.in' >> $@.tmp
182	chmod a-w $@.tmp
183	mv $@.tmp $@
184