Make show_symbol newline-consistent
[smatch.git] / Makefile
blob3eab17e9eef189c0b7c6c39ed911b8f44a30dfe4
1 VERSION=0.4.1
3 OS ?= linux
5 CC ?= gcc
6 CFLAGS ?= -O2 -finline-functions -fno-strict-aliasing -g
7 CFLAGS += -Wall -Wwrite-strings
8 LDFLAGS ?= -g
9 AR ?= ar
11 HAVE_LIBXML=$(shell pkg-config --exists libxml-2.0 && echo 'yes')
14 # For debugging, uncomment the next one
16 CFLAGS += -DDEBUG
18 DESTDIR=
19 PREFIX=$(HOME)
20 BINDIR=$(PREFIX)/bin
21 LIBDIR=$(PREFIX)/lib
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)
35 PROGRAMS+=c2xml
36 INST_PROGRAMS+=c2xml
37 endif
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
48 LIB_FILE= libsparse.a
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
56 # shared library.
57 LIBS=$(LIB_FILE)
60 # Pretty print
62 V = @
63 Q = $(V:1=)
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; \
82 done
83 $(Q)for f in $(INST_MAN1); do \
84 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(MAN1DIR)/$$f || exit 1; \
85 done
86 $(Q)for f in $(LIBS); do \
87 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(LIBDIR)/$$f || exit 1; \
88 done
89 $(Q)for f in $(LIB_H); do \
90 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(INCLUDEDIR)/sparse/$$f || exit 1; \
91 done
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)
142 evaluate.o: $(LIB_H)
143 expression.o: $(LIB_H)
144 lib.o: $(LIB_H)
145 allocate.o: $(LIB_H)
146 ptrlist.o: $(LIB_H)
147 parse.o: $(LIB_H)
148 pre-process.o: $(LIB_H) pre-process.h
149 scope.o: $(LIB_H)
150 show-parse.o: $(LIB_H)
151 symbol.o: $(LIB_H)
152 expand.o: $(LIB_H)
153 linearize.o: $(LIB_H)
154 flow.o: $(LIB_H)
155 cse.o: $(LIB_H)
156 simplify.o: $(LIB_H)
157 memops.o: $(LIB_H)
158 liveness.o: $(LIB_H)
159 sort.o: $(LIB_H)
160 inline.o: $(LIB_H)
161 target.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)
167 ctags.o: $(LIB_H)
168 compile.o: $(LIB_H) compile.h
169 compile-i386.o: $(LIB_H) compile.h
170 tokenize.o: $(LIB_H)
171 sparse.o: $(LIB_H)
172 obfuscate.o: $(LIB_H)
173 example.o: $(LIB_H)
174 storage.o: $(LIB_H)
175 dissect.o: $(LIB_H)
176 graph.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 \
182 $(LIB_H)
183 compat-solaris.o: compat/mmap-blob.c $(LIB_H)
184 compat-mingw.o: $(LIB_H)
185 compat-cygwin.o: $(LIB_H)
187 pre-process.h:
188 $(QUIET_GEN)echo "#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
190 .c.o:
191 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
193 clean: clean-check
194 rm -f *.[oa] $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc
196 dist:
197 @if test "`git describe`" != "$(VERSION)" ; then \
198 echo 'Update VERSION in the Makefile before running "make dist".' ; \
199 exit 1 ; \
201 git archive --format=tar --prefix=sparse-$(VERSION)/ HEAD^{tree} | gzip -9 > sparse-$(VERSION).tar.gz
203 check: all
204 $(Q)cd validation && ./test-suite
206 clean-check:
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" \
213 \) -exec rm {} \;