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
31 INST_PROGRAMS
=sparse cgcc
32 INST_MAN1
=sparse
.1 cgcc
.1
34 ifeq ($(HAVE_LIBXML
),yes
)
39 LIB_H
= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
40 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
41 storage.h ptrlist.h dissect.h
43 LIB_OBJS
= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
44 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
45 sort.o allocate.o compat-
$(OS
).o ptrlist.o \
46 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
49 SLIB_FILE
= libsparse.so
51 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
52 # Doing so incurs a noticeable performance hit, and Sparse does not have a
53 # stable shared library interface, so this does not occur by default. If you
54 # really want a shared library, you may want to build Sparse twice: once
55 # without -fpic to get all the Sparse tools, and again with -fpic to get the
64 QUIET_CC
= $(Q
:@
=@echo
' CC '$@
;)
65 QUIET_AR
= $(Q
:@
=@echo
' AR '$@
;)
66 QUIET_GEN
= $(Q
:@
=@echo
' GEN '$@
;)
67 QUIET_LINK
= $(Q
:@
=@echo
' LINK '$@
;)
68 # We rely on the -v switch of install to print 'file -> $install_dir/file'
69 QUIET_INST_SH
= $(Q
:@
=echo
-n
' INSTALL ';)
70 QUIET_INST
= $(Q
:@
=@echo
-n
' INSTALL ';)
72 all: $(PROGRAMS
) sparse.
pc
74 install: $(INST_PROGRAMS
) $(LIBS
) $(LIB_H
) sparse.
pc
75 $(Q
)install -d
$(DESTDIR
)$(BINDIR
)
76 $(Q
)install -d
$(DESTDIR
)$(LIBDIR
)
77 $(Q
)install -d
$(DESTDIR
)$(MAN1DIR
)
78 $(Q
)install -d
$(DESTDIR
)$(INCLUDEDIR
)/sparse
79 $(Q
)install -d
$(DESTDIR
)$(PKGCONFIGDIR
)
80 $(Q
)for f in
$(INST_PROGRAMS
); do \
81 $(QUIET_INST_SH
)install -v
$$f $(DESTDIR
)$(BINDIR
)/$$f || exit
1; \
83 $(Q
)for f in
$(INST_MAN1
); do \
84 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(MAN1DIR
)/$$f || exit
1; \
86 $(Q
)for f in
$(LIBS
); do \
87 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(LIBDIR
)/$$f || exit
1; \
89 $(Q
)for f in
$(LIB_H
); do \
90 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(INCLUDEDIR
)/sparse
/$$f || exit
1; \
92 $(QUIET_INST
)install -m
644 -v sparse.
pc $(DESTDIR
)$(PKGCONFIGDIR
)/sparse.
pc
94 sparse.
pc: sparse.
pc.in
95 $(QUIET_GEN
)sed
's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.
pc.in
> sparse.
pc
97 test-lexing
: test-lexing.o
$(LIBS
)
98 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
100 test-parsing
: test-parsing.o
$(LIBS
)
101 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
103 test-linearize
: test-linearize.o
$(LIBS
)
104 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
106 test-sort
: test-sort.o
$(LIBS
)
107 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
109 compile
: compile.o compile-i386.o
$(LIBS
)
110 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< compile-i386.o
$(LIBS
)
112 obfuscate
: obfuscate.o
$(LIBS
)
113 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
115 sparse
: sparse.o
$(LIBS
)
116 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
118 graph
: graph.o
$(LIBS
)
119 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
121 example
: example.o
$(LIBS
)
122 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
124 test-unssa
: test-unssa.o
$(LIBS
)
125 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
127 test-dissect
: test-dissect.o
$(LIBS
)
128 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
130 ctags
: ctags.o
$(LIBS
)
131 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
133 c2xml
: c2xml.o
$(LIBS
)
134 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
) `pkg-config --libs libxml-2.0`
136 $(LIB_FILE
): $(LIB_OBJS
)
137 $(QUIET_AR
)$(AR
) rcs
$@
$(LIB_OBJS
)
139 $(SLIB_FILE
): $(LIB_OBJS
)
140 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -Wl
,-soname
,$@
-shared
-o
$@
$(LIB_OBJS
)
143 expression.o
: $(LIB_H
)
148 pre-process.o
: $(LIB_H
) pre-process.h
150 show-parse.o
: $(LIB_H
)
153 linearize.o
: $(LIB_H
)
162 test-lexing.o
: $(LIB_H
)
163 test-parsing.o
: $(LIB_H
)
164 test-linearize.o
: $(LIB_H
)
165 test-dissect.o
: $(LIB_H
)
166 test-unssa.o
: $(LIB_H
)
168 compile.o
: $(LIB_H
) compile.h
169 compile-i386.o
: $(LIB_H
) compile.h
172 obfuscate.o
: $(LIB_H
)
178 c2xml.o
: c2xml.c
$(LIB_H
)
179 $(QUIET_CC
)$(CC
) `pkg-config --cflags libxml-2.0` -o
$@
-c
$(CFLAGS
) $<
181 compat-linux.o
: compat
/strtold.c compat
/mmap-blob.c \
183 compat-solaris.o
: compat
/mmap-blob.c
$(LIB_H
)
184 compat-mingw.o
: $(LIB_H
)
185 compat-cygwin.o
: $(LIB_H
)
188 $(QUIET_GEN
)echo
"#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
191 $(QUIET_CC
)$(CC
) -o
$@
-c
$(CFLAGS
) $<
194 rm -f
*.
[oa
] $(PROGRAMS
) $(SLIB_FILE
) pre-process.h sparse.
pc
197 @if
test "`git describe`" != "$(VERSION)" ; then \
198 echo
'Update VERSION in the Makefile before running "make dist".' ; \
201 git archive
--format
=tar --prefix=sparse-
$(VERSION
)/ HEAD^
{tree
} | gzip
-9 > sparse-
$(VERSION
).
tar.gz
204 $(Q
)cd validation
&& .
/test-suite
207 find validation
/ \
( -name
"*.c.output.expected" \
208 -o
-name
"*.c.output.got" \
209 -o
-name
"*.c.output.diff" \
210 -o
-name
"*.c.error.expected" \
211 -o
-name
"*.c.error.got" \
212 -o
-name
"*.c.error.diff" \