Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. TEST_SOURCES := $(wildcard *.cc) $(wildcard */*.cc) $(wildcard */*/*.cc)
  22. TEST_OBJECTS := $(patsubst %.cc, %.o, $(TEST_SOURCES))
  23. OBJS += $(TEST_OBJECTS)
  24. SMARTDNS_SRC_FILES := $(wildcard $(SMARTDNS_SRC_DIR)/*.c) $(wildcard $(SMARTDNS_SRC_DIR)/*.h) $(wildcard $(SMARTDNS_SRC_DIR)/lib/*.c)
  25. LDFLAGS += -lssl -lcrypto -lpthread -ldl -lgtest -lstdc++ -lm
  26. LDFLAGS += $(EXTRA_LDFLAGS)
  27. .PHONY: all clean test $(SMARTDNS_TEST_LIB)
  28. all: $(BIN)
  29. $(BIN) : $(OBJS) $(SMARTDNS_TEST_LIB)
  30. $(CC) $^ -o $@ $(LDFLAGS)
  31. test: $(BIN)
  32. ./$(BIN)
  33. $(SMARTDNS_TEST_LIB):
  34. $(MAKE) -C $(SMARTDNS_SRC_DIR) libsmartdns-test.a
  35. clean:
  36. $(RM) $(OBJS) $(BIN)
  37. $(MAKE) -C $(SMARTDNS_SRC_DIR) clean