source: trunk/src/astrometry/util/Makefile @ 11537

Revision 11537, 7.4 KB checked in by dstn, 16 months ago (diff)

add downsample-fits

Line 
1# This file is part of the Astrometry.net suite.
2# Copyright 2006, 2007 Dustin Lang, Keir Mierle and Sam Roweis.
3#
4# The Astrometry.net suite is free software; you can redistribute
5# it and/or modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation, version 2.
7#
8# The Astrometry.net suite is distributed in the hope that it will be
9# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11# General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with the Astrometry.net suite ; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
16
17BASEDIR := ..
18COMMON := .
19
20all:
21.PHONY: all
22
23# You can build stripped-down versions of the AN libraries that do not
24# depend on libkd or libqfits by defining the following in your Makefile
25# before calling make in the an-common directory:
26#   NO_KDTREE := 1
27#   export NO_KDTREE
28#   NO_QFITS := 1
29#   export NO_QFITS
30
31include $(COMMON)/makefile.common
32ifndef NO_QFITS
33include $(COMMON)/makefile.qfits
34endif
35ifndef NO_KDTREE
36include $(COMMON)/makefile.libkd
37endif
38
39include $(COMMON)/makefile.cairo
40include $(COMMON)/makefile.jpeg
41include $(COMMON)/makefile.netpbm
42include $(COMMON)/makefile.gsl
43
44CFLAGS += $(CFLAGS_DEF)
45CFLAGS += $(CAIRO_INC)
46CFLAGS += $(NETPBM_INC)
47CFLAGS += $(JPEG_INC)
48CFLAGS += $(GSL_INC)
49
50LDFLAGS += $(LDFLAGS_DEF)
51LDFLAGS += -lm
52
53ifndef NO_QFITS
54CFLAGS += $(QFITS_INC)
55endif
56ifndef NO_KDTREE
57CFLAGS += $(LIBKD_INC)
58endif
59CFLAGS += -I.
60
61ANFILES_LIB := libanfiles.a
62ANUTILS_LIB := libanutils.a
63
64PYTHON_LIBS := _sip.so _healpix.so
65
66PROGS := an-fitstopnm downsample-fits
67
68all: $(ANUTILS_LIB) $(ANFILES_LIB) $(PYTHON_LIBS) $(PROGS)
69
70# Things that it depends on but which aren't linked in
71ANUTILS_DEPS :=
72
73ANUTILS_OBJ := starutil.o mathutil.o bl.o bt.o healpix-utils.o healpix.o \
74        permutedsort.o ioutils.o sip.o sip-utils.o md5.o constellations.o \
75        gnu-specific.o an-endian.o errors.o an-opts.o svn.o tic.o log.o \
76        gslutils.o
77ifndef NO_QFITS
78ANUTILS_OBJ += fitsioutils.o sip_qfits.o fitstable.o fitsbin.o fitsfile.o
79ANUTILS_DEPS += $(QFITS_LIB)
80endif
81ifndef NO_KDTREE
82ANUTILS_OBJ += dualtree.o dualtree_rangesearch.o dualtree_nearestneighbour.o
83endif
84
85# Things that it depends on but which aren't linked in
86ANFILES_DEPS :=
87
88ANFILES_OBJ :=
89ifndef NO_QFITS
90ANFILES_OBJ += index.o codekd.o starkd.o rdlist.o xylist.o \
91        starxy.o an-catalog.o qidxfile.o quadfile.o scamp-catalog.o
92ANFILES_DEPS += $(QFITS_LIB)
93endif
94
95MISC_OBJ := grab-stellarium-constellations.o
96
97ALL_OBJ := $(ANUTILS_OBJ) $(ANFILES_OBJ) $(MISC_OBJ)
98
99# svn.c depends on all the .c and .h files in ANUTILS_OBJ
100SVN_C_DEPS := $(subst svn.o,,$(ANUTILS_OBJ))
101SVN_C_DEPS := $(subst .o,.c,$(SVN_C_DEPS)) $(subst .o,.h,$(SVN_C_DEPS))
102
103svn.c: $(SVN_C_DEPS)
104        echo "//" >> svn.c
105
106$(ANUTILS_LIB): $(ANUTILS_OBJ) $(ANUTILS_DEPS)
107        -rm -f $@
108        $(AR) rc $@ $(ANUTILS_OBJ)
109        $(RANLIB) $@
110
111$(ANFILES_LIB): $(ANFILES_OBJ) $(ANFILES_DEPS)
112        -rm -f $@
113        $(AR) rc $@ $(ANFILES_OBJ)
114        $(RANLIB) $@
115
116SHAREDLIBFLAGS := $(SHAREDLIBFLAGS_DEF)
117
118_sip.so: sip-utils.o sip.o starutil.o mathutil.o sip_qfits.o \
119                fitsioutils.o ioutils.o bl.o gnu-specific.o an-endian.o \
120                errors.o log.o $(QFITS_LIB)
121        $(CC) $(SHAREDLIBFLAGS) -o $@ $^
122
123_healpix.so: healpix.o starutil.o mathutil.o errors.o bl.o log.o
124        $(CC) $(SHAREDLIBFLAGS) -o $@ $^
125
126an-fitstopnm: an-fitstopnm.o $(ANUTILS_LIB) $(QFITS_LIB)
127
128downsample-fits: downsample-fits.o $(ANUTILS_LIB) $(QFITS_LIB)
129
130ALL_OBJ += an-fitstopnm.o
131
132PYTHON_INSTALL := fits2fits.py image2pnm.py healpix.py sip.py starutil.py \
133        shell.py __init__.py file.py run_command.py w3c_validator.py \
134        filetype.py \
135        $(PYTHON_LIBS)
136
137PYTHON_EXECS := fits2fits.py image2pnm.py
138
139PY_INSTALL_DIR := $(INSTALL_DIR)/python/astrometry/util
140BIN_INSTALL_DIR := $(INSTALL_DIR)/bin
141LINK_DIR := ../python/astrometry/util
142
143install: $(PYTHON_LIBS)
144        @echo Installing in base directory $(INSTALL_DIR)
145        mkdir -p $(PY_INSTALL_DIR)
146        @for x in $(PYTHON_INSTALL); do \
147                echo cp $$x $(PY_INSTALL_DIR)/$$x; \
148                cp $$x $(PY_INSTALL_DIR)/$$x; \
149        done
150        @echo Making symlinks in directory $(BIN_INSTALL_DIR)
151        mkdir -p $(BIN_INSTALL_DIR)
152        @for x in $(PYTHON_EXECS); do \
153                echo ln -f -s $(PY_INSTALL_DIR)/$$x $(BIN_INSTALL_DIR)/$$x; \
154                ln -f -s $(LINK_DIR)/$$x $(BIN_INSTALL_DIR)/$$x; \
155        done
156        @echo Installing executables into $(BIN_INSTALL_DIR)...
157        @for x in $(PROGS); do \
158                echo cp $$x $(BIN_INSTALL_DIR)/$$x; \
159                cp $$x $(BIN_INSTALL_DIR)/$$x; \
160        done
161
162gnu-specific-config.h: gnu-specific-test.c
163        ( \
164        (($(CC) -o gnu-specific-test-canonicalize \
165                $(CFLAGS) -DTEST_CANONICALIZE_FILE_NAME $(LDFLAGS) $^  > /dev/null && \
166          ./gnu-specific-test-canonicalize) \
167        || echo "#define NEED_CANONICALIZE_FILE_NAME 1") \
168        ; \
169         (($(CC) -o gnu-specific-test-declare-qsort \
170                $(CFLAGS) -DTEST_DECLARE_QSORT_R $(LDFLAGS) $^ > /dev/null && \
171          ./gnu-specific-test-declare-qsort) \
172        || echo "#define NEED_DECLARE_QSORT_R 0") \
173        ; \
174         (($(CC) -o gnu-specific-test-qsort \
175                $(CFLAGS) -DTEST_QSORT_R $(LDFLAGS) $^ > /dev/null && \
176          ./gnu-specific-test-qsort) \
177        || echo "#define NEED_QSORT_R 1") \
178        ; \
179         (($(CC) -o gnu-specific-test-swap-qsort \
180                $(CFLAGS) -DTEST_SWAP_QSORT_R $(LDFLAGS) $^ > /dev/null && \
181          ./gnu-specific-test-swap-qsort) \
182        || echo "#define NEED_SWAP_QSORT_R 0") \
183        ; \
184        echo) | grep -v "Segmentation" > $@
185
186ALL_OBJ += gnu-specific.o
187ALL_TARGETS := gnu-specific-test.o \
188        gnu-specific-test-canonicalize \
189        gnu-specific-test-declare-qsort \
190        gnu-specific-test-qsort \
191        gnu-specific-config.h
192
193DEP_OBJ := $(ANUTILS_OBJ) $(ANFILES_OBJ) $(MISC_OBJ)
194ifndef NO_QFITS
195DEP_PREREQS := $(QFITS_LIB)
196endif
197include $(COMMON)/makefile.deps
198
199stellarium-constellations.c:
200        -$(MAKE) grab-stellarium-constellations
201        -(./grab-stellarium-constellations > $@.tmp  &&  mv $@.tmp $@) || touch $@
202
203grab-stellarium-constellations: grab-stellarium-constellations.o \
204                starutil.o mathutil.o bl.o an-endian.o
205        $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ -lm
206
207### TESTS
208
209ALL_TEST_FILES = test_bl test_bt test_endian test_fitstable test_xylist \
210        test_rdlist test_healpix test_fitsioutils test_fitsbin test_log test_ioutils \
211        test_dualtree_nn test_scamp_catalog test_starutil test_svd
212ALL_TEST_EXTRA_OBJS =
213ALL_TEST_LIBS = $(LIBKD_LIB) $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) $(GSL_LIB)
214
215include $(COMMON)/makefile.tests
216
217DEP_OBJ += $(ALL_TEST_FILES_O)
218
219test_fitstable: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB)
220
221test_fitsbin: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB)
222
223test_fitsioutils: $(ANUTILS_LIB) $(QFITS_LIB)
224
225test_xylist: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB)
226
227test_rdlist: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB)
228
229test_bl: $(ANUTILS_LIB)
230
231test_bt: $(ANUTILS_LIB)
232
233test_endian: $(ANUTILS_LIB)
234
235test_healpix: $(ANUTILS_LIB)
236
237test_log: $(ANUTILS_LIB)
238
239test_ioutils: $(ANUTILS_LIB)
240
241test_dualtree_nn: $(LIBKD_LIB) $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB)
242
243test_scamp_catalog: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB)
244
245test_starutil: $(ANUTILS_LIB)
246
247test_svd: $(ANUTILS_LIB) $(GSL_LIB)
248
249### /TESTS
250
251# we'll just tack this on here... It depends on cairo, libjpeg, etc, so it's not part
252# of the anX.a libraries.
253ifeq ($(MAKECMDGOALS),cairoutils.o)
254  include cairoutils.dep
255endif
256
257.PHONY: allclean realclean clean
258
259allclean: clean
260        rm -f *.o *~ *.dep *.so
261
262realclean: allclean
263
264clean:
265        rm -f $(ANUTILS_LIB) $(ANFILES_LIB) $(ALL_OBJ) \
266                $(DEPS) deps cairoutils.o $(PYTHON_LIBS) \
267                grab-stellarium-constellations \
268                $(PROGS) $(ALL_TARGETS) $(ALL_TESTS_CLEAN)
Note: See TracBrowser for help on using the repository browser.