6 CFLAGS ?
= -O2
-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 smatch_extra.o \
31 smatch_extra_helper.o smatch_implied.o smatch_ignore.o \
32 smatch_tracker.o smatch_files.o smatch_expression_stacks.o
33 SMATCH_CHECKS
=$(shell ls check_
*.c | sed
-e
's/\.c/.o/')
36 INST_PROGRAMS
=sparse cgcc
37 INST_MAN1
=sparse
.1 cgcc
.1
39 ifeq ($(HAVE_LIBXML
),yes
)
44 LIB_H
= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
45 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
46 storage.h ptrlist.h dissect.h
48 LIB_OBJS
= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
49 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
50 sort.o allocate.o compat-
$(OS
).o ptrlist.o \
51 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
54 SLIB_FILE
= libsparse.so
56 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
57 # Doing so incurs a noticeable performance hit, and Sparse does not have a
58 # stable shared library interface, so this does not occur by default. If you
59 # really want a shared library, you may want to build Sparse twice: once
60 # without -fpic to get all the Sparse tools, and again with -fpic to get the
69 QUIET_CC
= $(Q
:@
=@echo
' CC '$@
;)
70 QUIET_AR
= $(Q
:@
=@echo
' AR '$@
;)
71 QUIET_GEN
= $(Q
:@
=@echo
' GEN '$@
;)
72 QUIET_LINK
= $(Q
:@
=@echo
' LINK '$@
;)
73 # We rely on the -v switch of install to print 'file -> $install_dir/file'
74 QUIET_INST_SH
= $(Q
:@
=echo
-n
' INSTALL ';)
75 QUIET_INST
= $(Q
:@
=@echo
-n
' INSTALL ';)
77 all: $(PROGRAMS
) sparse.
pc
79 install: $(INST_PROGRAMS
) $(LIBS
) $(LIB_H
) sparse.
pc
80 $(Q
)install -d
$(DESTDIR
)$(BINDIR
)
81 $(Q
)install -d
$(DESTDIR
)$(LIBDIR
)
82 $(Q
)install -d
$(DESTDIR
)$(MAN1DIR
)
83 $(Q
)install -d
$(DESTDIR
)$(INCLUDEDIR
)/sparse
84 $(Q
)install -d
$(DESTDIR
)$(PKGCONFIGDIR
)
85 $(Q
)for f in
$(INST_PROGRAMS
); do \
86 $(QUIET_INST_SH
)install -v
$$f $(DESTDIR
)$(BINDIR
)/$$f || exit
1; \
88 $(Q
)for f in
$(INST_MAN1
); do \
89 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(MAN1DIR
)/$$f || exit
1; \
91 $(Q
)for f in
$(LIBS
); do \
92 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(LIBDIR
)/$$f || exit
1; \
94 $(Q
)for f in
$(LIB_H
); do \
95 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(INCLUDEDIR
)/sparse
/$$f || exit
1; \
97 $(QUIET_INST
)install -m
644 -v sparse.
pc $(DESTDIR
)$(PKGCONFIGDIR
)/sparse.
pc
99 sparse.
pc: sparse.
pc.in
100 $(QUIET_GEN
)sed
's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.
pc.in
> sparse.
pc
102 test-lexing
: test-lexing.o
$(LIBS
)
103 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
105 test-parsing
: test-parsing.o
$(LIBS
)
106 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
108 test-linearize
: test-linearize.o
$(LIBS
)
109 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
111 test-sort
: test-sort.o
$(LIBS
)
112 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
114 compile
: compile.o compile-i386.o
$(LIBS
)
115 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< compile-i386.o
$(LIBS
)
117 obfuscate
: obfuscate.o
$(LIBS
)
118 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
120 sparse
: sparse.o
$(LIBS
)
121 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
123 graph
: graph.o
$(LIBS
)
124 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
126 example
: example.o
$(LIBS
)
127 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
129 test-unssa
: test-unssa.o
$(LIBS
)
130 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
132 test-dissect
: test-dissect.o
$(LIBS
)
133 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
135 ctags
: ctags.o
$(LIBS
)
136 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
138 c2xml
: c2xml.o
$(LIBS
)
139 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
) `pkg-config --libs libxml-2.0`
141 smatch
: smatch.o
$(SMATCH_FILES
) $(SMATCH_CHECKS
) $(LIBS
)
142 $(CC
) $(LDFLAGS
) -o
$@
$< $(SMATCH_FILES
) $(SMATCH_CHECKS
) $(LIBS
)
144 $(LIB_FILE
): $(LIB_OBJS
)
145 $(QUIET_AR
)$(AR
) rcs
$@
$(LIB_OBJS
)
147 $(SLIB_FILE
): $(LIB_OBJS
)
148 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -Wl
,-soname
,$@
-shared
-o
$@
$(LIB_OBJS
)
151 expression.o
: $(LIB_H
)
156 pre-process.o
: $(LIB_H
) pre-process.h
158 show-parse.o
: $(LIB_H
)
161 linearize.o
: $(LIB_H
)
170 test-lexing.o
: $(LIB_H
)
171 test-parsing.o
: $(LIB_H
)
172 test-linearize.o
: $(LIB_H
)
173 test-dissect.o
: $(LIB_H
)
174 smatch_flow.o
: $(LIB_H
) smatch.h
175 smatch_conditions.o
: $(LIB_H
) smatch.h
176 smatch_extra.o
: $(LIB_H
) smatch.h smatch_extra.h
177 smatch_extra_helper.o
: $(LIB_H
) smatch.h smatch_extra.h
178 smatch_implied.o
: $(LIB_H
) smatch.h smatch_slist.h smatch_extra.h
179 smatch_ignore.o
: $(LIB_H
) smatch.h
180 smatch_tracker.o
: $(LIB_H
) smatch.h
181 smatch_files.o
: $(LIB_H
) smatch.h
182 smatch_hooks.o
: $(LIB_H
) smatch.h
183 smatch_function_hooks.o
: $(LIB_H
) smatch.h
184 smatch_helper.o
: $(LIB_H
) smatch.h
185 smatch_slist.o
: $(LIB_H
) smatch.h smatch_slist.h smatch_extra.h
186 smatch_states.o
: $(LIB_H
) smatch.h smatch_slist.h
187 smatch_expression_stacks.o
: $(LIB_H
) smatch.h
188 smatch.o
: $(LIB_H
) smatch.h
189 $(SMATCH_CHECKS
): smatch.h smatch_slist.h
190 test-unssa.o
: $(LIB_H
)
192 compile.o
: $(LIB_H
) compile.h
193 compile-i386.o
: $(LIB_H
) compile.h
196 obfuscate.o
: $(LIB_H
)
202 c2xml.o
: c2xml.c
$(LIB_H
)
203 $(QUIET_CC
)$(CC
) `pkg-config --cflags libxml-2.0` -o
$@
-c
$(CFLAGS
) $<
205 compat-linux.o
: compat
/strtold.c compat
/mmap-blob.c \
207 compat-solaris.o
: compat
/mmap-blob.c
$(LIB_H
)
208 compat-mingw.o
: $(LIB_H
)
209 compat-cygwin.o
: $(LIB_H
)
212 $(QUIET_GEN
)echo
"#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
215 $(QUIET_CC
)$(CC
) -o
$@
-c
$(CFLAGS
) $<
218 rm -f
*.
[oa
] $(PROGRAMS
) $(SLIB_FILE
) pre-process.h sparse.
pc
221 @if
test "`git describe`" != "$(VERSION)" ; then \
222 echo
'Update VERSION in the Makefile before running "make dist".' ; \
225 git archive
--format
=tar --prefix=sparse-
$(VERSION
)/ HEAD^
{tree
} | gzip
-9 > sparse-
$(VERSION
).
tar.gz
228 $(Q
)cd validation
&& .
/test-suite
231 find validation
/ \
( -name
"*.c.output.expected" \
232 -o
-name
"*.c.output.got" \
233 -o
-name
"*.c.output.diff" \
234 -o
-name
"*.c.error.expected" \
235 -o
-name
"*.c.error.got" \
236 -o
-name
"*.c.error.diff" \