0cfa407c263c89fbac2256ae662c9836f51a564a
[platform/upstream/giflib.git] / Makefile
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 #
9 OFLAGS = -O0 -g
10 OFLAGS  = -O2
11 CFLAGS  = -std=gnu99 -fPIC -Wall -Wno-format-truncation $(OFLAGS)
12
13 SHELL = /bin/sh
14 TAR = tar
15 INSTALL = install
16
17 PREFIX = /usr/local
18 BINDIR = $(PREFIX)/bin
19 INCDIR = $(PREFIX)/include
20 #LIBDIR = $(PREFIX)/lib
21 MANDIR = $(PREFIX)/share/man
22
23 # No user-serviceable parts below this line
24
25 VERSION:=$(shell ./getversion)
26 LIBMAJOR=7
27 LIBMINOR=2
28 LIBPOINT=0
29 LIBVER=$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
30
31 SOURCES = dgif_lib.c egif_lib.c gifalloc.c gif_err.c gif_font.c \
32         gif_hash.c openbsd-reallocarray.c
33 HEADERS = gif_hash.h  gif_lib.h  gif_lib_private.h
34 OBJECTS = $(SOURCES:.c=.o)
35
36 USOURCES = qprintf.c quantize.c getarg.c 
37 UHEADERS = getarg.h
38 UOBJECTS = $(USOURCES:.c=.o)
39
40 # Some utilities are installed
41 INSTALLABLE = \
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.
52 UTILS = $(INSTALLABLE) \
53         gifbg \
54         gifcolor \
55         gifecho \
56         giffilter \
57         gifhisto \
58         gifinto \
59         gifsponge \
60         gifwedge
61
62 LDLIBS=libgif.a -lm
63
64 all: libgif.so libgif.a libutil.so libutil.a $(UTILS)
65         $(MAKE) -C doc
66
67 $(UTILS):: libgif.a libutil.a
68
69 libgif.so: $(OBJECTS) $(HEADERS)
70         $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
71
72 libgif.a: $(OBJECTS) $(HEADERS)
73         $(AR) rcs libgif.a $(OBJECTS)
74
75 libutil.so: $(UOBJECTS) $(UHEADERS)
76         $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
77
78 libutil.a: $(UOBJECTS) $(UHEADERS)
79         $(AR) rcs libutil.a $(UOBJECTS)
80
81 clean:
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
87 check: all
88         $(MAKE) -C tests
89
90 # Installation/uninstallation
91
92 install: all install-bin install-include install-lib install-man
93 install-bin: $(INSTALLABLE)
94         $(INSTALL) -d "$(DESTDIR)$(BINDIR)"
95         $(INSTALL) $^ "$(DESTDIR)$(BINDIR)"
96 install-include:
97         $(INSTALL) -d "$(DESTDIR)$(INCDIR)"
98         $(INSTALL) -m 644 gif_lib.h "$(DESTDIR)$(INCDIR)"
99 install-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"
105 install-man:
106         $(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1"
107         $(INSTALL) -m 644 doc/*.1 "$(DESTDIR)$(MANDIR)/man1"
108 uninstall: uninstall-man uninstall-include uninstall-lib uninstall-bin
109 uninstall-bin:
110         cd "$(DESTDIR)$(BINDIR)" && rm -f $(INSTALLABLE)
111 uninstall-include:
112         rm -f "$(DESTDIR)$(INCDIR)/gif_lib.h"
113 uninstall-lib:
114         cd "$(DESTDIR)$(LIBDIR)" && \
115                 rm -f libgif.a libgif.so libgif.so.$(LIBMAJOR) libgif.so.$(LIBVER)
116 uninstall-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
124 EXTRAS =     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
136 DSOURCES = Makefile *.[ch]
137 DOCS = doc/*.xml doc/*.1 doc/*.html doc/index.html.in doc/00README doc/Makefile
138 ALL =  $(DSOURCES) $(DOCS) tests pic $(EXTRAS)
139 giflib-$(VERSION).tar.gz: $(ALL)
140         $(TAR) --transform='s:^:giflib-$(VERSION)/:' -czf giflib-$(VERSION).tar.gz $(ALL)
141 giflib-$(VERSION).tar.bz2: $(ALL)
142         $(TAR) --transform='s:^:giflib-$(VERSION)/:' -cjf giflib-$(VERSION).tar.bz2 $(ALL)
143
144 dist: giflib-$(VERSION).tar.gz giflib-$(VERSION).tar.bz2
145
146 # Auditing tools.
147
148 # Check that getversion hasn't gone pear-shaped.
149 version:
150         @echo $(VERSION)
151
152 # cppcheck should run clean
153 cppcheck:
154         cppcheck --inline-suppr --template gcc --enable=all --suppress=unusedFunction --force *.[ch]
155
156 # Verify the build
157 distcheck: 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
164 release: 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
170 refresh: all
171         $(MAKE) -C doc website
172         shipper --no-stale -w version=$(VERSION) | sh -e -x
173         rm -fr doc/staging