assumed_nonnull crap... temp fix.
[smatch.git] / Makefile
blobf71afc1f06f6621f27dd6517224b0ca110c7c6d3
1 VERSION=0.4.1
3 OS ?= linux
5 CC ?= gcc
6 CFLAGS ?= -O2 -finline-functions -fno-strict-aliasing -g
7 CFLAGS += -Wall -Wwrite-strings
8 LDFLAGS ?= -g
9 AR ?= ar
11 HAVE_LIBXML=$(shell pkg-config --exists libxml-2.0 && echo 'yes')
14 # For debugging, uncomment the next one
16 CFLAGS += -DDEBUG
18 DESTDIR=
19 PREFIX=$(HOME)
20 BINDIR=$(PREFIX)/bin
21 LIBDIR=$(PREFIX)/lib
22 MANDIR=$(PREFIX)/share/man
23 MAN1DIR=$(MANDIR)/man1
24 INCLUDEDIR=$(PREFIX)/include
25 PKGCONFIGDIR=$(LIBDIR)/pkgconfig
27 PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example \
28 test-unssa test-dissect ctags smatch
29 SMATCH_FILES=smatch_flow.o smatch_conditions.o smatch_slist.o smatch_states.o smatch_helper.o smatch_hooks.o smatch_function_hooks.o smatch_extra.o smatch_implied.o smatch_ignore.o smatch_tracker.o
30 SMATCH_CHECKS=$(shell ls check_*.c | sed -e 's/\.c/.o/')
33 INST_PROGRAMS=sparse cgcc
34 INST_MAN1=sparse.1 cgcc.1
36 ifeq ($(HAVE_LIBXML),yes)
37 PROGRAMS+=c2xml
38 INST_PROGRAMS+=c2xml
39 endif
41 LIB_H= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
42 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
43 storage.h ptrlist.h dissect.h
45 LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
46 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
47 sort.o allocate.o compat-$(OS).o ptrlist.o \
48 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
50 LIB_FILE= libsparse.a
51 SLIB_FILE= libsparse.so
53 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
54 # Doing so incurs a noticeable performance hit, and Sparse does not have a
55 # stable shared library interface, so this does not occur by default. If you
56 # really want a shared library, you may want to build Sparse twice: once
57 # without -fpic to get all the Sparse tools, and again with -fpic to get the
58 # shared library.
59 LIBS=$(LIB_FILE)
62 # Pretty print
64 V = @
65 Q = $(V:1=)
66 QUIET_CC = $(Q:@=@echo ' CC '$@;)
67 QUIET_AR = $(Q:@=@echo ' AR '$@;)
68 QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
69 QUIET_LINK = $(Q:@=@echo ' LINK '$@;)
70 # We rely on the -v switch of install to print 'file -> $install_dir/file'
71 QUIET_INST_SH = $(Q:@=echo -n ' INSTALL ';)
72 QUIET_INST = $(Q:@=@echo -n ' INSTALL ';)
74 all: $(PROGRAMS) sparse.pc
76 install: $(INST_PROGRAMS) $(LIBS) $(LIB_H) sparse.pc
77 $(Q)install -d $(DESTDIR)$(BINDIR)
78 $(Q)install -d $(DESTDIR)$(LIBDIR)
79 $(Q)install -d $(DESTDIR)$(MAN1DIR)
80 $(Q)install -d $(DESTDIR)$(INCLUDEDIR)/sparse
81 $(Q)install -d $(DESTDIR)$(PKGCONFIGDIR)
82 $(Q)for f in $(INST_PROGRAMS); do \
83 $(QUIET_INST_SH)install -v $$f $(DESTDIR)$(BINDIR)/$$f || exit 1; \
84 done
85 $(Q)for f in $(INST_MAN1); do \
86 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(MAN1DIR)/$$f || exit 1; \
87 done
88 $(Q)for f in $(LIBS); do \
89 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(LIBDIR)/$$f || exit 1; \
90 done
91 $(Q)for f in $(LIB_H); do \
92 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(INCLUDEDIR)/sparse/$$f || exit 1; \
93 done
94 $(QUIET_INST)install -m 644 -v sparse.pc $(DESTDIR)$(PKGCONFIGDIR)/sparse.pc
96 sparse.pc: sparse.pc.in
97 $(QUIET_GEN)sed 's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.pc.in > sparse.pc
99 test-lexing: test-lexing.o $(LIBS)
100 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
102 test-parsing: test-parsing.o $(LIBS)
103 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
105 test-linearize: test-linearize.o $(LIBS)
106 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
108 test-sort: test-sort.o $(LIBS)
109 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
111 compile: compile.o compile-i386.o $(LIBS)
112 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< compile-i386.o $(LIBS)
114 obfuscate: obfuscate.o $(LIBS)
115 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
117 sparse: sparse.o $(LIBS)
118 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
120 graph: graph.o $(LIBS)
121 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
123 example: example.o $(LIBS)
124 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
126 test-unssa: test-unssa.o $(LIBS)
127 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
129 test-dissect: test-dissect.o $(LIBS)
130 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
132 ctags: ctags.o $(LIBS)
133 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
135 c2xml: c2xml.o $(LIBS)
136 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS) `pkg-config --libs libxml-2.0`
138 smatch: smatch.o $(SMATCH_FILES) $(SMATCH_CHECKS) $(LIBS)
139 $(CC) $(LDFLAGS) -o $@ $< $(SMATCH_FILES) $(SMATCH_CHECKS) $(LIBS)
141 $(LIB_FILE): $(LIB_OBJS)
142 $(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
144 $(SLIB_FILE): $(LIB_OBJS)
145 $(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(LIB_OBJS)
147 evaluate.o: $(LIB_H)
148 expression.o: $(LIB_H)
149 lib.o: $(LIB_H)
150 allocate.o: $(LIB_H)
151 ptrlist.o: $(LIB_H)
152 parse.o: $(LIB_H)
153 pre-process.o: $(LIB_H) pre-process.h
154 scope.o: $(LIB_H)
155 show-parse.o: $(LIB_H)
156 symbol.o: $(LIB_H)
157 expand.o: $(LIB_H)
158 linearize.o: $(LIB_H)
159 flow.o: $(LIB_H)
160 cse.o: $(LIB_H)
161 simplify.o: $(LIB_H)
162 memops.o: $(LIB_H)
163 liveness.o: $(LIB_H)
164 sort.o: $(LIB_H)
165 inline.o: $(LIB_H)
166 target.o: $(LIB_H)
167 test-lexing.o: $(LIB_H)
168 test-parsing.o: $(LIB_H)
169 test-linearize.o: $(LIB_H)
170 test-dissect.o: $(LIB_H)
171 smatch_flow.o: $(LIB_H) smatch.h
172 smatch_conditions.o: $(LIB_H) smatch.h
173 smatch_extra.o: $(LIB_H) smatch.h
174 smatch_implied.o: $(LIB_H) smatch.h smatch_slist.h
175 smatch_ignore.o: $(LIB_H) smatch.h
176 smatch_tracker.o: $(LIB_H) smatch.h
177 smatch_hooks.o: $(LIB_H) smatch.h
178 smatch_function_hooks.o: $(LIB_H) smatch.h
179 smatch_helper.o: $(LIB_H) smatch.h
180 smatch_slist.o: $(LIB_H) smatch.h smatch_slist.h
181 smatch_states.o: $(LIB_H) smatch.h smatch_slist.h
182 smatch.o: $(LIB_H) smatch.h
183 test-unssa.o: $(LIB_H)
184 ctags.o: $(LIB_H)
185 compile.o: $(LIB_H) compile.h
186 compile-i386.o: $(LIB_H) compile.h
187 tokenize.o: $(LIB_H)
188 sparse.o: $(LIB_H)
189 obfuscate.o: $(LIB_H)
190 example.o: $(LIB_H)
191 storage.o: $(LIB_H)
192 dissect.o: $(LIB_H)
193 graph.o: $(LIB_H)
195 c2xml.o: c2xml.c $(LIB_H)
196 $(QUIET_CC)$(CC) `pkg-config --cflags libxml-2.0` -o $@ -c $(CFLAGS) $<
198 compat-linux.o: compat/strtold.c compat/mmap-blob.c \
199 $(LIB_H)
200 compat-solaris.o: compat/mmap-blob.c $(LIB_H)
201 compat-mingw.o: $(LIB_H)
202 compat-cygwin.o: $(LIB_H)
204 pre-process.h:
205 $(QUIET_GEN)echo "#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
207 .c.o:
208 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
210 clean: clean-check
211 rm -f *.[oa] $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc
213 dist:
214 @if test "`git describe`" != "$(VERSION)" ; then \
215 echo 'Update VERSION in the Makefile before running "make dist".' ; \
216 exit 1 ; \
218 git archive --format=tar --prefix=sparse-$(VERSION)/ HEAD^{tree} | gzip -9 > sparse-$(VERSION).tar.gz
220 check: all
221 $(Q)cd validation && ./test-suite
223 clean-check:
224 find validation/ \( -name "*.c.output.expected" \
225 -o -name "*.c.output.got" \
226 -o -name "*.c.output.diff" \
227 -o -name "*.c.error.expected" \
228 -o -name "*.c.error.got" \
229 -o -name "*.c.error.diff" \
230 \) -exec rm {} \;