libxml compile fix on Cygwin
[smatch.git] / Makefile
blobf07290ea3fb04f0ffaf7906b599d148ba3d40052
1 VERSION=0.3
3 OS=linux
5 CC ?= gcc
6 CFLAGS ?= -O2 -finline-functions -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 INCLUDEDIR=$(PREFIX)/include
23 PKGCONFIGDIR=$(LIBDIR)/pkgconfig
25 PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example \
26 test-unssa test-dissect ctags
29 INST_PROGRAMS=sparse cgcc
31 ifeq ($(HAVE_LIBXML),yes)
32 PROGRAMS+=c2xml
33 INST_PROGRAMS+=c2xml
34 endif
36 LIB_H= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
37 linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
38 storage.h ptrlist.h dissect.h
40 LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
41 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
42 sort.o allocate.o compat-$(OS).o ptrlist.o \
43 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
45 LIB_FILE= libsparse.a
46 SLIB_FILE= libsparse.so
48 # If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
49 # Doing so incurs a noticeable performance hit, and Sparse does not have a
50 # stable shared library interface, so this does not occur by default. If you
51 # really want a shared library, you may want to build Sparse twice: once
52 # without -fpic to get all the Sparse tools, and again with -fpic to get the
53 # shared library.
54 LIBS=$(LIB_FILE)
57 # Pretty print
59 V = @
60 Q = $(V:1=)
61 QUIET_CC = $(Q:@=@echo ' CC '$@;)
62 QUIET_AR = $(Q:@=@echo ' AR '$@;)
63 QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
64 QUIET_LINK = $(Q:@=@echo ' LINK '$@;)
65 # We rely on the -v switch of install to print 'file -> $install_dir/file'
66 QUIET_INST_SH = $(Q:@=echo -n ' INSTALL ';)
67 QUIET_INST = $(Q:@=@echo -n ' INSTALL ';)
69 all: $(PROGRAMS) sparse.pc
71 install: $(INST_PROGRAMS) $(LIBS) $(LIB_H) sparse.pc
72 $(Q)install -d $(DESTDIR)$(BINDIR)
73 $(Q)install -d $(DESTDIR)$(LIBDIR)
74 $(Q)install -d $(DESTDIR)$(INCLUDEDIR)/sparse
75 $(Q)install -d $(DESTDIR)$(PKGCONFIGDIR)
76 $(Q)for f in $(INST_PROGRAMS); do \
77 $(QUIET_INST_SH)install -v $$f $(DESTDIR)$(BINDIR)/$$f || exit 1; \
78 done
79 $(Q)for f in $(LIBS); do \
80 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(LIBDIR)/$$f || exit 1; \
81 done
82 $(Q)for f in $(LIB_H); do \
83 $(QUIET_INST_SH)install -m 644 -v $$f $(DESTDIR)$(INCLUDEDIR)/sparse/$$f || exit 1; \
84 done
85 $(QUIET_INST)install -m 644 -v sparse.pc $(DESTDIR)$(PKGCONFIGDIR)/sparse.pc
87 sparse.pc: sparse.pc.in
88 $(QUIET_GEN)sed 's|@version@|$(VERSION)|g;s|@prefix@|$(PREFIX)|g;s|@libdir@|$(LIBDIR)|g;s|@includedir@|$(INCLUDEDIR)|g' sparse.pc.in > sparse.pc
90 test-lexing: test-lexing.o $(LIBS)
91 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
93 test-parsing: test-parsing.o $(LIBS)
94 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
96 test-linearize: test-linearize.o $(LIBS)
97 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
99 test-sort: test-sort.o $(LIBS)
100 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
102 compile: compile.o compile-i386.o $(LIBS)
103 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< compile-i386.o $(LIBS)
105 obfuscate: obfuscate.o $(LIBS)
106 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
108 sparse: sparse.o $(LIBS)
109 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
111 graph: graph.o $(LIBS)
112 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
114 example: example.o $(LIBS)
115 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
117 test-unssa: test-unssa.o $(LIBS)
118 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
120 test-dissect: test-dissect.o $(LIBS)
121 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
123 ctags: ctags.o $(LIBS)
124 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
126 c2xml: c2xml.o $(LIBS)
127 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $< $(LIBS) `pkg-config --libs libxml-2.0`
129 $(LIB_FILE): $(LIB_OBJS)
130 $(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
132 $(SLIB_FILE): $(LIB_OBJS)
133 $(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(LIB_OBJS)
135 evaluate.o: $(LIB_H)
136 expression.o: $(LIB_H)
137 lib.o: $(LIB_H)
138 allocate.o: $(LIB_H)
139 ptrlist.o: $(LIB_H)
140 parse.o: $(LIB_H)
141 pre-process.o: $(LIB_H) pre-process.h
142 scope.o: $(LIB_H)
143 show-parse.o: $(LIB_H)
144 symbol.o: $(LIB_H)
145 expand.o: $(LIB_H)
146 linearize.o: $(LIB_H)
147 flow.o: $(LIB_H)
148 cse.o: $(LIB_H)
149 simplify.o: $(LIB_H)
150 memops.o: $(LIB_H)
151 liveness.o: $(LIB_H)
152 sort.o: $(LIB_H)
153 inline.o: $(LIB_H)
154 target.o: $(LIB_H)
155 test-lexing.o: $(LIB_H)
156 test-parsing.o: $(LIB_H)
157 test-linearize.o: $(LIB_H)
158 test-dissect.o: $(LIB_H)
159 test-unssa.o: $(LIB_H)
160 ctags.o: $(LIB_H)
161 compile.o: $(LIB_H) compile.h
162 compile-i386.o: $(LIB_H) compile.h
163 tokenize.o: $(LIB_H)
164 sparse.o: $(LIB_H)
165 obfuscate.o: $(LIB_H)
166 example.o: $(LIB_H)
167 storage.o: $(LIB_H)
168 dissect.o: $(LIB_H)
169 graph.o: $(LIB_H)
171 c2xml.o: c2xml.c $(LIB_H)
172 $(QUIET_CC)$(CC) `pkg-config --cflags libxml-2.0` -o $@ -c $(CFLAGS) $<
174 compat-linux.o: compat/strtold.c compat/mmap-blob.c \
175 $(LIB_H)
176 compat-solaris.o: compat/mmap-blob.c $(LIB_H)
177 compat-mingw.o: $(LIB_H)
178 compat-cygwin.o: $(LIB_H)
180 pre-process.h:
181 $(QUIET_GEN)echo "#define GCC_INTERNAL_INCLUDE \"`$(CC) -print-file-name=include`\"" > pre-process.h
183 .c.o:
184 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
186 clean: clean-check
187 rm -f *.[oa] $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc
189 dist:
190 @if test "`git describe`" != "$(VERSION)" ; then \
191 echo 'Update VERSION in the Makefile before running "make dist".' ; \
192 exit 1 ; \
194 git archive --format=tar --prefix=sparse-$(VERSION)/ HEAD^{tree} | gzip -9 > sparse-$(VERSION).tar.gz
196 check: all
197 $(Q)cd validation && ./test-suite
199 clean-check:
200 find validation/ \( -name "*.c.output.expected" \
201 -o -name "*.c.output.got" \
202 -o -name "*.c.output.diff" \
203 -o -name "*.c.error.expected" \
204 -o -name "*.c.error.got" \
205 -o -name "*.c.error.diff" \
206 \) -exec rm {} \;