| 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 | |
|---|
| 17 | BASEDIR := .. |
|---|
| 18 | COMMON := . |
|---|
| 19 | |
|---|
| 20 | all: |
|---|
| 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 | |
|---|
| 31 | include $(COMMON)/makefile.common |
|---|
| 32 | ifndef NO_QFITS |
|---|
| 33 | include $(COMMON)/makefile.qfits |
|---|
| 34 | endif |
|---|
| 35 | ifndef NO_KDTREE |
|---|
| 36 | include $(COMMON)/makefile.libkd |
|---|
| 37 | endif |
|---|
| 38 | |
|---|
| 39 | include $(COMMON)/makefile.cairo |
|---|
| 40 | include $(COMMON)/makefile.jpeg |
|---|
| 41 | include $(COMMON)/makefile.netpbm |
|---|
| 42 | include $(COMMON)/makefile.gsl |
|---|
| 43 | |
|---|
| 44 | CFLAGS += $(CFLAGS_DEF) |
|---|
| 45 | CFLAGS += $(CAIRO_INC) |
|---|
| 46 | CFLAGS += $(NETPBM_INC) |
|---|
| 47 | CFLAGS += $(JPEG_INC) |
|---|
| 48 | CFLAGS += $(GSL_INC) |
|---|
| 49 | |
|---|
| 50 | LDFLAGS += $(LDFLAGS_DEF) |
|---|
| 51 | LDFLAGS += -lm |
|---|
| 52 | |
|---|
| 53 | ifndef NO_QFITS |
|---|
| 54 | CFLAGS += $(QFITS_INC) |
|---|
| 55 | endif |
|---|
| 56 | ifndef NO_KDTREE |
|---|
| 57 | CFLAGS += $(LIBKD_INC) |
|---|
| 58 | endif |
|---|
| 59 | CFLAGS += -I. |
|---|
| 60 | |
|---|
| 61 | ANFILES_LIB := libanfiles.a |
|---|
| 62 | ANUTILS_LIB := libanutils.a |
|---|
| 63 | |
|---|
| 64 | PYTHON_LIBS := _sip.so _healpix.so |
|---|
| 65 | |
|---|
| 66 | PROGS := an-fitstopnm downsample-fits pad-file |
|---|
| 67 | |
|---|
| 68 | all: $(ANUTILS_LIB) $(ANFILES_LIB) $(PYTHON_LIBS) $(PROGS) |
|---|
| 69 | |
|---|
| 70 | # Things that it depends on but which aren't linked in |
|---|
| 71 | ANUTILS_DEPS := |
|---|
| 72 | |
|---|
| 73 | ANUTILS_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 |
|---|
| 77 | ifndef NO_QFITS |
|---|
| 78 | ANUTILS_OBJ += fitsioutils.o sip_qfits.o fitstable.o fitsbin.o fitsfile.o |
|---|
| 79 | ANUTILS_DEPS += $(QFITS_LIB) |
|---|
| 80 | endif |
|---|
| 81 | ifndef NO_KDTREE |
|---|
| 82 | ANUTILS_OBJ += dualtree.o dualtree_rangesearch.o dualtree_nearestneighbour.o |
|---|
| 83 | endif |
|---|
| 84 | |
|---|
| 85 | # Things that it depends on but which aren't linked in |
|---|
| 86 | ANFILES_DEPS := |
|---|
| 87 | |
|---|
| 88 | ANFILES_OBJ := |
|---|
| 89 | ifndef NO_QFITS |
|---|
| 90 | ANFILES_OBJ += index.o codekd.o starkd.o rdlist.o xylist.o \ |
|---|
| 91 | starxy.o an-catalog.o qidxfile.o quadfile.o scamp-catalog.o |
|---|
| 92 | ANFILES_DEPS += $(QFITS_LIB) |
|---|
| 93 | endif |
|---|
| 94 | |
|---|
| 95 | MISC_OBJ := grab-stellarium-constellations.o |
|---|
| 96 | |
|---|
| 97 | ALL_OBJ := $(ANUTILS_OBJ) $(ANFILES_OBJ) $(MISC_OBJ) |
|---|
| 98 | |
|---|
| 99 | # svn.c depends on all the .c and .h files in ANUTILS_OBJ |
|---|
| 100 | SVN_C_DEPS := $(subst svn.o,,$(ANUTILS_OBJ)) |
|---|
| 101 | SVN_C_DEPS := $(subst .o,.c,$(SVN_C_DEPS)) $(subst .o,.h,$(SVN_C_DEPS)) |
|---|
| 102 | |
|---|
| 103 | svn.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 | |
|---|
| 116 | SHAREDLIBFLAGS := $(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 | |
|---|
| 126 | pad-file: pad-file.o $(ANUTILS_LIB) |
|---|
| 127 | |
|---|
| 128 | an-fitstopnm: an-fitstopnm.o $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 129 | |
|---|
| 130 | downsample-fits: downsample-fits.o $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 131 | |
|---|
| 132 | ALL_OBJ += an-fitstopnm.o |
|---|
| 133 | |
|---|
| 134 | PYTHON_INSTALL := fits2fits.py image2pnm.py healpix.py sip.py starutil.py \ |
|---|
| 135 | shell.py __init__.py file.py run_command.py w3c_validator.py \ |
|---|
| 136 | filetype.py \ |
|---|
| 137 | $(PYTHON_LIBS) |
|---|
| 138 | |
|---|
| 139 | PYTHON_EXECS := fits2fits.py image2pnm.py |
|---|
| 140 | |
|---|
| 141 | PY_INSTALL_DIR := $(INSTALL_DIR)/python/astrometry/util |
|---|
| 142 | BIN_INSTALL_DIR := $(INSTALL_DIR)/bin |
|---|
| 143 | LINK_DIR := ../python/astrometry/util |
|---|
| 144 | |
|---|
| 145 | install: $(PYTHON_LIBS) |
|---|
| 146 | @echo Installing in base directory $(INSTALL_DIR) |
|---|
| 147 | mkdir -p $(PY_INSTALL_DIR) |
|---|
| 148 | @for x in $(PYTHON_INSTALL); do \ |
|---|
| 149 | echo cp $$x $(PY_INSTALL_DIR)/$$x; \ |
|---|
| 150 | cp $$x $(PY_INSTALL_DIR)/$$x; \ |
|---|
| 151 | done |
|---|
| 152 | @echo Making symlinks in directory $(BIN_INSTALL_DIR) |
|---|
| 153 | mkdir -p $(BIN_INSTALL_DIR) |
|---|
| 154 | @for x in $(PYTHON_EXECS); do \ |
|---|
| 155 | echo ln -f -s $(PY_INSTALL_DIR)/$$x $(BIN_INSTALL_DIR)/$$x; \ |
|---|
| 156 | ln -f -s $(LINK_DIR)/$$x $(BIN_INSTALL_DIR)/$$x; \ |
|---|
| 157 | done |
|---|
| 158 | @echo Installing executables into $(BIN_INSTALL_DIR)... |
|---|
| 159 | @for x in $(PROGS); do \ |
|---|
| 160 | echo cp $$x $(BIN_INSTALL_DIR)/$$x; \ |
|---|
| 161 | cp $$x $(BIN_INSTALL_DIR)/$$x; \ |
|---|
| 162 | done |
|---|
| 163 | |
|---|
| 164 | gnu-specific-config.h: gnu-specific-test.c |
|---|
| 165 | ( \ |
|---|
| 166 | (($(CC) -o gnu-specific-test-canonicalize \ |
|---|
| 167 | $(CFLAGS) -DTEST_CANONICALIZE_FILE_NAME $(LDFLAGS) $^ > /dev/null && \ |
|---|
| 168 | ./gnu-specific-test-canonicalize) \ |
|---|
| 169 | || echo "#define NEED_CANONICALIZE_FILE_NAME 1") \ |
|---|
| 170 | ; \ |
|---|
| 171 | (($(CC) -o gnu-specific-test-declare-qsort \ |
|---|
| 172 | $(CFLAGS) -DTEST_DECLARE_QSORT_R $(LDFLAGS) $^ > /dev/null && \ |
|---|
| 173 | ./gnu-specific-test-declare-qsort) \ |
|---|
| 174 | || echo "#define NEED_DECLARE_QSORT_R 0") \ |
|---|
| 175 | ; \ |
|---|
| 176 | (($(CC) -o gnu-specific-test-qsort \ |
|---|
| 177 | $(CFLAGS) -DTEST_QSORT_R $(LDFLAGS) $^ > /dev/null && \ |
|---|
| 178 | ./gnu-specific-test-qsort) \ |
|---|
| 179 | || echo "#define NEED_QSORT_R 1") \ |
|---|
| 180 | ; \ |
|---|
| 181 | (($(CC) -o gnu-specific-test-swap-qsort \ |
|---|
| 182 | $(CFLAGS) -DTEST_SWAP_QSORT_R $(LDFLAGS) $^ > /dev/null && \ |
|---|
| 183 | ./gnu-specific-test-swap-qsort) \ |
|---|
| 184 | || echo "#define NEED_SWAP_QSORT_R 0") \ |
|---|
| 185 | ; \ |
|---|
| 186 | echo) | grep -v "Segmentation" > $@ |
|---|
| 187 | |
|---|
| 188 | ALL_OBJ += gnu-specific.o |
|---|
| 189 | ALL_TARGETS := gnu-specific-test.o \ |
|---|
| 190 | gnu-specific-test-canonicalize \ |
|---|
| 191 | gnu-specific-test-declare-qsort \ |
|---|
| 192 | gnu-specific-test-qsort \ |
|---|
| 193 | gnu-specific-config.h |
|---|
| 194 | |
|---|
| 195 | DEP_OBJ := $(ANUTILS_OBJ) $(ANFILES_OBJ) $(MISC_OBJ) |
|---|
| 196 | ifndef NO_QFITS |
|---|
| 197 | DEP_PREREQS := $(QFITS_LIB) |
|---|
| 198 | endif |
|---|
| 199 | include $(COMMON)/makefile.deps |
|---|
| 200 | |
|---|
| 201 | stellarium-constellations.c: |
|---|
| 202 | -$(MAKE) grab-stellarium-constellations |
|---|
| 203 | -(./grab-stellarium-constellations > $@.tmp && mv $@.tmp $@) || touch $@ |
|---|
| 204 | |
|---|
| 205 | grab-stellarium-constellations: grab-stellarium-constellations.o \ |
|---|
| 206 | starutil.o mathutil.o bl.o an-endian.o |
|---|
| 207 | $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ -lm |
|---|
| 208 | |
|---|
| 209 | ### TESTS |
|---|
| 210 | |
|---|
| 211 | ALL_TEST_FILES = test_bl test_bt test_endian test_fitstable test_xylist \ |
|---|
| 212 | test_rdlist test_healpix test_fitsioutils test_fitsbin test_log test_ioutils \ |
|---|
| 213 | test_dualtree_nn test_scamp_catalog test_starutil test_svd |
|---|
| 214 | ALL_TEST_EXTRA_OBJS = |
|---|
| 215 | ALL_TEST_LIBS = $(LIBKD_LIB) $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) $(GSL_LIB) |
|---|
| 216 | |
|---|
| 217 | include $(COMMON)/makefile.tests |
|---|
| 218 | |
|---|
| 219 | DEP_OBJ += $(ALL_TEST_FILES_O) |
|---|
| 220 | |
|---|
| 221 | test_fitstable: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 222 | |
|---|
| 223 | test_fitsbin: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 224 | |
|---|
| 225 | test_fitsioutils: $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 226 | |
|---|
| 227 | test_xylist: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 228 | |
|---|
| 229 | test_rdlist: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 230 | |
|---|
| 231 | test_bl: $(ANUTILS_LIB) |
|---|
| 232 | |
|---|
| 233 | test_bt: $(ANUTILS_LIB) |
|---|
| 234 | |
|---|
| 235 | test_endian: $(ANUTILS_LIB) |
|---|
| 236 | |
|---|
| 237 | test_healpix: $(ANUTILS_LIB) |
|---|
| 238 | |
|---|
| 239 | test_log: $(ANUTILS_LIB) |
|---|
| 240 | |
|---|
| 241 | test_ioutils: $(ANUTILS_LIB) |
|---|
| 242 | |
|---|
| 243 | test_dualtree_nn: $(LIBKD_LIB) $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 244 | |
|---|
| 245 | test_scamp_catalog: $(ANFILES_LIB) $(ANUTILS_LIB) $(QFITS_LIB) |
|---|
| 246 | |
|---|
| 247 | test_starutil: $(ANUTILS_LIB) |
|---|
| 248 | |
|---|
| 249 | test_svd: $(ANUTILS_LIB) $(GSL_LIB) |
|---|
| 250 | |
|---|
| 251 | ### /TESTS |
|---|
| 252 | |
|---|
| 253 | # we'll just tack this on here... It depends on cairo, libjpeg, etc, so it's not part |
|---|
| 254 | # of the anX.a libraries. |
|---|
| 255 | ifeq ($(MAKECMDGOALS),cairoutils.o) |
|---|
| 256 | include cairoutils.dep |
|---|
| 257 | endif |
|---|
| 258 | |
|---|
| 259 | .PHONY: allclean realclean clean |
|---|
| 260 | |
|---|
| 261 | allclean: clean |
|---|
| 262 | rm -f *.o *~ *.dep *.so |
|---|
| 263 | |
|---|
| 264 | realclean: allclean |
|---|
| 265 | |
|---|
| 266 | clean: |
|---|
| 267 | rm -f $(ANUTILS_LIB) $(ANFILES_LIB) $(ALL_OBJ) \ |
|---|
| 268 | $(DEPS) deps cairoutils.o $(PYTHON_LIBS) \ |
|---|
| 269 | grab-stellarium-constellations \ |
|---|
| 270 | $(PROGS) $(ALL_TARGETS) $(ALL_TESTS_CLEAN) |
|---|