aboutsummaryrefslogtreecommitdiff
From d702ed6d9da604e522625d08750636f680536743 Mon Sep 17 00:00:00 2001
From: Sharlatan Hellseher <sharlatanus@gmail.com>
Date: Mon, 11 Sep 2023 21:12:53 +0100
Subject: [PATCH] wcstools: Extend makefiles.

This patch was partly sourced from Debian Astro:
- source: https://salsa.debian.org/debian-astro-team/wcstools/-/tree/master/
  - file: debian/patches/Rename-libwcs-to-libwcstools-to-avoid-conflicts-with-Mark.patch
  - commit: 91eb27654fa096d6adebb26dab8d94f5fc2fc721

Additional changes applied:
- do not rename library from libwcs to libwcstools
- add 'install' target
- add PREFIX and VERSION to ease packaging process
---
 Makefile        | 146 ++++++++++++++++++++++++++----------------------
 libwcs/Makefile |  22 ++++++--
 2 files changed, 96 insertions(+), 72 deletions(-)

diff --git a/Makefile b/Makefile
index cdc8a46..caadd97 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,13 @@
-CFLAGS= -g -D_FILE_OFFSET_BITS=64
-CC= cc
+CC = cc
 LIBWCS = libwcs/libwcs.a
 LIBS = $(LIBWCS) -lm
-#LIBS = $(LIBWCS) -lm -lnsl -lsocket
+
+PREFIX ?= /usr
 BIN = bin
+
 .PRECIOUS: ${LIBWCS} ${LIBNED}
 .c.o:
-	$(CC) -c $(CFLAGS) $(DEFS) $<
+	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(DEFS) $<
 
 all:	cphead delwcs delhead edhead fixpix gethead i2f imcat imhead immatch \
 	imrot imsize imstar imwcs scat sethead addpix getpix setpix sky2xy \
