Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2018-2025 Ruilin Peng (Nick) <[email protected]>.
  2. #
  3. # smartdns is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # smartdns is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. SMARTDNS_SRC_DIR=../src
  16. BIN=test.bin
  17. SMARTDNS_TEST_LIB=$(SMARTDNS_SRC_DIR)/libsmartdns-test.a
  18. CXXFLAGS += -g
  19. CXXFLAGS += -DTEST
  20. CXXFLAGS += -I./ -I../src -I../src/include
  21. CXXFLAGS += -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables
  22. TEST_SOURCES := $(wildcard *.cc) $(wildcard */*.cc) $(wildcard */*/*.cc)
  23. TEST_OBJECTS := $(patsubst %.cc, %.o, $(TEST_SOURCES))
  24. OBJS += $(TEST_OBJECTS)
  25. SMARTDNS_SRC_FILES := $(wildcard $(SMARTDNS_SRC_DIR)/*.c) $(wildcard $(SMARTDNS_SRC_DIR)/*.h) $(wildcard $(SMARTDNS_SRC_DIR)/lib/*.c)
  26. ifeq ($(filter -j,$(MAKEFLAGS)),)
  27. MAKEFLAGS += -j$(shell nproc)
  28. endif
  29. LDFLAGS += -lssl -lcrypto -lpthread -ldl -lgtest -lstdc++ -lm -rdynamic
  30. LDFLAGS += $(EXTRA_LDFLAGS)
  31. .PHONY: all clean test $(SMARTDNS_TEST_LIB)
  32. all: $(BIN)
  33. $(BIN) : $(OBJS) $(SMARTDNS_TEST_LIB)
  34. $(CC) $^ -o $@ $(LDFLAGS)
  35. test: $(BIN)
  36. ./$(BIN)
  37. $(SMARTDNS_TEST_LIB):
  38. $(MAKE) DEBUG=1 -C $(SMARTDNS_SRC_DIR) libsmartdns-test.a
  39. clean:
  40. $(RM) $(OBJS) $(BIN)
  41. $(MAKE) -C $(SMARTDNS_SRC_DIR) clean