aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-13 17:59:52 +0800
committerTeddy <[email protected]>2013-08-13 17:59:52 +0800
commit5fe2cc5264b28726a6a43e2141d252caa66d37f9 (patch)
tree0010dfc045c7ac1e92cfc444768d714c390c8a89
parente828a57eba62ff2469c894d3e50ecc58f36d810b (diff)
new version Makefile
-rw-r--r--Makefile39
1 files changed, 30 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 48e2d8e..50b7f45 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,39 @@
-sonsi: main.o parser.o builtin.o model.o eval.o exc.o consts.o types.o gc.o
- g++ -o sonsi $^ -pg -lgmp
+CXX = g++ -DGMP_SUPPORT
+BUILD_DIR = build
-.cpp.o:
- g++ $< -c -g -DGMP_SUPPORT -Wall -DGC_INFO
+all: release
+debug: CXX += -g -pg
+gc_debug: CXX += -DGC_INFO -DGC_DEBUG -g -pg
+
+release: $(BUILD_DIR) $(BUILD_DIR)/sonsi
+debug: $(BUILD_DIR) $(BUILD_DIR)/sonsi
+gc_debug: $(BUILD_DIR) $(BUILD_DIR)/sonsi
+
+_OBJS = main.o \
+ parser.o builtin.o \
+ model.o eval.o exc.o \
+ consts.o types.o gc.o
+
+
+OBJS = $(patsubst %, $(BUILD_DIR)/%, $(_OBJS))
+
+$(BUILD_DIR)/sonsi: $(OBJS)
+ $(CXX) -o $(BUILD_DIR)/sonsi $^ -lgmp
+
+$(BUILD_DIR):
+ mkdir -p $(BUILD_DIR)
+
+$(BUILD_DIR)/%.o : %.cpp
+ $(CXX) -o $@ -c $< -Wall -O2
clean:
- rm -f *.o
- rm -f sonsi
+ rm -rf $(BUILD_DIR)
db:
- gdb sonsi
+ gdb $(BUILD_DIR)/sonsi
cdb:
- cgdb sonsi
+ cgdb $(BUILD_DIR)/sonsi
run:
- ./sonsi
+ ./$(BUILD_DIR)/sonsi