add end position to symbols
[smatch.git] / Makefile
blob5aa5cd634232f87ae01f380ee65a7a45bfe0ca41
1 VERSION=0.3
3 OS=linux
5 CC=gcc
6 CFLAGS=-O -g -Wall -Wwrite-strings -fpic
7 LDFLAGS=-g
8 AR=ar
11 # For debugging, uncomment the next one
13 CFLAGS += -DDEBUG
15 DESTDIR=
16 PREFIX=$(HOME)
17 BINDIR=$(PREFIX)/bin
18 LIBDIR=$(PREFIX)/lib
19 INCLUDEDIR=$(PREFIX)/include
20 PKGCONFIGDIR=$(LIBDIR)/pkgconfig
22 PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example \
23 test-unssa test-dissect ctags
24 INST_PROGRAMS=sparse cgcc
26 LIB_H= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
27 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
28 storage.h ptrlist.h dissect.h
30 LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
31 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
32 sort.o allocate.o compat-$(OS).o ptrlist.o \
33 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
35 LIB_FILE= libsparse.a
36 SLIB_FILE= libsparse.so
38 LIBS=$(LIB_FILE)
41 # Pretty print
43 V = @
44 Q = $(V:1=)
45 QUIET_CC = $(Q:@=@echo ' CC '$@;)
46 QUIET_AR = $(Q:@=@echo ' AR '$@;)
47 QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
48 QUIET_LINK = $(Q:@=@echo ' LINK '$@;)
49 # We rely on the -v switch of install to print 'file -> $install_dir/file'
50 QUIET_INST_SH = $(Q:@=echo -n ' INSTALL ';)
51 QUIET_INST = $(Q:@=@echo -n ' INSTALL ';)
53 all: $(PROGRAMS) sparse.pc
55 install: $(INST_PROGRAMS) $(LIBS) $(LIB_H) sparse.pc
56 $(Q)install -d $(DESTDIR)$(BINDIR)
57 $(Q)install -d $(DESTDIR)$(LIBDIR)
58 $(Q)install -d $(DESTDIR)$(INCLUDEDIR)/sparse
59 $(Q)install -d $(DESTDIR)$(PKGCONFIGDIR)
60 $(Q)for f in $(INST_PROGRAMS); do \
61 $(QUIET_INST_SH)install -v $$f $(DESTDIR)$(BINDIR)/$$f || exit 1; \
62 done
63 $(Q)for f in $(LIBS); do \
64 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(LIBDIR)/$$f || exit 1; \
65 done
66 $(Q)for f in $(LIB_H); do \
67 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(INCLUDEDIR)/sparse/$$f || exit 1; \
68 done
69 $(QUIET_INST)install -m 644 -v sparse.pc $(DESTDIR)$(PKGCONFIGDIR)/sparse.pc
71 sparse.pc: sparse.pc.in
72 $(QUIET_GEN)sed 's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.pc.in > sparse.pc
74 test-lexing: test-lexing.o $(LIBS)
75 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
77 test-parsing: test-parsing.o $(LIBS)
78 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
80 test-linearize: test-linearize.o $(LIBS)
81 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
83 test-sort: test-sort.o $(LIBS)
84 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
86 compile: compile.o compile-i386.o $(LIBS)
87 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< compile-i386.o $(LIBS)
89 obfuscate: obfuscate.o $(LIBS)
90 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
92 sparse: sparse.o $(LIBS)
93 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
95 graph: graph.o $(LIBS)
96 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
98 example: example.o $(LIBS)
99 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
101 test-unssa: test-unssa.o $(LIBS)
102 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
104 test-dissect: test-dissect.o $(LIBS)
105 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
107 ctags: ctags.o $(LIBS)
108 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
110 $(LIB_FILE): $(LIB_OBJS)
111 $(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
113 $(SLIB_FILE): $(LIB_OBJS)
114 $(QUIET_LINK)$(CC) -shared -o $@ $(LIB_OBJS)
116 evaluate.o: $(LIB_H)
117 expression.o: $(LIB_H)
118 lib.o: $(LIB_H)
119 allocate.o: $(LIB_H)
120 parse.o: $(LIB_H)
121 pre-process.o: $(LIB_H) pre-process.h
122 scope.o: $(LIB_H)
123 show-parse.o: $(LIB_H)
124 symbol.o: $(LIB_H)
125 expand.o: $(LIB_H)
126 linearize.o: $(LIB_H)
127 flow.o: $(LIB_H)
128 cse.o: $(LIB_H)
129 simplify.o: $(LIB_H)
130 memops.o: $(LIB_H)
131 liveness.o: $(LIB_H)
132 sort.o: $(LIB_H)
133 inline.o: $(LIB_H)
134 target.o: $(LIB_H)
135 test-lexing.o: $(LIB_H)
136 test-parsing.o: $(LIB_H)
137 test-linearize.o: $(LIB_H)
138 test-dissect.o: $(LIB_H)
139 ctags.o: $(LIB_H)
140 compile.o: $(LIB_H) compile.h
141 compile-i386.o: $(LIB_H) compile.h
142 tokenize.o: $(LIB_H)
143 sparse.o: $(LIB_H)
144 obfuscate.o: $(LIB_H)
145 example.o: $(LIB_H)
146 storage.o: $(LIB_H)
147 dissect.o: $(LIB_H)
148 graph.o: $(LIB_H)
150 compat-linux.o: compat/strtold.c compat/mmap-blob.c \
151 $(LIB_H)
152 compat-solaris.o: compat/mmap-blob.c $(LIB_H)
153 compat-mingw.o: $(LIB_H)
154 compat-cygwin.o: $(LIB_H)
156 pre-process.h:
157 $(QUIET_GEN)echo "#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
159 .c.o:
160 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
162 clean: clean-check
163 rm -f *.[oasi] core core.[0-9]* $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc
165 dist:
166 @if test "`git describe`" != "$(VERSION)" ; then \
167 echo 'Update VERSION in the Makefile before running "make dist".' ; \
168 exit 1 ; \
170 git archive --format=tar --prefix=sparse-$(VERSION)/ HEAD^{tree} | gzip -9 > sparse-$(VERSION).tar.gz
172 check: all
173 $(Q)cd validation && ./test-suite
175 clean-check:
176 find validation/ -name "*.c.[egd]*" -exec rm {} \;