-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (42 loc) · 1.71 KB
/
Makefile
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
44
45
46
47
48
49
50
51
52
# ----------------------------------------------------------------------
EXE :=example
EXE_SRCS :=$(wildcard *.cpp) $(wildcard *.knucpp)
SHLIB :=
SHLIB_SRCS :=
# Useful KNUCC Flags:
# -v Run in verbose mode to display individual steps
# -k Keep intermediate files for examination/debugging
# --show-disassembly Show disassembly output during compilation
# --gen-disassembly Generate '.os' disassembly files during compilation
# --gen-assembly Generate .s assembly language files, which can
# later be processed by an assembler.
KNUCC_FLAGS :=
# ----------------------------------------------------------------------
EXE_OBJS :=$(addsuffix .o,$(basename $(EXE_SRCS)))
SHLIB_OBJS :=$(addsuffix .o,$(basename $(SHLIB_SRCS)))
TEMPFILES :=$(addsuffix .*, $(wildcard *.knuc))
KNUPATH_INSTALL:=/opt/knupath
KNUCC :=$(KNUPATH_INSTALL)/bin/knucc
CPPFLAGS :=-I$(KNUPATH_INSTALL)/include \
-I$(KNUPATH_INSTALL)/include/kpi
# Compile shared library sources with the position independent code
# flag
CXXFLAGS :=-std=c++11 -fPIC
LDFLAGS :=-L$(KNUPATH_INSTALL)/lib -Wl,-rpath,$(KNUPATH_INSTALL)/lib -Wl,-rpath,$(shell pwd)
LDLIBS :=-lprotobuf -lpthread -lkpirt
.PHONY: all clean
all: $(EXE) $(SHLIB)
run:
./$(EXE)
clean:
rm -rf $(EXE) $(SHLIB) $(EXE_OBJS) $(SHLIB_OBJS) $(TEMPFILES)
%.o : %.knuc
$(KNUCC) $(KNUCC_FLAGS) -c -o $@ $<
%.o : %.knucpp
$(KNUCC) $(KNUCC_FLAGS) -c -o $@ $<
%.o : %.knucxx
$(KNUCC) $(KNUCC_FLAGS) -c -o $@ $<
$(SHLIB) : $(SHLIB_OBJS)
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
$(EXE) : $(EXE_OBJS) $(SHLIB)
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)