Fix build error due to giflib build changes
[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=1
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         gifecho \
45         giffilter \
46         giffix \
47         gifinto \
48         giftext \
49         giftool \
50         gifsponge \
51         gifclrmp
52
53 # Some utilities are only used internally for testing.
54 # There is a parallel list in doc/Makefile.
55 # These are all candidates for removal in future releases.
56 UTILS = $(INSTALLABLE) \
57         gifbg \
58         gifcolor \
59         gifhisto \
60         gifsponge \
61         gifwedge
62
63 LDLIBS=libgif.a -lm
64
65 all: libgif.so libgif.a libutil.so libutil.a $(UTILS)
66         $(MAKE) -C doc
67
68 $(UTILS):: libgif.a libutil.a
69
70 libgif.so: $(OBJECTS) $(HEADERS)
71         $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
72
73 libgif.a: $(OBJECTS) $(HEADERS)
74         $(AR) rcs libgif.a $(OBJECTS)
75
76 libutil.so: $(UOBJECTS) $(UHEADERS)
77         $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
78
79 libutil.a: $(UOBJECTS) $(UHEADERS)
80         $(AR) rcs libutil.a $(UOBJECTS)
81
82 clean:
83         rm -f $(UTILS) $(TARGET) libgetarg.a libgif.a libgif.so libutil.a libutil.so *.o
84         rm -f libgif.so.$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
85         rm -f libgif.so.$(LIBMAJOR)
86         rm -fr doc/*.1 *.html doc/staging
87
88 check: all
89         $(MAKE) -C tests
90
91 # Installation/uninstallation
92
93 install: all install-bin install-include install-lib install-man
94 install-bin: $(INSTALLABLE)
95         $(INSTALL) -d "$(DESTDIR)$(BINDIR)"
96         $(INSTALL) $^ "$(DESTDIR)$(BINDIR)"
97 install-include:
98         $(INSTALL) -d "$(DESTDIR)$(INCDIR)"
99         $(INSTALL) -m 644 gif_lib.h "$(DESTDIR)$(INCDIR)"
100 install-lib:
101         $(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
102 #       $(INSTALL) -m 644 libgif.a "$(DESTDIR)$(LIBDIR)/libgif.a"
103         $(INSTALL) -m 755 libgif.so "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBVER)"
104         ln -sf libgif.so.$(LIBVER) "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBMAJOR)"
105         ln -sf libgif.so.$(LIBMAJOR) "$(DESTDIR)$(LIBDIR)/libgif.so"
106 install-man:
107         $(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1"
108         $(INSTALL) -m 644 doc/*.1 "$(DESTDIR)$(MANDIR)/man1"
109 uninstall: uninstall-man uninstall-include uninstall-lib uninstall-bin
110 uninstall-bin:
111         cd "$(DESTDIR)$(BINDIR)" && rm -f $(INSTALLABLE)
112 uninstall-include:
113         rm -f "$(DESTDIR)$(INCDIR)/gif_lib.h"
114 uninstall-lib:
115         cd "$(DESTDIR)$(LIBDIR)" && \
116                 rm -f libgif.a libgif.so libgif.so.$(LIBMAJOR) libgif.so.$(LIBVER)
117 uninstall-man:
118         cd "$(DESTDIR)$(MANDIR)/man1" && rm -f $(shell cd doc >/dev/null && echo *.1)
119
120 # Make distribution tarball
121 #
122 # We include all of the XML, and also generated manual pages
123 # so people working from the distribution tarball won't need xmlto.
124
125 EXTRAS =     README \
126              NEWS \
127              TODO \
128              COPYING \
129              getversion \
130              ChangeLog \
131              build.adoc \
132              history.adoc \
133              control \
134              doc/whatsinagif \
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