Blob Blame Raw
From: Ole Streicher <olebole@debian.org>
Date: Thu, 1 Dec 2016 21:18:56 +0100
Subject: Dynamically link to libastrometry.so, when possible

---
 blind/Makefile | 10 ++++------
 libkd/Makefile |  3 +--
 util/Makefile  |  8 +++-----
 3 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/blind/Makefile b/blind/Makefile
index 5ce0c89..66fdc54 100644
--- a/blind/Makefile
+++ b/blind/Makefile
@@ -43,9 +43,7 @@ LDFLAGS := $(LDFLAGS_DEF)
 LDLIBS := $(LDLIBS_DEF)
 LDLIBS += $(ANFILES_LIB)
 
-SLIB := $(ENGINE_LIB)
-SLIB += $(CATS_SLIB)
-SLIB += $(ANFILES_SLIB)
+SLIB := $(ENGINE_SO)
 
 CAIRO_SLIB := $(COMMON)/cairoutils.o
 CAIRO_SLIB += $(SLIB)
@@ -130,7 +128,7 @@ ENGINE_OBJS += new-wcs.o fits-guess-scale.o cut-table.o \
 	resort-xylist.o
 
 BUILD_INDEX_OBJS := build-index.o uniformize-catalog.o startree.o hpquads.o \
-	quad-builder.o quad-utils.o codefile.o codetree.o unpermute-stars.o \
+	quad-builder.o codefile.o codetree.o unpermute-stars.o \
 	unpermute-quads.o merge-index.o 
 ENGINE_OBJS += $(BUILD_INDEX_OBJS)
 
@@ -146,8 +144,8 @@ $(ENGINE_LIB): $(ENGINE_OBJS)
 	$(AR) rc $@ $(ENGINE_OBJS)
 	$(RANLIB) $@
 
-$(ENGINE_SO): $(ENGINE_OBJS) $(SLIB)
-	$(CC) $(LDFLAGS) $(SHAREDLIBFLAGS) -Wl,-soname,$@.0 -o $@.0 $^ $(LDLIBS)
+$(ENGINE_SO): $(ENGINE_LIB) $(CATS_SLIB) $(ANFILES_SLIB)
+	$(CC) $(LDFLAGS) $(SHAREDLIBFLAGS) -Wl,-soname,$@.0 -o $@.0 -Wl,--whole-archive $^ -Wl,--no-whole-archive $(LDLIBS) -lpthread
 	ln -s  $@.0 $@
 
 # old and miscellaneous executables that aren't part of the pipeline.
diff --git a/libkd/Makefile b/libkd/Makefile
index f535986..0442518 100644
--- a/libkd/Makefile
+++ b/libkd/Makefile
@@ -90,8 +90,7 @@ py: pyspherematch
 PYSPHEREMATCH_OBJ := pyspherematch.o
 
 spherematch_c$(PYTHON_SO_EXT): pyspherematch.c setup.py $(SLIB)
-	LDFLAGS="$(LDFLAGS)" LDLIBS="$(LDLIBS)" \
-	SLIB="$(SLIB)" \
+	LDFLAGS="$(LDFLAGS)" LDLIBS="-L../blind -lastrometry" \
 	INC="$(INC)" \
 	CFLAGS="$(CFLAGS)" \
 	$(PYTHON) setup.py build_ext --inplace --force --build-temp .
diff --git a/util/Makefile b/util/Makefile
index b00f71f..84507bb 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -50,8 +50,7 @@ ANFILES_OBJ += multiindex.o index.o codekd.o starkd.o rdlist.o xylist.o \
 	tabsort.o wcs-xy2rd.o wcs-rd2xy.o
 ANFILES_DEPS += $(QFITS_LIB)
 
-ANUTILS_OBJ += fitsioutils.o sip_qfits.o fitstable.o fitsbin.o fitsfile.o \
-	tic.o
+ANUTILS_OBJ += fitsioutils.o sip_qfits.o fitstable.o fitsbin.o fitsfile.o
 ANUTILS_DEPS += $(QFITS_LIB)
 endif
 
@@ -96,8 +95,7 @@ CFLAGS += -I.
 
 LDFLAGS += $(LDFLAGS_DEF)
 
-LDLIBS := $(LDLIBS_DEF)
-LDLIBS += $(ANFILES_LIB)
+LDLIBS := $(LDLIBS_DEF) -lm
 
 SHAREDLIBFLAGS := $(SHAREDLIBFLAGS_DEF)
 
@@ -161,7 +159,7 @@ an-pnmtofits: an-pnmtofits.o $(ANUTILS_SLIB)
 ALL_OBJ += an-pnmtofits.o
 
 _util$(PYTHON_SO_EXT): util.i lanczos.i $(ANFILES_SLIB)
-	LDFLAGS="$(LDFLAGS)" LDLIBS="$(LDLIBS)" SLIB="$(ANFILES_SLIB)" \
+	LDFLAGS="$(LDFLAGS)" LDLIBS="-L../blind -lastrometry" \
 	INC="$(ANFILES_INC)" CFLAGS="$(CFLAGS)" \
 	$(PYTHON) setup.py build_ext -v --inplace --build-temp .
 util.py: util.i lanczos.i