7 CFLAGS
= -O2
-finline-functions
-fno-strict-aliasing
-g
8 CFLAGS
+= -Wall
-Wwrite-strings
13 # For debugging, uncomment the next one
15 #CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
17 HAVE_LIBXML
=$(shell pkg-config
--exists libxml-2.0
&& echo
'yes')
20 CFLAGS
+= -DGCC_BASE
=\"$(shell $(CC
) --print-file-name
=)\"
26 MANDIR
=$(PREFIX
)/share
/man
27 MAN1DIR
=$(MANDIR
)/man1
28 INCLUDEDIR
=$(PREFIX
)/include
29 PKGCONFIGDIR
=$(LIBDIR
)/pkgconfig
31 PROGRAMS
=test-lexing test-parsing obfuscate compile graph sparse test-linearize example \
32 test-unssa test-dissect ctags
35 INST_PROGRAMS
=sparse cgcc
36 INST_MAN1
=sparse
.1 cgcc
.1
38 ifeq ($(HAVE_LIBXML
),yes
)
43 LIB_H
= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
44 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
45 storage.h ptrlist.h dissect.h
47 LIB_OBJS
= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
48 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
49 sort.o allocate.o compat-
$(OS
).o ptrlist.o \
50 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
53 SLIB_FILE
= libsparse.so
55 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
56 # Doing so incurs a noticeable performance hit, and Sparse does not have a
57 # stable shared library interface, so this does not occur by default. If you
58 # really want a shared library, you may want to build Sparse twice: once
59 # without -fpic to get all the Sparse tools, and again with -fpic to get the
68 QUIET_CC
= $(Q
:@
=@echo
' CC '$@
;)
69 QUIET_AR
= $(Q
:@
=@echo
' AR '$@
;)
70 QUIET_GEN
= $(Q
:@
=@echo
' GEN '$@
;)
71 QUIET_LINK
= $(Q
:@
=@echo
' LINK '$@
;)
72 # We rely on the -v switch of install to print 'file -> $install_dir/file'
73 QUIET_INST_SH
= $(Q
:@
=echo
-n
' INSTALL ';)
74 QUIET_INST
= $(Q
:@
=@echo
-n
' INSTALL ';)
76 all: $(PROGRAMS
) sparse.
pc
78 install: $(INST_PROGRAMS
) $(LIBS
) $(LIB_H
) sparse.
pc
79 $(Q
)install -d
$(DESTDIR
)$(BINDIR
)
80 $(Q
)install -d
$(DESTDIR
)$(LIBDIR
)
81 $(Q
)install -d
$(DESTDIR
)$(MAN1DIR
)
82 $(Q
)install -d
$(DESTDIR
)$(INCLUDEDIR
)/sparse
83 $(Q
)install -d
$(DESTDIR
)$(PKGCONFIGDIR
)
84 $(Q
)for f in
$(INST_PROGRAMS
); do \
85 $(QUIET_INST_SH
)install -v
$$f $(DESTDIR
)$(BINDIR
)/$$f || exit
1; \
87 $(Q
)for f in
$(INST_MAN1
); do \
88 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(MAN1DIR
)/$$f || exit
1; \
90 $(Q
)for f in
$(LIBS
); do \
91 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(LIBDIR
)/$$f || exit
1; \
93 $(Q
)for f in
$(LIB_H
); do \
94 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(INCLUDEDIR
)/sparse
/$$f || exit
1; \
96 $(QUIET_INST
)install -m
644 -v sparse.
pc $(DESTDIR
)$(PKGCONFIGDIR
)/sparse.
pc
98 sparse.
pc: sparse.
pc.in
99 $(QUIET_GEN
)sed
's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.
pc.in
> sparse.
pc
101 test-lexing
: test-lexing.o
$(LIBS
)
102 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
104 test-parsing
: test-parsing.o
$(LIBS
)
105 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
107 test-linearize
: test-linearize.o
$(LIBS
)
108 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
110 test-sort
: test-sort.o
$(LIBS
)
111 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
113 compile
: compile.o compile-i386.o
$(LIBS
)
114 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< compile-i386.o
$(LIBS
)
116 obfuscate
: obfuscate.o
$(LIBS
)
117 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
119 sparse
: sparse.o
$(LIBS
)
120 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
122 graph
: graph.o
$(LIBS
)
123 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
125 example
: example.o
$(LIBS
)
126 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
128 test-unssa
: test-unssa.o
$(LIBS
)
129 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
131 test-dissect
: test-dissect.o
$(LIBS
)
132 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
134 ctags
: ctags.o
$(LIBS
)
135 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
137 c2xml
: c2xml.o
$(LIBS
)
138 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
) `pkg-config --libs libxml-2.0`
140 $(LIB_FILE
): $(LIB_OBJS
)
141 $(QUIET_AR
)$(AR
) rcs
$@
$(LIB_OBJS
)
143 $(SLIB_FILE
): $(LIB_OBJS
)
144 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -Wl
,-soname
,$@
-shared
-o
$@
$(LIB_OBJS
)
147 expression.o
: $(LIB_H
)
152 pre-process.o
: $(LIB_H
)
154 show-parse.o
: $(LIB_H
)
157 linearize.o
: $(LIB_H
)
166 test-lexing.o
: $(LIB_H
)
167 test-parsing.o
: $(LIB_H
)
168 test-linearize.o
: $(LIB_H
)
169 test-dissect.o
: $(LIB_H
)
170 test-unssa.o
: $(LIB_H
)
172 compile.o
: $(LIB_H
) compile.h
173 compile-i386.o
: $(LIB_H
) compile.h
176 obfuscate.o
: $(LIB_H
)
182 c2xml.o
: c2xml.c
$(LIB_H
)
183 $(QUIET_CC
)$(CC
) `pkg-config --cflags libxml-2.0` -o
$@
-c
$(CFLAGS
) $<
185 compat-linux.o
: compat
/strtold.c compat
/mmap-blob.c \
187 compat-solaris.o
: compat
/mmap-blob.c
$(LIB_H
)
188 compat-mingw.o
: $(LIB_H
)
189 compat-cygwin.o
: $(LIB_H
)
192 $(QUIET_CC
)$(CC
) -o
$@
-c
$(CFLAGS
) $<
195 rm -f
*.
[oa
] *.so
$(PROGRAMS
) $(SLIB_FILE
) pre-process.h sparse.
pc
198 @if
test "`git describe`" != "$(VERSION)" ; then \
199 echo
'Update VERSION in the Makefile before running "make dist".' ; \
202 git archive
--format
=tar --prefix=sparse-
$(VERSION
)/ HEAD^
{tree
} | gzip
-9 > sparse-
$(VERSION
).
tar.gz
205 $(Q
)cd validation
&& .
/test-suite
208 find validation
/ \
( -name
"*.c.output.expected" \
209 -o
-name
"*.c.output.got" \
210 -o
-name
"*.c.output.diff" \
211 -o
-name
"*.c.error.expected" \
212 -o
-name
"*.c.error.got" \
213 -o
-name
"*.c.error.diff" \