aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefile23
1 files changed, 7 insertions, 16 deletions
diff --git a/makefile b/makefile
index 364ff87..eb34c1b 100644
--- a/makefile
+++ b/makefile
@@ -22,7 +22,7 @@ RELEASE_FLAGS = -O3
RELEASE_LDFLAGS = -lrt
# Debug flags
-DEBUGFLAGS = -ggdb -O0
+DEBUGFLAGS = -ggdb -O0 -fsanitize=address -fno-omit-frame-pointer
# Linking flags
LDFLAGS =
@@ -33,8 +33,7 @@ C_OBJECTS += src/crypto/halfsiphash.o
C_OBJECTS += src/crypto/pubkey.o
# Object files
-OBJECTS := wg2nd.o
-OBJECTS += main.o
+OBJECTS := src/wg2nd.o
# Source directory
SRC_DIR = src
@@ -45,10 +44,6 @@ TEST_TARGETS := $(patsubst $(TEST_DIR)/%.cpp, $(TEST_DIR)/%, $(TEST_FILES))
SRC_FILES := $(patsubst %.o,$(SRC_DIR)/%.cpp,$(OBJECTS))
-# Object directory
-OBJ_DIR = obj
-DEBUG_OBJ_DIR = obj/debug
-
# Target executable
CMD = wg2nd
@@ -63,25 +58,21 @@ targets: $(CMD)
tests: $(TEST_TARGETS)
debug: CXXFLAGS += $(DEBUGFLAGS)
-debug: OBJ_DIR = $(DEBUG_OBJ_DIR)
+debug: CFLAGS += $(DEBUGFLAGS)
debug: tests targets
-$(CMD): $(addprefix $(OBJ_DIR)/, $(OBJECTS)) $(C_OBJECTS)
+$(CMD): $(OBJECTS) $(C_OBJECTS) src/main.cpp
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
-$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
+$(OBJECTS): %.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
$(C_OBJECTS): %.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
-
-$(TEST_DIR)/%: $(TEST_DIR)/%.cpp $(addprefix $(OBJ_DIR)/, wg2nd.o) | $(OBJ_DIR)
+$(TEST_DIR)/%: $(TEST_DIR)/%.cpp $(OBJECTS) $(C_OBJECTS)
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
-$(OBJ_DIR) $(DEBUG_OBJ_DIR):
- mkdir -p $@
-
install:
mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR)/
install -m 755 $(CMD) $(DESTDIR)$(PREFIX)$(BINDIR)/
@@ -91,7 +82,7 @@ uninstall:
# Clean rule
clean:
- rm -rf $(OBJ_DIR) $(DEBUG_OBJ_DIR) $(TARGET) $(TEST_TARGETS) $(C_OBJECTS) $(CMD)
+ rm -rf $(TARGET) $(TEST_TARGETS) $(C_OBJECTS) $(OBJECTS) $(CMD)
.PHONY: install uninstall all clean targets tests