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 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
)
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
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
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; \
85 $(Q
)for f in
$(INST_MAN1
); do \
86 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(MAN1DIR
)/$$f || exit
1; \
88 $(Q
)for f in
$(LIBS
); do \
89 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(LIBDIR
)/$$f || exit
1; \
91 $(Q
)for f in
$(LIB_H
); do \
92 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(INCLUDEDIR
)/sparse
/$$f || exit
1; \
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
)
148 expression.o
: $(LIB_H
)
153 pre-process.o
: $(LIB_H
) pre-process.h
155 show-parse.o
: $(LIB_H
)
158 linearize.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 $(SMATCH_CHECKS
): smatch.h smatch_slist.h
184 test-unssa.o
: $(LIB_H
)
186 compile.o
: $(LIB_H
) compile.h
187 compile-i386.o
: $(LIB_H
) compile.h
190 obfuscate.o
: $(LIB_H
)
196 c2xml.o
: c2xml.c
$(LIB_H
)
197 $(QUIET_CC
)$(CC
) `pkg-config --cflags libxml-2.0` -o
$@
-c
$(CFLAGS
) $<
199 compat-linux.o
: compat
/strtold.c compat
/mmap-blob.c \
201 compat-solaris.o
: compat
/mmap-blob.c
$(LIB_H
)
202 compat-mingw.o
: $(LIB_H
)
203 compat-cygwin.o
: $(LIB_H
)
206 $(QUIET_GEN
)echo
"#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
209 $(QUIET_CC
)$(CC
) -o
$@
-c
$(CFLAGS
) $<
212 rm -f
*.
[oa
] $(PROGRAMS
) $(SLIB_FILE
) pre-process.h sparse.
pc
215 @if
test "`git describe`" != "$(VERSION)" ; then \
216 echo
'Update VERSION in the Makefile before running "make dist".' ; \
219 git archive
--format
=tar --prefix=sparse-
$(VERSION
)/ HEAD^
{tree
} | gzip
-9 > sparse-
$(VERSION
).
tar.gz
222 $(Q
)cd validation
&& .
/test-suite
225 find validation
/ \
( -name
"*.c.output.expected" \
226 -o
-name
"*.c.output.got" \
227 -o
-name
"*.c.output.diff" \
228 -o
-name
"*.c.error.expected" \
229 -o
-name
"*.c.error.got" \
230 -o
-name
"*.c.error.diff" \