allocate.h: Stop needlessly returning a void value in __DO_ALLOCATOR
[smatch.git] / Makefile
blob478e151dc8fd4b53c39041364016ff511413313a
1 VERSION=0.3
3 OS=linux
5 CC=gcc
6 CFLAGS=-O -g -Wall -Wwrite-strings -fpic
7 LDFLAGS=-g
8 AR=ar
10 HAVE_LIBXML=$(shell pkg-config --exists libxml-2.0 && echo 'yes')
13 # For debugging, uncomment the next one
15 CFLAGS += -DDEBUG
17 DESTDIR=
18 PREFIX=$(HOME)
19 BINDIR=$(PREFIX)/bin
20 LIBDIR=$(PREFIX)/lib
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)
31 PROGRAMS+=c2xml
32 INST_PROGRAMS+=c2xml
33 endif
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
44 LIB_FILE= libsparse.a
45 SLIB_FILE= libsparse.so
47 LIBS=$(LIB_FILE)
50 # Pretty print
52 V = @
53 Q = $(V:1=)
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; \
71 done
72 $(Q)for f in $(LIBS); do \
73 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(LIBDIR)/$$f || exit 1; \
74 done
75 $(Q)for f in $(LIB_H); do \
76 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(INCLUDEDIR)/sparse/$$f || exit 1; \
77 done
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)
128 evaluate.o: $(LIB_H)
129 expression.o: $(LIB_H)
130 lib.o: $(LIB_H)
131 allocate.o: $(LIB_H)
132 parse.o: $(LIB_H)
133 pre-process.o: $(LIB_H) pre-process.h
134 scope.o: $(LIB_H)
135 show-parse.o: $(LIB_H)
136 symbol.o: $(LIB_H)
137 expand.o: $(LIB_H)
138 linearize.o: $(LIB_H)
139 flow.o: $(LIB_H)
140 cse.o: $(LIB_H)
141 simplify.o: $(LIB_H)
142 memops.o: $(LIB_H)
143 liveness.o: $(LIB_H)
144 sort.o: $(LIB_H)
145 inline.o: $(LIB_H)
146 target.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)
151 ctags.o: $(LIB_H)
152 compile.o: $(LIB_H) compile.h
153 compile-i386.o: $(LIB_H) compile.h
154 tokenize.o: $(LIB_H)
155 sparse.o: $(LIB_H)
156 obfuscate.o: $(LIB_H)
157 example.o: $(LIB_H)
158 storage.o: $(LIB_H)
159 dissect.o: $(LIB_H)
160 graph.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 \
166 $(LIB_H)
167 compat-solaris.o: compat/mmap-blob.c $(LIB_H)
168 compat-mingw.o: $(LIB_H)
169 compat-cygwin.o: $(LIB_H)
171 pre-process.h:
172 $(QUIET_GEN)echo "#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
174 .c.o:
175 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
177 clean: clean-check
178 rm -f *.[oa] $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc
180 dist:
181 @if test "`git describe`" != "$(VERSION)" ; then \
182 echo 'Update VERSION in the Makefile before running "make dist".' ; \
183 exit 1 ; \
185 git archive --format=tar --prefix=sparse-$(VERSION)/ HEAD^{tree} | gzip -9 > sparse-$(VERSION).tar.gz
187 check: all
188 $(Q)cd validation && ./test-suite
190 clean-check:
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" \
197 \) -exec rm {} \;