Add a comment to get_variable_from_expr_simple()
[smatch.git] / Makefile
blob46cb6626949ef35c8011663eee20205e44ced926
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
17 #CFLAGS += -DNDEBUG
18 #CFLAGS += -DDEBUGSTATES
20 DESTDIR=
21 PREFIX=$(HOME)
22 BINDIR=$(PREFIX)/bin
23 LIBDIR=$(PREFIX)/lib
24 MANDIR=$(PREFIX)/share/man
25 MAN1DIR=$(MANDIR)/man1
26 INCLUDEDIR=$(PREFIX)/include
27 PKGCONFIGDIR=$(LIBDIR)/pkgconfig
29 PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example \
30 test-unssa test-dissect ctags smatch
31 SMATCH_FILES=smatch_flow.o smatch_states.o smatch_helper.o smatch_hooks.o smatch_extra.o
32 SMATCH_CHECKS=check_derefed_params.o check_null_deref.o check_overflow.o
35 INST_PROGRAMS=sparse cgcc
36 INST_MAN1=sparse.1 cgcc.1
38 ifeq ($(HAVE_LIBXML),yes)
39 PROGRAMS+=c2xml
40 INST_PROGRAMS+=c2xml
41 endif
43 LIB_H= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
44 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
45 storage.h ptrlist.h dissect.h
47 LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
48 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
49 sort.o allocate.o compat-$(OS).o ptrlist.o \
50 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
52 LIB_FILE= libsparse.a
53 SLIB_FILE= libsparse.so
55 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
56 # Doing so incurs a noticeable performance hit, and Sparse does not have a
57 # stable shared library interface, so this does not occur by default. If you
58 # really want a shared library, you may want to build Sparse twice: once
59 # without -fpic to get all the Sparse tools, and again with -fpic to get the
60 # shared library.
61 LIBS=$(LIB_FILE)
64 # Pretty print
66 V = @
67 Q = $(V:1=)
68 QUIET_CC = $(Q:@=@echo ' CC '$@;)
69 QUIET_AR = $(Q:@=@echo ' AR '$@;)
70 QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
71 QUIET_LINK = $(Q:@=@echo ' LINK '$@;)
72 # We rely on the -v switch of install to print 'file -> $install_dir/file'
73 QUIET_INST_SH = $(Q:@=echo -n ' INSTALL ';)
74 QUIET_INST = $(Q:@=@echo -n ' INSTALL ';)
76 all: $(PROGRAMS) sparse.pc
78 install: $(INST_PROGRAMS) $(LIBS) $(LIB_H) sparse.pc
79 $(Q)install -d $(DESTDIR)$(BINDIR)
80 $(Q)install -d $(DESTDIR)$(LIBDIR)
81 $(Q)install -d $(DESTDIR)$(MAN1DIR)
82 $(Q)install -d $(DESTDIR)$(INCLUDEDIR)/sparse
83 $(Q)install -d $(DESTDIR)$(PKGCONFIGDIR)
84 $(Q)for f in $(INST_PROGRAMS); do \
85 $(QUIET_INST_SH)install -v $$f $(DESTDIR)$(BINDIR)/$$f || exit 1; \
86 done
87 $(Q)for f in $(INST_MAN1); do \
88 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(MAN1DIR)/$$f || exit 1; \
89 done
90 $(Q)for f in $(LIBS); do \
91 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(LIBDIR)/$$f || exit 1; \
92 done
93 $(Q)for f in $(LIB_H); do \
94 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(INCLUDEDIR)/sparse/$$f || exit 1; \
95 done
96 $(QUIET_INST)install -m 644 -v sparse.pc $(DESTDIR)$(PKGCONFIGDIR)/sparse.pc
98 sparse.pc: sparse.pc.in
99 $(QUIET_GEN)sed 's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.pc.in > sparse.pc
101 test-lexing: test-lexing.o $(LIBS)
102 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
104 test-parsing: test-parsing.o $(LIBS)
105 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
107 test-linearize: test-linearize.o $(LIBS)
108 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
110 test-sort: test-sort.o $(LIBS)
111 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
113 compile: compile.o compile-i386.o $(LIBS)
114 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< compile-i386.o $(LIBS)
116 obfuscate: obfuscate.o $(LIBS)
117 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
119 sparse: sparse.o $(LIBS)
120 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
122 graph: graph.o $(LIBS)
123 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
125 example: example.o $(LIBS)
126 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
128 test-unssa: test-unssa.o $(LIBS)
129 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
131 test-dissect: test-dissect.o $(LIBS)
132 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
134 ctags: ctags.o $(LIBS)
135 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
137 c2xml: c2xml.o $(LIBS)
138 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS) `pkg-config --libs libxml-2.0`
140 smatch: smatch.o $(SMATCH_FILES) $(SMATCH_CHECKS) $(LIBS)
141 $(CC) $(LDFLAGS) -o $@ $< $(SMATCH_FILES) $(SMATCH_CHECKS) $(LIBS)
143 $(LIB_FILE): $(LIB_OBJS)
144 $(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
146 $(SLIB_FILE): $(LIB_OBJS)
147 $(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(LIB_OBJS)
149 evaluate.o: $(LIB_H)
150 expression.o: $(LIB_H)
151 lib.o: $(LIB_H)
152 allocate.o: $(LIB_H)
153 ptrlist.o: $(LIB_H)
154 parse.o: $(LIB_H)
155 pre-process.o: $(LIB_H) pre-process.h
156 scope.o: $(LIB_H)
157 show-parse.o: $(LIB_H)
158 symbol.o: $(LIB_H)
159 expand.o: $(LIB_H)
160 linearize.o: $(LIB_H)
161 flow.o: $(LIB_H)
162 cse.o: $(LIB_H)
163 simplify.o: $(LIB_H)
164 memops.o: $(LIB_H)
165 liveness.o: $(LIB_H)
166 sort.o: $(LIB_H)
167 inline.o: $(LIB_H)
168 target.o: $(LIB_H)
169 test-lexing.o: $(LIB_H)
170 test-parsing.o: $(LIB_H)
171 test-linearize.o: $(LIB_H)
172 test-dissect.o: $(LIB_H)
173 smatch_flow.o: $(LIB_H) smatch.h
174 smatch_hooks.o: $(LIB_H) smatch.h
175 smatch_helper.o: $(LIB_H) smatch.h
176 smatch_states.o: $(LIB_H) smatch.h
177 smatch.o: $(LIB_H) smatch.h
178 test-unssa.o: $(LIB_H)
179 ctags.o: $(LIB_H)
180 compile.o: $(LIB_H) compile.h
181 compile-i386.o: $(LIB_H) compile.h
182 tokenize.o: $(LIB_H)
183 sparse.o: $(LIB_H)
184 obfuscate.o: $(LIB_H)
185 example.o: $(LIB_H)
186 storage.o: $(LIB_H)
187 dissect.o: $(LIB_H)
188 graph.o: $(LIB_H)
190 c2xml.o: c2xml.c $(LIB_H)
191 $(QUIET_CC)$(CC) `pkg-config --cflags libxml-2.0` -o $@ -c $(CFLAGS) $<
193 compat-linux.o: compat/strtold.c compat/mmap-blob.c \
194 $(LIB_H)
195 compat-solaris.o: compat/mmap-blob.c $(LIB_H)
196 compat-mingw.o: $(LIB_H)
197 compat-cygwin.o: $(LIB_H)
199 pre-process.h:
200 $(QUIET_GEN)echo "#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
202 .c.o:
203 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
205 clean: clean-check
206 rm -f *.[oa] $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc
208 dist:
209 @if test "`git describe`" != "$(VERSION)" ; then \
210 echo 'Update VERSION in the Makefile before running "make dist".' ; \
211 exit 1 ; \
213 git archive --format=tar --prefix=sparse-$(VERSION)/ HEAD^{tree} | gzip -9 > sparse-$(VERSION).tar.gz
215 check: all
216 $(Q)cd validation && ./test-suite
218 clean-check:
219 find validation/ \( -name "*.c.output.expected" \
220 -o -name "*.c.output.got" \
221 -o -name "*.c.output.diff" \
222 -o -name "*.c.error.expected" \
223 -o -name "*.c.error.got" \
224 -o -name "*.c.error.diff" \
225 \) -exec rm {} \;