@@ -16,196 +17,205 @@ all:	cphead delwcs delhead edhead fixpix gethead i2f imcat imhead immatch \
 	isfile simpos bincat
 
 addpix: addpix.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/addpix addpix.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/addpix addpix.c $(LIBS)
 
 bincat: bincat.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/bincat bincat.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/bincat bincat.c $(LIBS)
 
 char2sp: char2sp.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/char2sp char2sp.c $(LIBWCS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/char2sp char2sp.c $(LIBWCS)
 
 conpix: conpix.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/conpix conpix.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/conpix conpix.c $(LIBS)
 
 cphead: cphead.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/cphead cphead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/cphead cphead.c $(LIBS)
 
 crlf: crlf.c
-	$(CC) $(CFLAGS) -o $(BIN)/crlf crlf.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/crlf crlf.c
 
 delwcs: delwcs.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/delwcs delwcs.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/delwcs delwcs.c $(LIBS)
 
 delhead: delhead.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/delhead delhead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/delhead delhead.c $(LIBS)
 
 edhead: edhead.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/edhead edhead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/edhead edhead.c $(LIBS)
 
 filename: filename.c
-	$(CC) $(CFLAGS) -o $(BIN)/filename filename.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/filename filename.c
 
 filedir: filedir.c
-	$(CC) $(CFLAGS) -o $(BIN)/filedir filedir.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/filedir filedir.c
 
 fileroot: fileroot.c
-	$(CC) $(CFLAGS) -o $(BIN)/fileroot fileroot.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/fileroot fileroot.c
 
 filext: filext.c
-	$(CC) $(CFLAGS) -o $(BIN)/filext filext.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/filext filext.c
 
 fixhead: fixhead.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/fixhead fixhead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/fixhead fixhead.c $(LIBS)
 
 fixpix: fixpix.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/fixpix fixpix.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/fixpix fixpix.c $(LIBS)
 
 getcol: getcol.c $(LIBWCS) libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/getcol getcol.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getcol getcol.c $(LIBS)
 
 getdate: getdate.c $(LIBWCS) libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/getdate getdate.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getdate getdate.c $(LIBS)
 
 gethead: gethead.c $(LIBWCS) libwcs/wcs.h libwcs/fitsfile.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/gethead gethead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/gethead gethead.c $(LIBS)
 
 getfits: getfits.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/getfits getfits.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getfits getfits.c $(LIBS)
 
 getpix: getpix.c $(LIBWCS) libwcs/wcs.h libwcs/fitsfile.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/getpix getpix.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/getpix getpix.c $(LIBS)
 
 gettab: gettab.c $(LIBWCS) libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/gettab gettab.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/gettab gettab.c $(LIBS)
 
 httpget: httpget.c $(LIBWCS) libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/httpget httpget.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/httpget httpget.c $(LIBS)
 
 htmlsp: htmlsp.c
-	$(CC) $(CFLAGS) -o $(BIN)/htmlsp htmlsp.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/htmlsp htmlsp.c
 
 i2f: i2f.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/i2f i2f.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/i2f i2f.c $(LIBS)
 
 imcat: imcat.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/imcat imcat.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imcat imcat.c $(LIBS)
 
 imfill: imfill.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/imfill imfill.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imfill imfill.c $(LIBS)
 
 imresize: imresize.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/imresize imresize.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imresize imresize.c $(LIBS)
 
 imsmooth: imsmooth.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/imsmooth imsmooth.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imsmooth imsmooth.c $(LIBS)
 
 imhead: imhead.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/imhead imhead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imhead imhead.c $(LIBS)
 
 imrot: imrot.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/imrot imrot.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imrot imrot.c $(LIBS)
 
 imsize: imsize.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/imsize imsize.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imsize imsize.c $(LIBS)
 
 imstack: imstack.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/imstack imstack.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imstack imstack.c $(LIBS)
 
 imextract: imextract.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/imextract imextract.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imextract imextract.c $(LIBS)
 
 imstar: imstar.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h libwcs/lwcs.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/imstar imstar.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imstar imstar.c $(LIBS)
 
 isfile: isfile.c $(LIBWCS) libwcs/fitshead.h
-	$(CC) $(CFLAGS) -o $(BIN)/isfile isfile.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isfile isfile.c $(LIBS)
 
 isfits: isfits.c $(LIBWCS) libwcs/fitshead.h
-	$(CC) $(CFLAGS) -o $(BIN)/isfits isfits.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isfits isfits.c $(LIBS)
 
 isnum: isnum.c $(LIBWCS) libwcs/fitshead.h
-	$(CC) $(CFLAGS) -o $(BIN)/isnum isnum.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isnum isnum.c $(LIBS)
 
 isdate: isdate.c $(LIBWCS) libwcs/fitshead.h
-	$(CC) $(CFLAGS) -o $(BIN)/isdate isdate.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isdate isdate.c $(LIBS)
 
 isimlist: isimlist.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/isimlist isimlist.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isimlist isimlist.c $(LIBS)
 
 isrange: isrange.c
-	$(CC) $(CFLAGS) -o $(BIN)/isrange isrange.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/isrange isrange.c
 
 imwcs: imwcs.c $(LIBWCS) libwcs/fitsfile.h libwcs/lwcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/imwcs imwcs.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/imwcs imwcs.c $(LIBS)
 
 immatch: immatch.c $(LIBWCS) libwcs/fitsfile.h libwcs/lwcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/immatch immatch.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/immatch immatch.c $(LIBS)
 
 immwcs: immwcs.c $(LIBWCS) libwcs/fitsfile.h libwcs/lwcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/immwcs immwcs.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/immwcs immwcs.c $(LIBS)
 
 keyhead: keyhead.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/keyhead keyhead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/keyhead keyhead.c $(LIBS)
 
 matchcat: matchcat.c $(LIBWCS) libwcs/wcscat.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/matchcat matchcat.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/matchcat matchcat.c $(LIBS)
 
 newfits: newfits.c $(LIBWCS) libwcs/fitshead.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/newfits newfits.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/newfits newfits.c $(LIBS)
 
 remap: remap.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/remap remap.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/remap remap.c $(LIBS)
 
 scat: scat.c $(LIBWCS) libwcs/wcscat.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/scat scat.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/scat scat.c $(LIBS)
 
 sethead: sethead.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h
-	$(CC) $(CFLAGS) -o $(BIN)/sethead sethead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sethead sethead.c $(LIBS)
 
 setpix: setpix.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/setpix setpix.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/setpix setpix.c $(LIBS)
 
 sky2xy: sky2xy.c $(LIBWCS) libwcs/wcs.h libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/sky2xy sky2xy.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sky2xy sky2xy.c $(LIBS)
 
 skycoor: skycoor.c $(LIBWCS) libwcs/wcs.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/skycoor skycoor.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/skycoor skycoor.c $(LIBS)
 
 sp2char: sp2char.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/sp2char sp2char.c $(LIBWCS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sp2char sp2char.c $(LIBWCS)
 
 subpix: subpix.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/subpix subpix.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/subpix subpix.c $(LIBS)
 
 sumpix: sumpix.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/sumpix sumpix.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/sumpix sumpix.c $(LIBS)
 
 wcshead: wcshead.c $(LIBWCS) libwcs/fitsfile.h
-	$(CC) $(CFLAGS) -o $(BIN)/wcshead wcshead.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/wcshead wcshead.c $(LIBS)
 
 xy2sky: xy2sky.c $(LIBWCS) libwcs/wcs.h libwcs/wcscat.h
-	$(CC) $(CFLAGS) -o $(BIN)/xy2sky xy2sky.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/xy2sky xy2sky.c $(LIBS)
 
 simpos: simpos.c libwcs/libwcs.a
-	$(CC) $(CFLAGS) -o $(BIN)/simpos simpos.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/simpos simpos.c $(LIBS)
 
 gsc2cat: gsc2cat.c $(LIBWCS)
-	$(CC) $(CFLAGS) -o $(BIN)/gsc2cat gsc2cat.c $(LIBS)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/gsc2cat gsc2cat.c $(LIBS)
 
 tmcat: tmcat.c
-	$(CC) $(CFLAGS) -o $(BIN)/tmcat tmcat.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/tmcat tmcat.c
 
 tmcate: tmcate.c
-	$(CC) $(CFLAGS) -o $(BIN)/tmcate tmcate.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(BIN)/tmcate tmcate.c
 
 $(LIBWCS): libwcs/*.c libwcs/*.h
-	cd libwcs; make
+	$(MAKE) CC=$(CC) -C libwcs
+
+install:
+	test -e $(DESTDIR)$(PREFIX)/bin || mkdir -p $(DESTDIR)$(PREFIX)/bin
+	test -e $(DESTDIR)$(PREFIX)/include || mkdir -p $(DESTDIR)$(PREFIX)/include/wcstools
+	test -e $(DESTDIR)$(PREFIX)/lib/wcstools || mkdir -p $(DESTDIR)$(PREFIX)/lib/wcstools
+	test -e $(DESTDIR)$(PREFIX)/share/wcstools || mkdir -p $(DESTDIR)$(PREFIX)/share/wcstools
+	install ./bin/* $(DESTDIR)$(PREFIX)/bin
+	install ./libwcs/*.so $(DESTDIR)$(PREFIX)/lib/wcstools
+	install ./libwcs/*.so.* $(DESTDIR)$(PREFIX)/lib/wcstools
 
 objclean:
-	cd libwcs; make clean
+	$(MAKE) -C libwcs clean
 
 binclean:
 	rm -f ./bin/*
 
 clean:
-	make objclean; make binclean
+	objclean binclean
diff --git a/libwcs/Makefile b/libwcs/Makefile
index ec2fae0..038ec61 100644
--- a/libwcs/Makefile
+++ b/libwcs/Makefile
@@ -1,5 +1,10 @@
-CFLAGS= -g -D_FILE_OFFSET_BITS=64
-CC= cc
+CFLAGS+= -fPIC
+
+VERSION?= 3.9.7
+VERSION_PARTS= $(subst ., ,$(VERSION))
+VERSION_MAJOR= $(word 1,$(VERSION_PARTS))
+VERSION_MINOR= $(word 2,$(VERSION_PARTS))
+VERSION_MICRO= $(word 3,$(VERSION_PARTS))
 
 OBJS =	imsetwcs.o imgetwcs.o matchstar.o findstar.o daoread.o wcscon.o \
 	fitswcs.o wcsinit.o wcs.o ty2read.o webread.o tmcread.o \
@@ -11,10 +16,19 @@ OBJS =	imsetwcs.o imgetwcs.o matchstar.o findstar.o daoread.o wcscon.o \
 	sortstar.o platefit.o iget.o fileutil.o \
 	wcslib.o lin.o cel.o proj.o sph.o wcstrig.o distort.o poly.o
 
-libwcs.a:	$(OBJS)
+all: libwcs.so.$(VERSION) libwcs.a
 	ar rv $@ $?
 	ranlib $@
 
+libwcs.a: $(OBJS)
+	ar rv $@ $?
+	ranlib $@
+
+libwcs.so.$(VERSION): $(OBJS)
+	$(CC) $(LDFLAGS) -shared -o $@ -Wl,-soname,libwcs.so.$(VERSION_MAJOR) $? -lm
+	ln -s libwcs.so.$(VERSION) libwcs.so.$(VERSION_MAJOR)
+	ln -s libwcs.so.$(VERSION) libwcs.so
+
 actread.o:	fitsfile.h wcscat.h wcs.h fitshead.h wcslib.h
 binread.o:	wcscat.h wcs.h fitshead.h wcslib.h
 ctgread.o:	wcscat.h wcs.h fitshead.h wcslib.h
@@ -67,4 +81,4 @@ webread.o:	wcscat.h
 worldpos.o:	wcs.h fitshead.h wcslib.h
 
 clean:
-	rm -f *.a *.o
+	rm -f *.a *.o *.so *.so.*
-- 
2.41.0