6 CFLAGS ?
= -finline-functions
-fno-strict-aliasing
-g
7 CFLAGS
+= -Wall
-Wwrite-strings
11 HAVE_LIBXML
=$(shell pkg-config
--exists libxml-2.0
&& echo
'yes')
14 # For debugging, uncomment the next one
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 \
30 smatch_helper.o smatch_hooks.o smatch_function_hooks.o \
31 smatch_modification_hooks.o smatch_extra.o \
32 smatch_ranges.o smatch_implied.o smatch_ignore.o \
33 smatch_tracker.o smatch_files.o smatch_expression_stacks.o smatch_oom.o \
35 SMATCH_CHECKS
=$(shell ls check_
*.c | sed
-e
's/\.c/.o/')
38 INST_PROGRAMS
=sparse cgcc smatch
39 INST_MAN1
=sparse
.1 cgcc
.1
41 ifeq ($(HAVE_LIBXML
),yes
)
46 LIB_H
= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
47 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
48 storage.h ptrlist.h dissect.h
50 LIB_OBJS
= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
51 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
52 sort.o allocate.o compat-
$(OS
).o ptrlist.o \
53 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
56 SLIB_FILE
= libsparse.so
58 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
59 # Doing so incurs a noticeable performance hit, and Sparse does not have a
60 # stable shared library interface, so this does not occur by default. If you
61 # really want a shared library, you may want to build Sparse twice: once
62 # without -fpic to get all the Sparse tools, and again with -fpic to get the
71 QUIET_CC
= $(Q
:@
=@echo
' CC '$@
;)
72 QUIET_AR
= $(Q
:@
=@echo
' AR '$@
;)
73 QUIET_GEN
= $(Q
:@
=@echo
' GEN '$@
;)
74 QUIET_LINK
= $(Q
:@
=@echo
' LINK '$@
;)
75 # We rely on the -v switch of install to print 'file -> $install_dir/file'
76 QUIET_INST_SH
= $(Q
:@
=echo
-n
' INSTALL ';)
77 QUIET_INST
= $(Q
:@
=@echo
-n
' INSTALL ';)
79 all: $(PROGRAMS
) sparse.
pc
81 install: $(INST_PROGRAMS
) $(LIBS
) $(LIB_H
) sparse.
pc
82 $(Q
)install -d
$(DESTDIR
)$(BINDIR
)
83 $(Q
)install -d
$(DESTDIR
)$(LIBDIR
)
84 $(Q
)install -d
$(DESTDIR
)$(MAN1DIR
)
85 $(Q
)install -d
$(DESTDIR
)$(INCLUDEDIR
)/sparse
86 $(Q
)install -d
$(DESTDIR
)$(PKGCONFIGDIR
)
87 $(Q
)for f in
$(INST_PROGRAMS
); do \
88 $(QUIET_INST_SH
)install -v
$$f $(DESTDIR
)$(BINDIR
)/$$f || exit
1; \
90 $(Q
)for f in
$(INST_MAN1
); do \
91 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(MAN1DIR
)/$$f || exit
1; \
93 $(Q
)for f in
$(LIBS
); do \
94 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(LIBDIR
)/$$f || exit
1; \
96 $(Q
)for f in
$(LIB_H
); do \
97 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(INCLUDEDIR
)/sparse
/$$f || exit
1; \
99 $(QUIET_INST
)install -m
644 -v sparse.
pc $(DESTDIR
)$(PKGCONFIGDIR
)/sparse.
pc
101 sparse.
pc: sparse.
pc.in
102 $(QUIET_GEN
)sed
's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.
pc.in
> sparse.
pc
104 test-lexing
: test-lexing.o
$(LIBS
)
105 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
107 test-parsing
: test-parsing.o
$(LIBS
)
108 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
110 test-linearize
: test-linearize.o
$(LIBS
)
111 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
113 test-sort
: test-sort.o
$(LIBS
)
114 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
116 compile
: compile.o compile-i386.o
$(LIBS
)
117 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< compile-i386.o
$(LIBS
)
119 obfuscate
: obfuscate.o
$(LIBS
)
120 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
122 sparse
: sparse.o
$(LIBS
)
123 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
125 graph
: graph.o
$(LIBS
)
126 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
128 example
: example.o
$(LIBS
)
129 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
131 test-unssa
: test-unssa.o
$(LIBS
)
132 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
134 test-dissect
: test-dissect.o
$(LIBS
)
135 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
137 ctags
: ctags.o
$(LIBS
)
138 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
140 c2xml
: c2xml.o
$(LIBS
)
141 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
) `pkg-config --libs libxml-2.0`
143 smatch
: smatch.o
$(SMATCH_FILES
) $(SMATCH_CHECKS
) $(LIBS
)
144 $(CC
) $(LDFLAGS
) -o
$@
$< $(SMATCH_FILES
) $(SMATCH_CHECKS
) $(LIBS
)
146 $(LIB_FILE
): $(LIB_OBJS
)
147 $(QUIET_AR
)$(AR
) rcs
$@
$(LIB_OBJS
)
149 $(SLIB_FILE
): $(LIB_OBJS
)
150 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -Wl
,-soname
,$@
-shared
-o
$@
$(LIB_OBJS
)
153 expression.o
: $(LIB_H
)
158 pre-process.o
: $(LIB_H
) pre-process.h
160 show-parse.o
: $(LIB_H
)
163 linearize.o
: $(LIB_H
)
172 test-lexing.o
: $(LIB_H
)
173 test-parsing.o
: $(LIB_H
)
174 test-linearize.o
: $(LIB_H
)
175 test-dissect.o
: $(LIB_H
)
176 smatch_flow.o
: $(LIB_H
) smatch.h smatch_expression_stacks.h smatch_extra.h
177 smatch_conditions.o
: $(LIB_H
) smatch.h
178 smatch_extra.o
: $(LIB_H
) smatch.h smatch_extra.h
179 smatch_ranges.o
: $(LIB_H
) smatch.h smatch_extra.h
180 smatch_implied.o
: $(LIB_H
) smatch.h smatch_slist.h smatch_extra.h
181 smatch_ignore.o
: $(LIB_H
) smatch.h
182 smatch_tracker.o
: $(LIB_H
) smatch.h
183 smatch_files.o
: $(LIB_H
) smatch.h
184 smatch_hooks.o
: $(LIB_H
) smatch.h
185 smatch_function_hooks.o
: $(LIB_H
) smatch.h smatch_slist.h smatch_extra.h
186 smatch_modification_hooks.o
: $(LIB_H
) smatch.h
187 smatch_containers.o
: $(LIB_H
) smatch.h
188 smatch_helper.o
: $(LIB_H
) smatch.h
189 smatch_slist.o
: $(LIB_H
) smatch.h smatch_slist.h
190 smatch_states.o
: $(LIB_H
) smatch.h smatch_slist.h smatch_extra.h
191 smatch_expression_stacks.o
: $(LIB_H
) smatch.h
192 smatch_oom.c
: $(LIB_H
) smatch.h
193 smatch_redefine.c
: $(LIB_H
) smatch.h
194 smatch.o
: $(LIB_H
) smatch.h
195 $(SMATCH_CHECKS
): smatch.h smatch_slist.h
196 test-unssa.o
: $(LIB_H
)
198 compile.o
: $(LIB_H
) compile.h
199 compile-i386.o
: $(LIB_H
) compile.h
202 obfuscate.o
: $(LIB_H
)
208 c2xml.o
: c2xml.c
$(LIB_H
)
209 $(QUIET_CC
)$(CC
) `pkg-config --cflags libxml-2.0` -o
$@
-c
$(CFLAGS
) $<
211 compat-linux.o
: compat
/strtold.c compat
/mmap-blob.c \
213 compat-solaris.o
: compat
/mmap-blob.c
$(LIB_H
)
214 compat-mingw.o
: $(LIB_H
)
215 compat-cygwin.o
: $(LIB_H
)
218 $(QUIET_GEN
)echo
"#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
221 $(QUIET_CC
)$(CC
) -o
$@
-c
$(CFLAGS
) $<
224 rm -f
*.
[oa
] $(PROGRAMS
) $(SLIB_FILE
) pre-process.h sparse.
pc
227 @if
test "`git describe`" != "$(VERSION)" ; then \
228 echo
'Update VERSION in the Makefile before running "make dist".' ; \
231 git archive
--format
=tar --prefix=sparse-
$(VERSION
)/ HEAD^
{tree
} | gzip
-9 > sparse-
$(VERSION
).
tar.gz
234 $(Q
)cd validation
&& .
/test-suite
237 find validation
/ \
( -name
"*.c.output.expected" \
238 -o
-name
"*.c.output.got" \
239 -o
-name
"*.c.output.diff" \
240 -o
-name
"*.c.error.expected" \
241 -o
-name
"*.c.error.got" \
242 -o
-name
"*.c.error.diff" \