2023-10-16 09:18:09 +00:00
|
|
|
HEADERS := scsl.h \
|
|
|
|
Arena.h \
|
|
|
|
Buffer.h \
|
|
|
|
Commander.h \
|
|
|
|
Dictionary.h \
|
|
|
|
Exceptions.h \
|
|
|
|
Flag.h \
|
|
|
|
StringUtil.h \
|
|
|
|
Test.h \
|
|
|
|
TLV.h \
|
|
|
|
WinHelpers.h
|
2023-10-06 03:13:46 +00:00
|
|
|
|
2023-10-16 09:18:09 +00:00
|
|
|
SOURCES := Arena.cc \
|
|
|
|
Buffer.cc \
|
|
|
|
Commander.cc \
|
|
|
|
Dictionary.cc \
|
|
|
|
Exceptions.cc \
|
|
|
|
Flag.cc \
|
|
|
|
StringUtil.cc \
|
|
|
|
Test.cc \
|
|
|
|
TLV.cc \
|
|
|
|
WinHelpers.cc
|
|
|
|
|
|
|
|
BUILD := DEBUG
|
|
|
|
OBJS := $(patsubst %.cc,%.o,$(SOURCES))
|
|
|
|
LIBS := libscsl.a
|
|
|
|
|
|
|
|
TARGETS := $(LIBS) phonebook
|
|
|
|
TESTS := bufferTest dictionaryTest flagTest tlvTest
|
2023-10-06 03:13:46 +00:00
|
|
|
CXX := clang++
|
2023-10-16 09:18:09 +00:00
|
|
|
CXXFLAGS := -std=c++14 -Werror -Wall -Wextra -DSCSL_DESKTOP_BUILD \
|
|
|
|
-DSCSL_BUILD_TYPE=${BUILD}
|
|
|
|
ifeq ($(BUILD),DEBUG)
|
|
|
|
CXXFLAGS += -g -fsanitize=address
|
|
|
|
else
|
|
|
|
CXXFLAGS += -O2
|
|
|
|
endif
|
2023-10-06 03:13:46 +00:00
|
|
|
|
|
|
|
.PHONY: all
|
2023-10-16 09:18:09 +00:00
|
|
|
all: $(TARGETS) $(TESTS) tags run-tests
|
2023-10-06 03:13:46 +00:00
|
|
|
|
|
|
|
tags: $(HEADERS) $(SOURCES)
|
|
|
|
ctags $(HEADERS) $(SOURCES)
|
|
|
|
|
2023-10-16 09:18:09 +00:00
|
|
|
libscsl.a: $(OBJS)
|
2023-10-06 03:13:46 +00:00
|
|
|
$(AR) rcs $@ $(OBJS)
|
|
|
|
|
|
|
|
.PHONY: print-%
|
|
|
|
print-%: ; @echo '$(subst ','\'',$*=$($*))'
|
|
|
|
|
|
|
|
klib.a: $(OBJS)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
# build outputs
|
2023-10-16 09:18:09 +00:00
|
|
|
rm -f $(TARGETS) $(TESTS) *.o
|
2023-10-06 03:13:46 +00:00
|
|
|
|
|
|
|
# test miscellaneous
|
|
|
|
rm -f core core.* tags arena_test.bin
|
|
|
|
|
|
|
|
.PHONY: run-tests
|
|
|
|
run-tests: $(TESTS)
|
|
|
|
for testbin in $(TESTS); \
|
|
|
|
do \
|
|
|
|
echo "./$${testbin}" ; \
|
|
|
|
./$${testbin}; \
|
|
|
|
done
|
2023-10-16 09:18:09 +00:00
|
|
|
|
|
|
|
phonebook: phonebook.o $(LIBS)
|
|
|
|
$(CXX) -o $@ $(CXXFLAGS) $@.o $(LIBS)
|
|
|
|
|
|
|
|
bufferTest: bufferTest.o $(LIBS)
|
|
|
|
$(CXX) -o $@ $(CXXFLAGS) $@.o $(LIBS)
|
|
|
|
|
|
|
|
dictionaryTest: dictionaryTest.o $(LIBS)
|
|
|
|
$(CXX) -o $@ $(CXXFLAGS) $@.o $(LIBS)
|
|
|
|
|
|
|
|
flagTest: flagTest.o $(LIBS)
|
|
|
|
$(CXX) -o $@ $(CXXFLAGS) $@.o $(LIBS)
|
|
|
|
|
|
|
|
tlvTest: tlvTest.o $(LIBS)
|
|
|
|
$(CXX) -o $@ $(CXXFLAGS) $@.o $(LIBS)
|
|
|
|
|
|
|
|
%.o: %.cc
|
|
|
|
$(CXX) -o $@ -c $(CXXFLAGS) $<
|
|
|
|
|