#----------------------------------------------------------------------------- # GNU makefile for building WCSLIB 4.3 and its test suite. # # Summary of the main targets # --------------------------- # build: Build the library. # clean: Delete intermediate object files. # cleaner: clean, and also delete the test executables. # realclean (or cleanest): cleaner, and also delete the object library # the C source files generated by 'flex', and wcsconfig.h and # wcsconfig_test.h which are generated by 'configure'. # check (or test): Compile and run the test programs. # tests: Compile the test programs (but don't run them). # check_s: Compile and run the scalar test programs. # tests_s: Compile the scalar test programs (but don't run them). # # Notes: # 1) If you need to make changes then preferably modify ../makedefs.in # instead and re-run configure. # # Author: Mark Calabretta, Australia Telescope National Facility # http://www.atnf.csiro.au/~mcalabre/index.html # $Id: GNUmakefile,v 4.3 2007/12/27 05:41:36 cal103 Exp $ #----------------------------------------------------------------------------- # Get configure settings. include ../makedefs MODULES := cel.o \ fitshdr.o \ lin.o \ log.o \ prj.o \ spc.o \ sph.o \ spx.o \ tab.o \ wcs.o \ wcsbth.o \ wcsfix.o \ wcshdr.o \ wcspih.o \ wcsulex.o \ wcsunits.o \ wcsutil.o \ wcsutrn.o ifeq "$(WCSTRIG)" "MACRO" CPPFLAGS += -DWCSTRIG_MACRO else ifneq "$(WCSTRIG)" "NATIVE" MODULES += wcstrig.o endif endif # Build the sharable library? ifneq "$(SHRLIB)" "" PICLIB := libwcs-PIC.a endif CPPFLAGS += -I. -I.. vpath %.c .:./test vpath %.h ..:. vpath %.in .. # For building and exercising the test suite # ------------------------------------------ # Signals tfitshdr to use wcshdr(). ifneq "$(DO_WCSHDR)" "" CPPFLAGS += -DDO_WCSHDR endif # Test programs that don't require PGPLOT. TEST_N := tlin tlog tprj1 tsph tspx ttab1 twcs twcssub tpih1 tbth1 tfitshdr \ tunits twcsfix # Test programs that do require PGPLOT. TEST_P := tspc tprj2 tcel1 tcel2 ttab2 ttab3 twcsmix TESTS := $(TEST_N) ifneq "$(PGPLOTINC)" "" ifneq "$(PGPLOTLIB)" "" TESTS += $(TEST_P) tpih2 TPRJ2_S := tprj2_s endif endif # Test programs that require CFITSIO. ifneq "$(CFITSIOINC)" "" ifneq "$(CFITSIOLIB)" "" TESTS += twcstab twcshdr endif endif PGSBOXLIB := ../pgsbox/libpgsbox-$V.a # Pattern rules #-------------- ifeq "$(FLEX)" "flex" %.c : %.l -@ echo '' -@ $(RM) $@ $(FLEX) $(FLFLAGS) -t $< | sed -e 's/^[ ]*#/#/' > $@ else %.c : %.l -@ echo '' -@ $(RM) $@ cp flexed/$@ . endif $(LIBWCS)(%.o) : %.c -@ echo '' $(CC) $(CPPFLAGS) $(CFLAGS) -c $< $(AR) r $(LIBWCS) $% -@ $(RM) $% $(PICLIB)(%.o) : %.c -@ echo '' $(CC) $(CPPFLAGS) $(SHRFLAGS) -c $< $(AR) r $(PICLIB) $% -@ $(RM) $% %.i : %.c -@ echo '' -@ $(RM) $@ $(CPP) $(CPPFLAGS) $(CFLAGS) $< > $@ %.d : %.c -@ echo '' -@ $(CPP) $(CPPFLAGS) $(CFLAGS) $< | \ sed -n -e 's|^# 1 "\([^/].*\.h\)".*|\1|p' | \ sort -u run_% : % -@ echo '' -@ $(TIMER) @ if [ '$<' = tcel2 ] ; then \ echo N | $< ; \ elif [ '$<' = tunits ] ; then \ ./$< < test/units_test ; \ elif [ '$<' != twcshdr ] ; then \ ./$< < /dev/null 2>&1 ; \ fi -@ echo '' # Static and static pattern rules #-------------------------------- .PHONY : build check check_s clean cleaner cleanest install lib realclean \ run_% test test_s tests tests_s build : lib lib : fitshdr.c wcsbth.c wcspih.c wcsulex.c wcsutrn.c $(LIBWCS) $(SHRLIB) $(LIBWCS) : $(MODULES:%=$(LIBWCS)(%)) -@ echo '' $(RANLIB) $@ $(SHRLIB) : $(PICLIB) -@ echo '' -@ $(RM) -r tmp mkdir tmp cd tmp && $(AR) x ../$(PICLIB) && $(SHRLD) -o $@ *.o && mv $@ .. - $(RM) -r tmp $(PICLIB) : $(MODULES:%.o=$(PICLIB)(%.o)) ; install : build - if [ ! -d "$(LIBDIR)" ] ; then \ $(INSTALL) -d -m 2775 $(LIBDIR) ; \ fi $(INSTALL) -m 644 $(LIBWCS) $(LIBDIR) $(RANLIB) $(LIBDIR)/$(LIBWCS) $(RM) $(LIBDIR)/libwcs.a $(LN_S) $(LIBDIR)/$(LIBWCS) $(LIBDIR)/libwcs.a - if [ "$(SHRLIB)" != "" ] ; then \ $(INSTALL) -m 644 $(SHRLIB) $(LIBDIR) ; \ if [ "$(SHRLN)" != "" ] ; then \ $(LN_S) $(LIBDIR)/$(SHRLIB) $(LIBDIR)/$(SHRLN) ; \ fi ; \ fi - if [ ! -d "$(INCDIR)" ] ; then \ $(INSTALL) -d -m 2775 $(INCDIR) ; \ fi $(INSTALL) -m 444 CHANGES $(INCDIR)/CHANGES_C $(INSTALL) -m 444 *.h $(INCDIR) $(RM) $(INCLINK) $(LN_S) $(INCDIR) $(INCLINK) clean : - $(RM) *.o *.i a.out core $(EXTRA_CLEAN) cleaner : clean - $(RM) $(TEST_N) - $(RM) $(TEST_P) tpih2 twcstab twcshdr - $(RM) tofits bth.fits pih.fits wcstab.fits - $(RM) t*_cfitsio - $(RM) tlin_s tprj1_s tprj2_s tsph_s cleanest realclean : cleaner - $(RM) ../wcsconfig.h ../wcsconfig_tests.h - $(RM) fitshdr.c wcsbth.c wcspih.c wcsulex.c wcsutrn.c - $(RM) $(LIBWCS) $(PICLIB) $(SHRLIB) check : tests $(TESTS:%=run_%) tests : $(TESTS) $(TEST_N) : % : test/%.c $(LIBWCS) -@ echo '' $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBWCS) $(LIBS) -@ $(RM) $@.o $(TEST_P) : % : test/%.c $(LIBWCS) -@ echo '' $(CC) $(CPPFLAGS) $(PGPLOTINC) $(CFLAGS) -c -o $@.o $< $(LD) $(LDFLAGS) -o $@ $@.o $(PGPLOTLIB) $(LIBWCS) $(LIBS) -@ $(RM) $@.o tpih2 : test/tpih2.c $(PGSBOXLIB) $(LIBWCS) -@ echo '' $(CC) $(CPPFLAGS) -I../pgsbox $(PGPLOTINC) $(CFLAGS) -c -o $@.o $< $(LD) $(LDFLAGS) -o $@ $@.o $(PGSBOXLIB) $(PGPLOTLIB) $(LIBWCS) \ $(FLIBS) $(LIBS) -@ $(RM) $@.o tfitshdr_cfitsio tpih1_cfitsio tbth1_cfitsio : %_cfitsio : test/%.c $(LIBWCS) -@ echo '' $(CC) -DDO_CFITSIO $(CPPFLAGS) $(CFITSIOINC) $(CFLAGS) \ $(LDFLAGS) -o $@ $< $(CFITSIOLIB) $(LIBWCS) $(LIBS) -@ $(RM) $@.o tpih2_cfitsio : test/tpih2.c $(PGSBOXLIB) $(LIBWCS) -@ echo '' $(CC) -DDO_CFITSIO $(CPPFLAGS) -I../pgsbox $(PGPLOTINC) \ $(CFITSIOINC) $(CFLAGS) -c -o $@.o $< $(LD) $(LDFLAGS) -o $@ $@.o $(PGSBOXLIB) $(PGPLOTLIB) \ $(CFITSIOLIB) $(LIBWCS) $(FLIBS) $(LIBS) -@ $(RM) $@.o twcstab : test/twcstab.c test/wcstab.keyrec $(LIBWCS) $(GETWCSTAB) -@ echo '' $(CC) $(CPPFLAGS) $(CFITSIOINC) $(CFLAGS) $(LDFLAGS) -o $@ $< \ $(GETWCSTAB) $(CFITSIOLIB) $(LIBWCS) $(LIBS) -@ $(RM) $@.o twcshdr : test/twcshdr.c $(LIBWCS) $(GETWCSTAB) -@ echo '' $(CC) $(CPPFLAGS) $(CFITSIOINC) $(CFLAGS) $(LDFLAGS) -o $@ $< \ $(GETWCSTAB) $(CFITSIOLIB) $(LIBWCS) $(LIBS) -@ $(RM) $@.o getwcstab.o : getwcstab.c getwcstab.h -@ echo '' $(CC) $(CPPFLAGS) $(CFLAGS) $(CFITSIOINC) -c $< $(PGSBOXLIB) : -@ echo '' $(MAKE) -C ../pgsbox lib tofits : test/tofits.c $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< pih.fits : test/pih.keyrec tofits sed '/^\*/q' $< | ./tofits > $@ bth.fits : test/bth.keyrec tofits sed '/^\*/q' $< | ./tofits > $@ check_s test_s : tests_s run_tlin_s run_tprj1_s $(TPRJ2_S:%=run_%) run_tsph_s ; tests_s : tlin_s tprj1_s $(TPRJ2_S) tsph_s ; tlin_s tprj1_s tsph_s : % : test_s/%.c $(LIBWCS) -@ echo '' $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBWCS) $(LIBS) -@ $(RM) $@.o tprj2_s : % : test_s/%.c $(LIBWCS) -@ echo '' $(CC) $(CPPFLAGS) $(PGPLOTINC) $(CFLAGS) -c -o $@.o $< $(LD) $(LDFLAGS) -o $@ $@.o $(PGPLOTLIB) $(LIBWCS) $(LIBS) -@ $(RM) $@.o GNUmakefile : ../makedefs ; ../makedefs ../wcsconfig.h ../wcsconfig_tests.h : makedefs.in wcsconfig.h.in \ wcsconfig_tests.h.in ../config.status -@ $(RM) ../wcsconfig.h ../wcsconfig_tests.h cd .. && config.status # Dependencies #------------- $(LIBWCS)(cel.o) : cel.h prj.h sph.h wcsmath.h wcstrig.h $(LIBWCS)(fitshdr.o) : wcsconfig.h fitshdr.h $(LIBWCS)(lin.o) : lin.h $(LIBWCS)(log.o) : log.h $(LIBWCS)(prj.o) : prj.h wcsmath.h wcstrig.h $(LIBWCS)(spc.o) : spc.h spx.h wcsmath.h wcstrig.h $(LIBWCS)(sph.o) : sph.h wcstrig.h $(LIBWCS)(spx.o) : spx.h $(LIBWCS)(tab.o) : tab.h wcsmath.h $(LIBWCS)(wcs.o) : cel.h lin.h log.h prj.h spc.h sph.h spx.h tab.h \ wcs.h wcsmath.h wcstrig.h wcsunits.h wcsutil.h $(LIBWCS)(wcsbth.o) : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h wcshdr.h \ wcsmath.h $(LIBWCS)(wcsfix.o) : cel.h lin.h prj.h spc.h sph.h spx.h tab.h wcs.h \ wcsfix.h wcsmath.h wcsunits.h $(LIBWCS)(wcshdr.o) : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h wcshdr.h \ wcsutil.h $(LIBWCS)(wcspih.o) : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h wcshdr.h \ wcsmath.h $(LIBWCS)(wcstrig.o) : wcsmath.h wcstrig.h $(LIBWCS)(wcsulex.o) : wcsmath.h wcsunits.h $(LIBWCS)(wcsunits.o) : wcsunits.h $(LIBWCS)(wcsutil.o) : wcsutil.h $(LIBWCS)(wcsutrn.o) : wcsunits.h tbth1 tbth1_cfitsio : cel.h wcsconfig.h wcsconfig_tests.h lin.h prj.h spc.h \ spx.h tab.h wcs.h wcsfix.h wcshdr.h bth.fits tcel1 : cel.h prj.h tcel2 : cel.h prj.h tfitshdr tfitshdr_cfitsio : wcsconfig.h wcsconfig_tests.h fitshdr.h pih.fits tlin : lin.h tlin_s : lin.h tlog : log.h tpih1 tpih1_cfitsio : cel.h wcsconfig.h wcsconfig_tests.h lin.h prj.h spc.h \ spx.h tab.h wcs.h wcsfix.h wcshdr.h pih.fits tpih2 tpih2_cfitsio : cel.h wcsconfig.h wcsconfig_tests.h lin.h prj.h spc.h \ spx.h tab.h wcs.h wcshdr.h pih.fits tprj1 : prj.h wcstrig.h tprj1_s : prj.h wcstrig.h tprj2 : prj.h tprj2_s : prj.h tspc : spc.h spx.h wcstrig.h tsph : sph.h wcstrig.h tsph_s : sph.h wcstrig.h tspx : spx.h ttab1 : tab.h ttab2 : tab.h ttab3 : prj.h tab.h tunits : wcsunits.h twcs : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h twcsfix : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h wcsfix.h wcsunits.h twcshdr : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h wcshdr.h twcsmix : cel.h lin.h prj.h spc.h sph.h spx.h tab.h wcs.h twcssub : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h twcstab : cel.h lin.h prj.h spc.h spx.h tab.h wcs.h wcshdr.h