-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
219 lines (184 loc) · 5.79 KB
/
Makefile
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
# Top-level Unix makefile for the GIFLIB package
# Should work for all Unix versions
#
# If your platform has the OpenBSD reallocarray(3) call, you may
# add -DHAVE_REALLOCARRAY to CFLAGS to use that, saving a bit
# of code space in the shared library.
#
OFLAGS = -O0 -g
OFLAGS = -O2
CFLAGS = -std=gnu99 -fPIC -Wall -Wno-format-truncation $(OFLAGS)
SHELL = /bin/sh
TAR = tar
INSTALL = install
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
INCDIR = $(PREFIX)/include
LIBDIR = $(PREFIX)/lib
MANDIR = $(PREFIX)/share/man
# No user-serviceable parts below this line
VERSION:=$(shell ./getversion)
LIBMAJOR=7
LIBMINOR=2
LIBPOINT=0
LIBVER=$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
SOURCES = dgif_lib.c egif_lib.c gifalloc.c gif_err.c gif_font.c \
gif_hash.c openbsd-reallocarray.c
HEADERS = gif_hash.h gif_lib.h gif_lib_private.h
OBJECTS = $(SOURCES:.c=.o)
USOURCES = qprintf.c quantize.c getarg.c
UHEADERS = getarg.h
UOBJECTS = $(USOURCES:.c=.o)
UNAME:=$(shell uname)
# Some utilities are installed
INSTALLABLE = \
gif2rgb \
gifbuild \
giffix \
giftext \
giftool \
gifclrmp
# Some utilities are only used internally for testing.
# There is a parallel list in doc/Makefile.
# These are all candidates for removal in future releases.
UTILS = $(INSTALLABLE) \
gifbg \
gifcolor \
gifecho \
giffilter \
gifhisto \
gifinto \
gifsponge \
gifwedge
LDLIBS=libgif.a -lm
MANUAL_PAGES = \
doc/gif2rgb.xml \
doc/gifbuild.xml \
doc/gifclrmp.xml \
doc/giffix.xml \
doc/giflib.xml \
doc/giftext.xml \
doc/giftool.xml
SOEXTENSION = so
LIBGIFSO = libgif.$(SOEXTENSION)
LIBGIFSOMAJOR = libgif.$(SOEXTENSION).$(LIBMAJOR)
LIBGIFSOVER = libgif.$(SOEXTENSION).$(LIBVER)
LIBUTILSO = libutil.$(SOEXTENSION)
LIBUTILSOMAJOR = libutil.$(SOEXTENSION).$(LIBMAJOR)
ifeq ($(UNAME), Darwin)
SOEXTENSION = dylib
LIBGIFSO = libgif.$(SOEXTENSION)
LIBGIFSOMAJOR = libgif.$(LIBMAJOR).$(SOEXTENSION)
LIBGIFSOVER = libgif.$(LIBVER).$(SOEXTENSION)
LIBUTILSO = libutil.$(SOEXTENSION)
LIBUTILSOMAJOR = libutil.$(LIBMAJOR).$(SOEXTENSION)
endif
all: $(LIBGIFSO) libgif.a $(LIBUTILSO) libutil.a $(UTILS)
ifeq ($(UNAME), Darwin)
else
$(MAKE) -C doc
endif
$(UTILS):: libgif.a libutil.a
$(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)
$(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 $(LIBGIFSO) libutil.a $(LIBUTILSO) *.o
rm -f $(LIBGIFSOVER)
rm -f $(LIBGIFSOMAJOR)
rm -fr doc/*.1 *.html doc/staging
check: all
$(MAKE) -C tests
reflow:
@clang-format --style="{IndentWidth: 8, UseTab: ForIndentation}" -i $$(find . -name "*.[ch]")
# Installation/uninstallation
ifeq ($(UNAME), Darwin)
install: all install-bin install-include install-lib
else
install: all install-bin install-include install-lib install-man
endif
install-bin: $(INSTALLABLE)
$(INSTALL) -d "$(DESTDIR)$(BINDIR)"
$(INSTALL) $^ "$(DESTDIR)$(BINDIR)"
install-include:
$(INSTALL) -d "$(DESTDIR)$(INCDIR)"
$(INSTALL) -m 644 gif_lib.h "$(DESTDIR)$(INCDIR)"
install-lib:
$(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
$(INSTALL) -m 644 libgif.a "$(DESTDIR)$(LIBDIR)/libgif.a"
$(INSTALL) -m 755 $(LIBGIFSO) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSOVER)"
ln -sf $(LIBGIFSOVER) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSOMAJOR)"
ln -sf $(LIBGIFSOMAJOR) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSO)"
install-man:
$(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1"
$(INSTALL) -m 644 $(MANUAL_PAGES) "$(DESTDIR)$(MANDIR)/man1"
uninstall: uninstall-man uninstall-include uninstall-lib uninstall-bin
uninstall-bin:
cd "$(DESTDIR)$(BINDIR)" && rm -f $(INSTALLABLE)
uninstall-include:
rm -f "$(DESTDIR)$(INCDIR)/gif_lib.h"
uninstall-lib:
cd "$(DESTDIR)$(LIBDIR)" && \
rm -f libgif.a $(LIBGIFSO) $(LIBGIFSOMAJOR) $(LIBGIFSOVER)
uninstall-man:
cd "$(DESTDIR)$(MANDIR)/man1" && rm -f $(shell cd doc >/dev/null && echo *.1)
cd "$(DESTDIR)$(MANDIR)/man7" && rm -f $(shell cd doc >/dev/null && echo *.7)
# Make distribution tarball
#
# We include all of the XML, and also generated manual pages
# so people working from the distribution tarball won't need xmlto.
EXTRAS = README \
NEWS \
TODO \
COPYING \
getversion \
ChangeLog \
build.adoc \
history.adoc \
control \
doc/whatsinagif \
doc/gifstandard \
DSOURCES = Makefile *.[ch]
DOCS = doc/*.xml doc/*.1 doc/*.7 doc/*.html doc/index.html.in doc/00README doc/Makefile
ALL = $(DSOURCES) $(DOCS) tests pic $(EXTRAS)
giflib-$(VERSION).tar.gz: $(ALL)
$(TAR) --transform='s:^:giflib-$(VERSION)/:' -czf giflib-$(VERSION).tar.gz $(ALL)
giflib-$(VERSION).tar.bz2: $(ALL)
$(TAR) --transform='s:^:giflib-$(VERSION)/:' -cjf giflib-$(VERSION).tar.bz2 $(ALL)
dist: giflib-$(VERSION).tar.gz giflib-$(VERSION).tar.bz2
# Auditing tools.
# Check that getversion hasn't gone pear-shaped.
version:
@echo $(VERSION)
# cppcheck should run clean
cppcheck:
cppcheck --quiet --inline-suppr --template gcc --enable=all --suppress=unusedFunction --suppress=missingInclude --force *.[ch]
# Verify the build
distcheck: all
$(MAKE) giflib-$(VERSION).tar.gz
tar xzvf giflib-$(VERSION).tar.gz
$(MAKE) -C giflib-$(VERSION)
rm -fr giflib-$(VERSION)
# release using the shipper tool
release: all distcheck
$(MAKE) -C doc website
shipper --no-stale version=$(VERSION) | sh -e -x
rm -fr doc/staging
# Refresh the website
refresh: all
$(MAKE) -C doc website
shipper --no-stale -w version=$(VERSION) | sh -e -x
rm -fr doc/staging