6 CFLAGS
=-O
-g
-Wall
-Wwrite-strings
-fpic
10 HAVE_LIBXML
=$(shell pkg-config
--exists libxml-2.0
&& echo
'yes')
13 # For debugging, uncomment the next one
21 INCLUDEDIR
=$(PREFIX
)/include
22 PKGCONFIGDIR
=$(LIBDIR
)/pkgconfig
24 PROGRAMS
=test-lexing test-parsing obfuscate compile graph sparse test-linearize example \
25 test-unssa test-dissect ctags
28 INST_PROGRAMS
=sparse cgcc
30 ifeq ($(HAVE_LIBXML
),yes
)
35 LIB_H
= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
36 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
37 storage.h ptrlist.h dissect.h
39 LIB_OBJS
= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
40 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
41 sort.o allocate.o compat-
$(OS
).o ptrlist.o \
42 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
45 SLIB_FILE
= libsparse.so
54 QUIET_CC
= $(Q
:@
=@echo
' CC '$@
;)
55 QUIET_AR
= $(Q
:@
=@echo
' AR '$@
;)
56 QUIET_GEN
= $(Q
:@
=@echo
' GEN '$@
;)
57 QUIET_LINK
= $(Q
:@
=@echo
' LINK '$@
;)
58 # We rely on the -v switch of install to print 'file -> $install_dir/file'
59 QUIET_INST_SH
= $(Q
:@
=echo
-n
' INSTALL ';)
60 QUIET_INST
= $(Q
:@
=@echo
-n
' INSTALL ';)
62 all: $(PROGRAMS
) sparse.
pc
64 install: $(INST_PROGRAMS
) $(LIBS
) $(LIB_H
) sparse.
pc
65 $(Q
)install -d
$(DESTDIR
)$(BINDIR
)
66 $(Q
)install -d
$(DESTDIR
)$(LIBDIR
)
67 $(Q
)install -d
$(DESTDIR
)$(INCLUDEDIR
)/sparse
68 $(Q
)install -d
$(DESTDIR
)$(PKGCONFIGDIR
)
69 $(Q
)for f in
$(INST_PROGRAMS
); do \
70 $(QUIET_INST_SH
)install -v
$$f $(DESTDIR
)$(BINDIR
)/$$f || exit
1; \
72 $(Q
)for f in
$(LIBS
); do \
73 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(LIBDIR
)/$$f || exit
1; \
75 $(Q
)for f in
$(LIB_H
); do \
76 $(QUIET_INST_SH
)install -m
644 -v
$$f $(DESTDIR
)$(INCLUDEDIR
)/sparse
/$$f || exit
1; \
78 $(QUIET_INST
)install -m
644 -v sparse.
pc $(DESTDIR
)$(PKGCONFIGDIR
)/sparse.
pc
80 sparse.
pc: sparse.
pc.in
81 $(QUIET_GEN
)sed
's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.
pc.in
> sparse.
pc
83 test-lexing
: test-lexing.o
$(LIBS
)
84 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
86 test-parsing
: test-parsing.o
$(LIBS
)
87 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
89 test-linearize
: test-linearize.o
$(LIBS
)
90 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
92 test-sort
: test-sort.o
$(LIBS
)
93 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
95 compile
: compile.o compile-i386.o
$(LIBS
)
96 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< compile-i386.o
$(LIBS
)
98 obfuscate
: obfuscate.o
$(LIBS
)
99 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
101 sparse
: sparse.o
$(LIBS
)
102 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
104 graph
: graph.o
$(LIBS
)
105 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
107 example
: example.o
$(LIBS
)
108 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
110 test-unssa
: test-unssa.o
$(LIBS
)
111 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
113 test-dissect
: test-dissect.o
$(LIBS
)
114 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
116 ctags
: ctags.o
$(LIBS
)
117 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) -o
$@
$< $(LIBS
)
119 c2xml
: c2xml.o
$(LIBS
)
120 $(QUIET_LINK
)$(CC
) $(LDFLAGS
) `pkg-config --libs libxml-2.0` -o
$@
$< $(LIBS
)
122 $(LIB_FILE
): $(LIB_OBJS
)
123 $(QUIET_AR
)$(AR
) rcs
$@
$(LIB_OBJS
)
125 $(SLIB_FILE
): $(LIB_OBJS
)
126 $(QUIET_LINK
)$(CC
) -shared
-o
$@
$(LIB_OBJS
)
129 expression.o
: $(LIB_H
)
133 pre-process.o
: $(LIB_H
) pre-process.h
135 show-parse.o
: $(LIB_H
)
138 linearize.o
: $(LIB_H
)
147 test-lexing.o
: $(LIB_H
)
148 test-parsing.o
: $(LIB_H
)
149 test-linearize.o
: $(LIB_H
)
150 test-dissect.o
: $(LIB_H
)
152 compile.o
: $(LIB_H
) compile.h
153 compile-i386.o
: $(LIB_H
) compile.h
156 obfuscate.o
: $(LIB_H
)
162 c2xml.o
: c2xml.c
$(LIB_H
)
163 $(QUIET_CC
)$(CC
) `pkg-config --cflags libxml-2.0` -o
$@
-c
$(CFLAGS
) $<
165 compat-linux.o
: compat
/strtold.c compat
/mmap-blob.c \
167 compat-solaris.o
: compat
/mmap-blob.c
$(LIB_H
)
168 compat-mingw.o
: $(LIB_H
)
169 compat-cygwin.o
: $(LIB_H
)
172 $(QUIET_GEN
)echo
"#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
175 $(QUIET_CC
)$(CC
) -o
$@
-c
$(CFLAGS
) $<
178 rm -f
*.
[oa
] $(PROGRAMS
) $(SLIB_FILE
) pre-process.h sparse.
pc
181 @if
test "`git describe`" != "$(VERSION)" ; then \
182 echo
'Update VERSION in the Makefile before running "make dist".' ; \
185 git archive
--format
=tar --prefix=sparse-
$(VERSION
)/ HEAD^
{tree
} | gzip
-9 > sparse-
$(VERSION
).
tar.gz
188 $(Q
)cd validation
&& .
/test-suite
191 find validation
/ \
( -name
"*.c.output.expected" \
192 -o
-name
"*.c.output.got" \
193 -o
-name
"*.c.output.diff" \
194 -o
-name
"*.c.error.expected" \
195 -o
-name
"*.c.error.got" \
196 -o
-name
"*.c.error.diff" \