• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Top-level Unix makefile for the GIFLIB package
2# Should work for all Unix versions
3#
4# If your platform has the OpenBSD reallocarray(3) call, you may
5# add -DHAVE_REALLOCARRAY to CFLAGS to use that, saving a bit
6# of code space in the shared library.
7
8#
9OFLAGS = -O0 -g
10OFLAGS  = -O2
11CFLAGS  = -std=gnu99 -fPIC -Wall -Wno-format-truncation $(OFLAGS)
12
13SHELL = /bin/sh
14TAR = tar
15INSTALL = install
16
17PREFIX = /usr/local
18BINDIR = $(PREFIX)/bin
19INCDIR = $(PREFIX)/include
20LIBDIR = $(PREFIX)/lib
21MANDIR = $(PREFIX)/share/man
22
23# No user-serviceable parts below this line
24
25VERSION:=$(shell ./getversion)
26LIBMAJOR=7
27LIBMINOR=2
28LIBPOINT=0
29LIBVER=$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
30
31SOURCES = dgif_lib.c egif_lib.c gifalloc.c gif_err.c gif_font.c \
32	gif_hash.c openbsd-reallocarray.c
33HEADERS = gif_hash.h  gif_lib.h  gif_lib_private.h
34OBJECTS = $(SOURCES:.c=.o)
35
36USOURCES = qprintf.c quantize.c getarg.c
37UHEADERS = getarg.h
38UOBJECTS = $(USOURCES:.c=.o)
39
40# Some utilities are installed
41INSTALLABLE = \
42	gif2rgb \
43	gifbuild \
44	giffix \
45	giftext \
46	giftool \
47	gifclrmp
48
49# Some utilities are only used internally for testing.
50# There is a parallel list in doc/Makefile.
51# These are all candidates for removal in future releases.
52UTILS = $(INSTALLABLE) \
53	gifbg \
54	gifcolor \
55	gifecho \
56	giffilter \
57	gifhisto \
58	gifinto \
59	gifsponge \
60	gifwedge
61
62LDLIBS=libgif.a -lm
63
64all: libgif.so libgif.a libutil.so libutil.a $(UTILS)
65	$(MAKE) -C doc
66
67$(UTILS):: libgif.a libutil.a
68
69libgif.so: $(OBJECTS) $(HEADERS)
70	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
71
72libgif.a: $(OBJECTS) $(HEADERS)
73	$(AR) rcs libgif.a $(OBJECTS)
74
75libutil.so: $(UOBJECTS) $(UHEADERS)
76	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
77
78libutil.a: $(UOBJECTS) $(UHEADERS)
79	$(AR) rcs libutil.a $(UOBJECTS)
80
81clean:
82	rm -f $(UTILS) $(TARGET) libgetarg.a libgif.a libgif.so libutil.a libutil.so *.o
83	rm -f libgif.so.$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
84	rm -f libgif.so.$(LIBMAJOR)
85	rm -fr doc/*.1 *.html doc/staging
86
87check: all
88	$(MAKE) -C tests
89
90# Installation/uninstallation
91
92install: all install-bin install-include install-lib install-man
93install-bin: $(INSTALLABLE)
94	$(INSTALL) -d "$(DESTDIR)$(BINDIR)"
95	$(INSTALL) $^ "$(DESTDIR)$(BINDIR)"
96install-include:
97	$(INSTALL) -d "$(DESTDIR)$(INCDIR)"
98	$(INSTALL) -m 644 gif_lib.h "$(DESTDIR)$(INCDIR)"
99install-lib:
100	$(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
101	$(INSTALL) -m 644 libgif.a "$(DESTDIR)$(LIBDIR)/libgif.a"
102	$(INSTALL) -m 755 libgif.so "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBVER)"
103	ln -sf libgif.so.$(LIBVER) "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBMAJOR)"
104	ln -sf libgif.so.$(LIBMAJOR) "$(DESTDIR)$(LIBDIR)/libgif.so"
105install-man:
106	$(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1"
107	$(INSTALL) -m 644 doc/*.1 "$(DESTDIR)$(MANDIR)/man1"
108uninstall: uninstall-man uninstall-include uninstall-lib uninstall-bin
109uninstall-bin:
110	cd "$(DESTDIR)$(BINDIR)" && rm -f $(INSTALLABLE)
111uninstall-include:
112	rm -f "$(DESTDIR)$(INCDIR)/gif_lib.h"
113uninstall-lib:
114	cd "$(DESTDIR)$(LIBDIR)" && \
115		rm -f libgif.a libgif.so libgif.so.$(LIBMAJOR) libgif.so.$(LIBVER)
116uninstall-man:
117	cd "$(DESTDIR)$(MANDIR)/man1" && rm -f $(shell cd doc >/dev/null && echo *.1)
118
119# Make distribution tarball
120#
121# We include all of the XML, and also generated manual pages
122# so people working from the distribution tarball won't need xmlto.
123
124EXTRAS =     README \
125	     NEWS \
126	     TODO \
127	     COPYING \
128	     getversion \
129	     ChangeLog \
130	     build.adoc \
131	     history.adoc \
132	     control \
133	     doc/whatsinagif \
134	     doc/gifstandard \
135
136DSOURCES = Makefile *.[ch]
137DOCS = doc/*.xml doc/*.1 doc/*.html doc/index.html.in doc/00README doc/Makefile
138ALL =  $(DSOURCES) $(DOCS) tests pic $(EXTRAS)
139giflib-$(VERSION).tar.gz: $(ALL)
140	$(TAR) --transform='s:^:giflib-$(VERSION)/:' -czf giflib-$(VERSION).tar.gz $(ALL)
141giflib-$(VERSION).tar.bz2: $(ALL)
142	$(TAR) --transform='s:^:giflib-$(VERSION)/:' -cjf giflib-$(VERSION).tar.bz2 $(ALL)
143
144dist: giflib-$(VERSION).tar.gz giflib-$(VERSION).tar.bz2
145
146# Auditing tools.
147
148# Check that getversion hasn't gone pear-shaped.
149version:
150	@echo $(VERSION)
151
152# cppcheck should run clean
153cppcheck:
154	cppcheck --inline-suppr --template gcc --enable=all --suppress=unusedFunction --force *.[ch]
155
156# Verify the build
157distcheck: all
158	$(MAKE) giflib-$(VERSION).tar.gz
159	tar xzvf giflib-$(VERSION).tar.gz
160	$(MAKE) -C giflib-$(VERSION)
161	rm -fr giflib-$(VERSION)
162
163# release using the shipper tool
164release: all distcheck
165	$(MAKE) -C doc website
166	shipper --no-stale version=$(VERSION) | sh -e -x
167	rm -fr doc/staging
168
169# Refresh the website
170refresh: all
171	$(MAKE) -C doc website
172	shipper --no-stale -w version=$(VERSION) | sh -e -x
173	rm -fr doc/staging
174