Makefile 816 Bytes
Newer Older
Peter Faber's avatar
Peter Faber committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
all: tokens

OBJS = tokens.o  

LLVMCONFIG = llvm-config-6.0
CPPFLAGS = -g `$(LLVMCONFIG) --cppflags` -std=c++11
LDFLAGS = `$(LLVMCONFIG) --ldflags` -rdynamic
LIBS = `$(LLVMCONFIG) --libs`

clean:
	$(RM) -rf tokens.cpp tokens.hpp tokens $(OBJS)

tokens.cpp: tokens.l
	flex --header-file=$(subst .cpp,.hpp,$@) -o $@ $^

tokens.hpp: tokens.cpp

%.o: %.cpp
	$(CXX) -c $(CPPFLAGS) -o $@ $<


tokens: $(OBJS)
	$(CXX) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)

test: tokens example.txt
	cat example.txt | ./$^

distclean: clean
	$(RM) -rf .depend ./tokens.cpp ./tokens.hpp

.PHONY: clean distclean

depend: .depend

.depend: tokens.cpp tokens.hpp
	$(CXX) `$(LLVMCONFIG) --cppflags` $(FLAGS) $(INCLUDE) -M *.cpp > .depend || true
	$(CXX) `$(LLVMCONFIG) --cppflags` $(FLAGS) $(INCLUDE) -M *.hpp >> .depend || true

-include .depend