Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2018-2024 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. BIN=test.bin
  16. CFLAGS += -I../src -I../src/include
  17. CFLAGS += -DTEST
  18. CFLAGS += -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables -Wmissing-prototypes -Wshadow -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough
  19. CXXFLAGS += -g
  20. CXXFLAGS += -DTEST
  21. CXXFLAGS += -I./ -I../src -I../src/include
  22. OBJS_LIB=$(patsubst %.c,%.o,$(wildcard ../src/lib/*.c))
  23. OBJS_MAIN=$(patsubst %.c,%.o,$(wildcard ../src/*.c))
  24. OBJS = $(OBJS_LIB) $(OBJS_MAIN)
  25. TEST_SOURCES := $(wildcard *.cc) $(wildcard */*.cc) $(wildcard */*/*.cc)
  26. TEST_OBJECTS := $(patsubst %.cc, %.o, $(TEST_SOURCES))
  27. OBJS += $(TEST_OBJECTS)
  28. LDFLAGS += -lssl -lcrypto -lpthread -ldl -lgtest -lstdc++ -lm
  29. .PHONY: all clean test
  30. all: $(BIN)
  31. $(BIN) : $(OBJS)
  32. $(CC) $(OBJS) -o $@ $(LDFLAGS)
  33. test: $(BIN)
  34. ./$(BIN)
  35. clean:
  36. $(RM) $(OBJS) $(BIN)