aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/wcstools-extend-makefiles.patch
blob: 127bf0e670fd3f434ee31052a37ab40b6b35a98c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
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