Skip to content

Commit f2fd901

Browse files
committed
Update buildflags
1 parent 988f1ae commit f2fd901

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Makefile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
CXX = g++
2-
CXXFLAGS = -Wall -O2 -std=c++11 -pthread -Iinclude
3-
LDFLAGS = -pthread
1+
CXX ?= g++
2+
CXXFLAGS ?= -Wall -O2
3+
CXXFLAGS += -std=c++11 -pthread -Iinclude
4+
LDFLAGS += -pthread
5+
CPPFLAGS ?=
46
PREFIX = /usr
57
BINDIR = $(PREFIX)/bin
68

79
# Extract version from debian/changelog
810
VERSION := $(shell head -1 debian/changelog | sed -n 's/.*([^)]*\([0-9][0-9.]*\)).*/\1/p')
9-
CXXFLAGS += -DVERSION="\"$(VERSION)\""
11+
CPPFLAGS += -DVERSION="\"$(VERSION)\""
1012

1113
# Coverage flags (set COVERAGE=1 to enable)
1214
ifdef COVERAGE
@@ -29,20 +31,20 @@ all: $(TARGET)
2931

3032
# Build library objects
3133
%.o: %.cpp
32-
$(CXX) $(CXXFLAGS) -c $< -o $@
34+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
3335

3436
# Build main application
3537
$(TARGET): $(LIB_OBJECTS) $(SOURCES)
36-
$(CXX) $(CXXFLAGS) -o $(TARGET) $(SOURCES) $(LIB_OBJECTS) $(LDFLAGS)
38+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TARGET) $(SOURCES) $(LIB_OBJECTS) $(LDFLAGS)
3739

3840
# Build and run tests
3941
test: $(LIB_OBJECTS)
4042
@echo "Building and running unit tests..."
41-
@$(CXX) $(CXXFLAGS) tests/test_csv_parser.cpp src/csv_parser.o -o test_csv_parser && ./test_csv_parser
42-
@$(CXX) $(CXXFLAGS) tests/test_json_parser.cpp src/json_parser.o -o test_json_parser && ./test_json_parser
43-
@$(CXX) $(CXXFLAGS) tests/test_error_detector.cpp src/error_detector.o -o test_error_detector && ./test_error_detector
44-
@$(CXX) $(CXXFLAGS) tests/test_file_utils.cpp src/file_utils.o -o test_file_utils && ./test_file_utils
45-
@$(CXX) $(CXXFLAGS) tests/test_date_utils.cpp -o test_date_utils && ./test_date_utils
43+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_csv_parser.cpp src/csv_parser.o -o test_csv_parser $(LDFLAGS) && ./test_csv_parser
44+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_json_parser.cpp src/json_parser.o -o test_json_parser $(LDFLAGS) && ./test_json_parser
45+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_error_detector.cpp src/error_detector.o -o test_error_detector $(LDFLAGS) && ./test_error_detector
46+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_file_utils.cpp src/file_utils.o -o test_file_utils $(LDFLAGS) && ./test_file_utils
47+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_date_utils.cpp -o test_date_utils $(LDFLAGS) && ./test_date_utils
4648
@echo "All unit tests passed!"
4749

4850
# Run integration tests (requires bash)

0 commit comments

Comments
 (0)