1#-----------------------------------------------------------------------------
2# GNU makefile for WCSLIB 7.7 utilities: fitshdr, HPXcvt, wcsgrid and wcsware.
3#
4# Summary of the main targets
5# ---------------------------
6#   build:     Build all utilities.
7#   clean (or cleaner): Delete intermediate object files.
8#   distclean (or realclean): cleaner, and also delete the executables.
9#   cleanest: distclean, and also delete the man pages.
10#
11# Notes:
12#   1: If you need to make changes then preferably modify ../makedefs.in
13#      instead and re-run configure.
14#
15#   2: In compiling these utilities, this makefile assumes that the WCSLIB 7.7
16#      sources reside in ../{pgsbox,C} (as in the distribution kit).
17#
18# Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
19# http://www.atnf.csiro.au/people/Mark.Calabretta
20# $Id: GNUmakefile,v 7.7 2021/07/12 06:36:49 mcalabre Exp $
21#-----------------------------------------------------------------------------
22# Get configure settings.
23SUBDIR := utils
24include ../makedefs
25
26UTILS := tofits fitshdr sundazel
27
28ifneq "$(CFITSIOINC)" ""
29ifneq "$(CFITSIOLIB)" ""
30  UTILS += HPXcvt wcsware
31
32  ifneq "$(PGPLOTINC)" ""
33  ifneq "$(PGPLOTLIB)" ""
34    UTILS += wcsgrid
35  endif
36  endif
37endif
38endif
39
40MAN := $(addsuffix .1,$(UTILS))
41
42WCSLIB    := ../C/$(WCSLIB)
43PGSBOXLIB := ../pgsbox/libpgsbox-$(LIBVER).a
44
45ifneq "$(GETWCSTAB)" ""
46  GETWCSTAB := ../C/$(GETWCSTAB)
47endif
48
49CPPFLAGS += -I.. -I../C
50
51OBSFLAGS := -DOBSLNG=$(OBSLNG) -DOBSLAT=$(OBSLAT) -DOBSTZ=$(OBSTZ)
52
53vpath %.h  ..:../C:../pgsbox
54vpath %.in ..
55
56
57# Static and static pattern rules
58#--------------------------------
59
60.PHONY : build clean cleaner cleanest distclean install man realclean \
61         uninstall
62
63build : $(UTILS)
64
65tofits : tofits.c
66	-@ echo ''
67	   $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $<
68
69fitshdr : fitshdr.c
70	-@ echo ''
71	   $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@.o $<
72	   $(LD) -o $@ $@.o $(LDFLAGS) $(LIBS)
73	-@ $(RM) $@.o
74
75sundazel : sundazel.c
76	-@ echo ''
77	   $(CC) $(CPPFLAGS) $(OBSFLAGS) $(CFLAGS) -c -o $@.o $<
78	   $(LD) -o $@ $@.o $(LDFLAGS) $(LIBS)
79	-@ $(RM) $@.o
80
81HPXcvt : HPXcvt.c
82	-@ echo ''
83	   $(CC) $(CPPFLAGS) $(CFITSIOINC) $(CFLAGS) -c -o $@.o $<
84	   $(LD) -o $@ $@.o $(LDFLAGS) $(CFITSIOLIB) $(LIBS)
85	-@ $(RM) $@.o
86
87wcsware : wcsware.c $(GETWCSTAB) $(WCSLIB)
88	-@ echo ''
89	   $(CC) -DDO_CFITSIO $(CPPFLAGS) -I../pgsbox -I../C $(CFITSIOINC) \
90	     $(CFLAGS) -c -o $@.o $<
91	   $(LD) -o $@ $@.o $(GETWCSTAB) $(LDFLAGS) $(CFITSIOLIB) $(WCSLIB) \
92	     $(FLIBS) $(LIBS)
93	-@ $(RM) $@.o
94
95wcsgrid : wcsgrid.c $(GETWCSTAB) $(PGSBOXLIB) $(WCSLIB)
96	-@ echo ''
97	   $(CC) -DDO_CFITSIO $(CPPFLAGS) -I../pgsbox -I../C $(PGPLOTINC) \
98	     $(CFITSIOINC) $(CFLAGS) -c -o $@.o $<
99	   $(LD) -o $@ $@.o $(GETWCSTAB) $(LDFLAGS) $(PGSBOXLIB) \
100	     $(PGPLOTLIB) $(CFITSIOLIB) $(WCSLIB) $(FLIBS) $(LIBS)
101	-@ $(RM) $@.o
102
103../C/getwcstab.o :
104	   $(MAKE) -C ../C $(@F)
105
106clean cleaner :
107	-  $(RM) -r *.o *.i a.out core *.dSYM $(EXTRA_CLEAN)
108
109distclean realclean : cleaner
110	-  $(RM) $(UTILS)
111
112cleanest : distclean
113	-  $(RM) $(MAN)
114
115$(PGSBOXLIB) :
116	-@ echo ''
117	   $(MAKE) -C ../pgsbox lib
118
119$(WCSLIB) :
120	-@ echo ''
121	   $(MAKE) -C ../C lib
122
123install : build
124	-  if [ ! -d "$(BINDIR)" ] ; then \
125	     $(INSTALL) -d -m 775 $(BINDIR) ; \
126	   fi
127	   $(INSTALL) -m 755 $(UTILS) $(BINDIR)
128	-  if [ ! -d "$(MANDIR)" ] ; then \
129	     $(INSTALL) -d -m 775 $(MANDIR)/man1 ; \
130	   fi
131	   $(INSTALL) -m 644 $(MAN) $(MANDIR)/man1
132
133uninstall :
134	-  cd $(BINDIR) && $(RM) $(UTILS)
135	-  cd $(MANDIR) && $(RM) $(MAN)
136
137GNUmakefile : ../makedefs ;
138
139../makedefs ../wcsconfig.h ../wcsconfig_utils.h : makedefs.in wcsconfig.h.in \
140    wcsconfig_utils.h.in ../config.status
141	-@ $(RM) ../wcsconfig.h ../wcsconfig_utils.h
142	   cd .. && ./config.status
143
144man : $(MAN)
145
146tofits.1 : tofits
147	help2man --no-discard-stderr --version-string=$(LIBVER) \
148	  -n "Turn a list of keyrecords to a valid FITS file" -N ./$< > $@
149
150fitshdr.1 : fitshdr
151	help2man --no-discard-stderr --version-string=$(LIBVER) \
152	  -n "List headers from a FITS file" -N ./$< > $@
153
154sundazel.1 : sundazel
155	help2man --no-discard-stderr --version-string=$(LIBVER) \
156	  -n "Compute the time of Solar passage" -N ./$< > $@
157
158wcsware.1 : wcsware
159	help2man --no-discard-stderr --version-string=$(LIBVER) \
160	  -n "Extract FITS WCS keywords for an image" -N ./$< > $@
161
162wcsgrid.1 : wcsgrid
163	help2man --no-discard-stderr --version-string=$(LIBVER) \
164	  -n "Extract FITS WCS keywords and plot graticule" -N ./$< > $@
165
166HPXcvt.1 : HPXcvt
167	help2man --no-discard-stderr --version-string=$(LIBVER) \
168	  -n "Reorganise HEALPix data into a 2-D FITS image" -N ./$< > $@
169
170# Dependency lists.
171fitshdr : wcsconfig.h wcsconfig_utils.h
172wcsware : getwcstab.h wcs.h wcsfix.h wcshdr.h
173wcsgrid : cpgsbox.h getwcstab.h wcs.h wcsfix.h wcshdr.h
174