6 CFLAGS ?
= -O2
-finline-functions
-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 INCLUDEDIR
=$(PREFIX
)/include
23 PKGCONFIGDIR
=$(LIBDIR
)/pkgconfig
25 PROGRAMS
=test-lexing test-parsing obfuscate compile graph sparse test-linearize example \
26 test-unssa test-dissect ctags
29 INST_PROGRAMS
=sparse cgcc
31 ifeq ($(HAVE_LIBXML
),yes
)
36 LIB_H
= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
37 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
38 storage.h ptrlist.h dissect.h
40 LIB_OBJS
= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
41 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
42 sort.o allocate.o compat-
$(OS
).o ptrlist.o \
43 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
46 SLIB_FILE
= libsparse.so
48 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
49 # Doing so incurs a noticeable performance hit, and Sparse does not have a
50 # stable shared library interface, so this does not occur by default. If you
51 # really want a shared library, you may want to build Sparse twice: once
52 # without -fpic to get all the Sparse tools, and again with -fpic to get the
61 QUIET_CC
= $(Q
:@
=@echo
' CC '$@
;)
62 QUIET_AR
= $(Q
:@
=@echo
' AR '$@
;)
63 QUIET_GEN
= $(Q
:@
=@echo
' GEN '$@
;)
64 QUIET_LINK
= $(Q
:@
=@echo
' LINK '$@
;)
65 # We rely on the -v switch of install to print 'file -> $install_dir/file'
66 QUIET_INST_SH
= $(Q
:@
=echo
-n
' INSTALL ';)
67 QUIET_INST
= $(Q
:@
=@echo
-n
' INSTALL ';)
69 all: $(PROGRAMS
) sparse.
pc
71 install: $(INST_PROGRAMS
) $(LIBS
) $(LIB_H
) sparse.
pc
72 $(Q
)install -d
$(DESTDIR
)$(BINDIR
)
73 $(Q
)install -d
$(DESTDIR
)$(LIBDIR
)
74 $(Q
)install -d
$(DESTDIR
)$(INCLUDEDIR
)/sparse
75 $(Q
)install -d
$(DESTDIR
)$(PKGCONFIGDIR
)
76 $(Q
)for f in
$(INST_PROGRAMS
); do \
77 $(QUIET_INST_SH
)install -v
$$f $(DESTDIR
)$(BINDIR
)/$$f || exit
1; \
79 $(Q
)for f in
$(LIBS
); do \
80 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(LIBDIR
)/$$f || exit
1; \
82 $(Q
)for f in
$(LIB_H
); do \
83 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(INCLUDEDIR
)/sparse
/$$f || exit
1; \
85 $(QUIET_INST
)install -m
644 -v sparse.
pc $(DESTDIR
)$(PKGCONFIGDIR
)/sparse.
pc
87 sparse.
pc: sparse.
pc.in
88 $(QUIET_GEN
)sed
's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.
pc.in
> sparse.
pc
90 test-lexing
: test-lexing.o
$(LIBS
)
91 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
93 test-parsing
: test-parsing.o
$(LIBS
)
94 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
96 test-linearize
: test-linearize.o
$(LIBS
)
97 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
99 test-sort
: test-sort.o
$(LIBS
)
100 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
102 compile
: compile.o compile-i386.o
$(LIBS
)
103 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< compile-i386.o
$(LIBS
)
105 obfuscate
: obfuscate.o
$(LIBS
)
106 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
108 sparse
: sparse.o
$(LIBS
)
109 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
111 graph
: graph.o
$(LIBS
)
112 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
114 example
: example.o
$(LIBS
)
115 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
117 test-unssa
: test-unssa.o
$(LIBS
)
118 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
120 test-dissect
: test-dissect.o
$(LIBS
)
121 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
123 ctags
: ctags.o
$(LIBS
)
124 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
126 c2xml
: c2xml.o
$(LIBS
)
127 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
) `pkg-config --libs libxml-2.0`
129 $(LIB_FILE
): $(LIB_OBJS
)
130 $(QUIET_AR
)$(AR
) rcs
$@
$(LIB_OBJS
)
132 $(SLIB_FILE
): $(LIB_OBJS
)
133 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -Wl
,-soname
,$@
-shared
-o
$@
$(LIB_OBJS
)
136 expression.o
: $(LIB_H
)
141 pre-process.o
: $(LIB_H
) pre-process.h
143 show-parse.o
: $(LIB_H
)
146 linearize.o
: $(LIB_H
)
155 test-lexing.o
: $(LIB_H
)
156 test-parsing.o
: $(LIB_H
)
157 test-linearize.o
: $(LIB_H
)
158 test-dissect.o
: $(LIB_H
)
159 test-unssa.o
: $(LIB_H
)
161 compile.o
: $(LIB_H
) compile.h
162 compile-i386.o
: $(LIB_H
) compile.h
165 obfuscate.o
: $(LIB_H
)
171 c2xml.o
: c2xml.c
$(LIB_H
)
172 $(QUIET_CC
)$(CC
) `pkg-config --cflags libxml-2.0` -o
$@
-c
$(CFLAGS
) $<
174 compat-linux.o
: compat
/strtold.c compat
/mmap-blob.c \
176 compat-solaris.o
: compat
/mmap-blob.c
$(LIB_H
)
177 compat-mingw.o
: $(LIB_H
)
178 compat-cygwin.o
: $(LIB_H
)
181 $(QUIET_GEN
)echo
"#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
184 $(QUIET_CC
)$(CC
) -o
$@
-c
$(CFLAGS
) $<
187 rm -f
*.
[oa
] $(PROGRAMS
) $(SLIB_FILE
) pre-process.h sparse.
pc
190 @if
test "`git describe`" != "$(VERSION)" ; then \
191 echo
'Update VERSION in the Makefile before running "make dist".' ; \
194 git archive
--format
=tar --prefix=sparse-
$(VERSION
)/ HEAD^
{tree
} | gzip
-9 > sparse-
$(VERSION
).
tar.gz
197 $(Q
)cd validation
&& .
/test-suite
200 find validation
/ \
( -name
"*.c.output.expected" \
201 -o
-name
"*.c.output.got" \
202 -o
-name
"*.c.output.diff" \
203 -o
-name
"*.c.error.expected" \
204 -o
-name
"*.c.error.got" \
205 -o
-name
"*.c.error.diff" \