-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.linux
43 lines (29 loc) · 876 Bytes
/
Makefile.linux
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
41
42
43
.PHONY: all clean opt
TARGET = impossible
CC := gcc
CXX := g++
INCLUDE =
all: CFLAGS = $(INCLUDE) -std=c++11
opt: CFLAGS = $(INCLUDE) -O3 -ffast-math -pipe -std=c++11
CXXFLAGS = $(CFLAGS)
LDFLAGS =
# Find all source files
SOURCE = .
SRC_CPP = $(foreach dir, $(SOURCE), $(wildcard $(dir)/*.cpp)) impossible.tab.cpp
SRC_C = $(foreach dir, $(SOURCE), $(wildcard $(dir)/*.c)) lex.yy.c
OBJ_CPP = $(patsubst %.cpp, %.o, $(SRC_CPP))
OBJ_C = $(patsubst %.c, %.o, $(SRC_C))
OBJS = $(OBJ_CPP) $(OBJ_C)
all opt : $(TARGET)
lex.yy.c: parser/impossible.l
flex --header-file=lex.yy.h $<
impossible.tab.cpp: parser/impossible.ypp lex.yy.c
bison -d -v $<
$(TARGET) : $(OBJS)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
%.o: %.c
$(CC) -x c++ $(CFLAGS) -c $< -o $@
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -f $(OBJS) $(TARGET) lex.yy.* impossible.tab.*