summaryrefslogtreecommitdiff
path: root/graphics/giflib/patches/patch-Makefile
blob: f831ab5f8de1b06fe54483cb4ad0b0e2d5aeff48 (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
$NetBSD: patch-Makefile,v 1.2 2020/01/11 13:33:31 schmonz Exp $

- Inherit the PREFIX rather than hard-coding it.
- Adjust location where manuals are installed.
- Apply <https://sourceforge.net/p/giflib/bugs/_discuss/thread/4e811ad29b/>
  to fix Darwin build

--- Makefile.orig	2019-06-24 16:08:57.000000000 +0000
+++ Makefile
@@ -14,7 +14,7 @@ SHELL = /bin/sh
 TAR = tar
 INSTALL = install
 
-PREFIX = /usr/local
+PREFIX?= /usr/local
 BINDIR = $(PREFIX)/bin
 INCDIR = $(PREFIX)/include
 LIBDIR = $(PREFIX)/lib
@@ -37,6 +37,8 @@ USOURCES = qprintf.c quantize.c getarg.c
 UHEADERS = getarg.h
 UOBJECTS = $(USOURCES:.c=.o)
 
+UNAME:=$(shell uname)
+
 # Some utilities are installed
 INSTALLABLE = \
 	gif2rgb \
@@ -61,27 +63,48 @@ UTILS = $(INSTALLABLE) \
 
 LDLIBS=libgif.a -lm
 
-all: libgif.so libgif.a libutil.so libutil.a $(UTILS)
-	$(MAKE) -C doc
+ifeq ($(UNAME), Darwin)
+SOEXTENSION	= dylib
+LIBGIFSOMAJOR   = libgif.$(LIBMAJOR).$(SOEXTENSION)
+LIBGIFSOVER	= libgif.$(LIBVER).$(SOEXTENSION)
+LIBUTILSOMAJOR	= libutil.$(LIBMAJOR).$(SOEXTENSION)
+else
+SOEXTENSION	= so
+LIBGIFSOMAJOR	= libgif.$(SOEXTENSION).$(LIBMAJOR)
+LIBGIFSOVER	= libgif.$(SOEXTENSION).$(LIBVER)
+LIBUTILSOMAJOR	= libutil.$(SOEXTENSION).$(LIBMAJOR)
+endif
+LIBGIFSO        = libgif.$(SOEXTENSION)
+LIBUTILSO	= libutil.$(SOEXTENSION)
+
+all: $(LIBGIFSO) libgif.a $(LIBUTILSO) libutil.a $(UTILS)
 
 $(UTILS):: libgif.a libutil.a
 
-libgif.so: $(OBJECTS) $(HEADERS)
-	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
+$(LIBGIFSO): $(OBJECTS) $(HEADERS)
+ifeq ($(UNAME), Darwin)
+	$(CC) $(CFLAGS) -dynamiclib -current_version $(LIBVER) $(OBJECTS) -o $(LIBGIFSO)
+else
+	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,$(LIBGIFSOMAJOR) -o $(LIBGIFSO) $(OBJECTS)
+endif
 
 libgif.a: $(OBJECTS) $(HEADERS)
 	$(AR) rcs libgif.a $(OBJECTS)
 
-libutil.so: $(UOBJECTS) $(UHEADERS)
-	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
+$(LIBUTILSO): $(UOBJECTS) $(UHEADERS)
+ifeq ($(UNAME), Darwin)
+	$(CC) $(CFLAGS) -dynamiclib -current_version $(LIBVER) $(OBJECTS) -o $(LIBUTILSO)
+else
+	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,$(LIBUTILMAJOR) -o $(LIBUTILSO) $(UOBJECTS)
+endif
 
 libutil.a: $(UOBJECTS) $(UHEADERS)
 	$(AR) rcs libutil.a $(UOBJECTS)
 
 clean:
-	rm -f $(UTILS) $(TARGET) libgetarg.a libgif.a libgif.so libutil.a libutil.so *.o
-	rm -f libgif.so.$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
-	rm -f libgif.so.$(LIBMAJOR)
+	rm -f $(UTILS) $(TARGET) libgetarg.a libgif.a $(LIBGIFSO) libutil.a $(LIBUTILSO) *.o
+	rm -f $(LIBGIFSOVER)
+	rm -f $(LIBGIFSOMAJOR)
 	rm -fr doc/*.1 *.html doc/staging
 
 check: all
@@ -89,7 +112,8 @@ check: all
 
 # Installation/uninstallation
 
-install: all install-bin install-include install-lib install-man
+install: all install-bin install-include install-lib
+
 install-bin: $(INSTALLABLE)
 	$(INSTALL) -d "$(DESTDIR)$(BINDIR)"
 	$(INSTALL) $^ "$(DESTDIR)$(BINDIR)"
@@ -99,9 +123,12 @@ install-include:
 install-lib:
 	$(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
 	$(INSTALL) -m 644 libgif.a "$(DESTDIR)$(LIBDIR)/libgif.a"
-	$(INSTALL) -m 755 libgif.so "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBVER)"
-	ln -sf libgif.so.$(LIBVER) "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBMAJOR)"
-	ln -sf libgif.so.$(LIBMAJOR) "$(DESTDIR)$(LIBDIR)/libgif.so"
+	$(INSTALL) -m 755 $(LIBGIFSO) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSOVER)"
+	ln -sf $(LIBGIFSOVER) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSOMAJOR)"
+	ln -sf $(LIBGIFSOMAJOR) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSO)"
+	$(INSTALL) -m 644 libutil.a "$(DESTDIR)$(LIBDIR)/libgifutil.a"
+	$(INSTALL) -m 755 $(LIBUTILSO) "$(DESTDIR)$(LIBDIR)/libgifutil.$(SOEXTENSION)"
+
 install-man:
 	$(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1"
 	$(INSTALL) -m 644 doc/*.1 "$(DESTDIR)$(MANDIR)/man1"
@@ -112,7 +139,7 @@ uninstall-include:
 	rm -f "$(DESTDIR)$(INCDIR)/gif_lib.h"
 uninstall-lib:
 	cd "$(DESTDIR)$(LIBDIR)" && \
-		rm -f libgif.a libgif.so libgif.so.$(LIBMAJOR) libgif.so.$(LIBVER)
+		rm -f libgif.a $(LIBGIFSO) $(LIBGIFSOMAJOR) $(LIBGIFSOVER)
 uninstall-man:
 	cd "$(DESTDIR)$(MANDIR)/man1" && rm -f $(shell cd doc >/dev/null && echo *.1)