aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-27 00:09:13 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-27 00:09:13 -0500
commit0e8737b3afe1dc5410b45761b7c9e38e022292f6 (patch)
treecbf09a624981d9bb6ec79aea01aa19804a711c6f
parent038396b015badc97dc48a851a0e48979890cd06e (diff)
downloadwg2nd-0e8737b3afe1dc5410b45761b7c9e38e022292f6.tar.xz
wg2nd-0e8737b3afe1dc5410b45761b7c9e38e022292f6.zip
refactor objects to work in parallel to source, add addrsan
-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