Add armoring option
[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 ifeq ($(__TIZEN__),true)
13 CFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong
14 LDFLAGS = -Wl,-z,relro
15 endif
16
17 SHELL = /bin/sh
18 TAR = tar
19 INSTALL = install
20
21 PREFIX = /usr/local
22 BINDIR = $(PREFIX)/bin
23 INCDIR = $(PREFIX)/include
24 #LIBDIR = $(PREFIX)/lib
25 MANDIR = $(PREFIX)/share/man
26
27 # No user-serviceable parts below this line
28
29 VERSION:=$(shell ./getversion)
30 LIBMAJOR=7
31 LIBMINOR=2
32 LIBPOINT=0
33 LIBVER=$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
34
35 SOURCES = dgif_lib.c egif_lib.c gifalloc.c gif_err.c gif_font.c \
36         gif_hash.c openbsd-reallocarray.c
37 HEADERS = gif_hash.h  gif_lib.h  gif_lib_private.h
38 OBJECTS = $(SOURCES:.c=.o)
39
40 USOURCES = qprintf.c quantize.c getarg.c 
41 UHEADERS = getarg.h
42 UOBJECTS = $(USOURCES:.c=.o)
43
44 # Some utilities are installed
45 INSTALLABLE = \
46         gif2rgb \
47         gifbuild \
48         giffix \
49         giftext \
50         giftool \
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         gifecho \
60         giffilter \
61         gifhisto \
62         gifinto \
63         gifsponge \
64         gifwedge
65
66 LDLIBS=libgif.a -lm
67
68 all: libgif.so libgif.a libutil.so libutil.a $(UTILS)
69         $(MAKE) -C doc
70
71 $(UTILS):: libgif.a libutil.a
72
73 libgif.so: $(OBJECTS) $(HEADERS)
74         $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
75
76 libgif.a: $(OBJECTS) $(HEADERS)
77         $(AR) rcs libgif.a $(OBJECTS)
78
79 libutil.so: $(UOBJECTS) $(UHEADERS)
80         $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
81
82 libutil.a: $(UOBJECTS) $(UHEADERS)
83         $(AR) rcs libutil.a $(UOBJECTS)
84
85 clean:
86         rm -f $(UTILS) $(TARGET) libgetarg.a libgif.a libgif.so libutil.a libutil.so *.o
87         rm -f libgif.so.$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
88         rm -f libgif.so.$(LIBMAJOR)
89         rm -fr doc/*.1 *.html doc/staging
90
91 check: all
92         $(MAKE) -C tests
93
94 # Installation/uninstallation
95
96 install: all install-bin install-include install-lib install-man
97 install-bin: $(INSTALLABLE)
98         $(INSTALL) -d "$(DESTDIR)$(BINDIR)"
99         $(INSTALL) $^ "$(DESTDIR)$(BINDIR)"
100 install-include:
101         $(INSTALL) -d "$(DESTDIR)$(INCDIR)"
102         $(INSTALL) -m 644 gif_lib.h "$(DESTDIR)$(INCDIR)"
103 install-lib:
104         $(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
105 #       $(INSTALL) -m 644 libgif.a "$(DESTDIR)$(LIBDIR)/libgif.a"
106         $(INSTALL) -m 755 libgif.so "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBVER)"
107         ln -sf libgif.so.$(LIBVER) "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBMAJOR)"
108         ln -sf libgif.so.$(LIBMAJOR) "$(DESTDIR)$(LIBDIR)/libgif.so"
109 install-man:
110         $(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1"
111         $(INSTALL) -m 644 doc/*.1 "$(DESTDIR)$(MANDIR)/man1"
112 uninstall: uninstall-man uninstall-include uninstall-lib uninstall-bin
113 uninstall-bin:
114         cd "$(DESTDIR)$(BINDIR)" && rm -f $(INSTALLABLE)
115 uninstall-include:
116         rm -f "$(DESTDIR)$(INCDIR)/gif_lib.h"
117 uninstall-lib:
118         cd "$(DESTDIR)$(LIBDIR)" && \
119                 rm -f libgif.a libgif.so libgif.so.$(LIBMAJOR) libgif.so.$(LIBVER)
120 uninstall-man:
121         cd "$(DESTDIR)$(MANDIR)/man1" && rm -f $(shell cd doc >/dev/null && echo *.1)
122
123 # Make distribution tarball
124 #
125 # We include all of the XML, and also generated manual pages
126 # so people working from the distribution tarball won't need xmlto.
127
128 EXTRAS =     README \
129              NEWS \
130              TODO \
131              COPYING \
132              getversion \
133              ChangeLog \
134              build.adoc \
135              history.adoc \
136              control \
137              doc/whatsinagif \
138              doc/gifstandard \
139
140 DSOURCES = Makefile *.[ch]
141 DOCS = doc/*.xml doc/*.1 doc/*.html doc/index.html.in doc/00README doc/Makefile
142 ALL =  $(DSOURCES) $(DOCS) tests pic $(EXTRAS)
143 giflib-$(VERSION).tar.gz: $(ALL)
144         $(TAR) --transform='s:^:giflib-$(VERSION)/:' -czf giflib-$(VERSION).tar.gz $(ALL)
145 giflib-$(VERSION).tar.bz2: $(ALL)
146         $(TAR) --transform='s:^:giflib-$(VERSION)/:' -cjf giflib-$(VERSION).tar.bz2 $(ALL)
147
148 dist: giflib-$(VERSION).tar.gz giflib-$(VERSION).tar.bz2
149
150 # Auditing tools.
151
152 # Check that getversion hasn't gone pear-shaped.
153 version:
154         @echo $(VERSION)
155
156 # cppcheck should run clean
157 cppcheck:
158         cppcheck --inline-suppr --template gcc --enable=all --suppress=unusedFunction --force *.[ch]
159
160 # Verify the build
161 distcheck: all
162         $(MAKE) giflib-$(VERSION).tar.gz
163         tar xzvf giflib-$(VERSION).tar.gz
164         $(MAKE) -C giflib-$(VERSION)
165         rm -fr giflib-$(VERSION)
166
167 # release using the shipper tool
168 release: all distcheck
169         $(MAKE) -C doc website
170         shipper --no-stale version=$(VERSION) | sh -e -x
171         rm -fr doc/staging
172
173 # Refresh the website
174 refresh: all
175         $(MAKE) -C doc website
176         shipper --no-stale -w version=$(VERSION) | sh -e -x
177         rm -fr doc/staging