Makefile 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. CXX = clang++
  2. CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion -Wshadow # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address
  3. PREFIX ?= $(shell brew --prefix)
  4. OPENSSL_DIR = $(PREFIX)/opt/openssl@3
  5. OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -L$(OPENSSL_DIR)/lib -lssl -lcrypto
  6. ifneq ($(OS), Windows_NT)
  7. UNAME_S := $(shell uname -s)
  8. ifeq ($(UNAME_S), Darwin)
  9. OPENSSL_SUPPORT += -DCPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN -framework CoreFoundation -framework Security
  10. endif
  11. endif
  12. ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz
  13. BROTLI_DIR = $(PREFIX)/opt/brotli
  14. BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec
  15. TEST_ARGS = gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) -pthread -lcurl
  16. # By default, use standalone_fuzz_target_runner.
  17. # This runner does no fuzzing, but simply executes the inputs
  18. # provided via parameters.
  19. # Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
  20. # to link the fuzzer(s) against a real fuzzing engine.
  21. # OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
  22. LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
  23. all : test test_split
  24. ./test
  25. proxy : test_proxy
  26. ./test_proxy
  27. test : test.cc include_httplib.cc ../httplib.h Makefile cert.pem
  28. $(CXX) -o $@ -I.. $(CXXFLAGS) test.cc include_httplib.cc $(TEST_ARGS)
  29. # Note: The intention of test_split is to verify that it works to compile and
  30. # link the split httplib.h, so there is normally no need to execute it.
  31. test_split : test.cc ../httplib.h httplib.cc Makefile cert.pem
  32. $(CXX) -o $@ $(CXXFLAGS) test.cc httplib.cc $(TEST_ARGS)
  33. check_abi:
  34. @./check-shared-library-abi-compatibility.sh
  35. test_proxy : test_proxy.cc ../httplib.h Makefile cert.pem
  36. $(CXX) -o $@ -I.. $(CXXFLAGS) test_proxy.cc $(TEST_ARGS)
  37. # Runs server_fuzzer.cc based on value of $(LIB_FUZZING_ENGINE).
  38. # Usage: make fuzz_test LIB_FUZZING_ENGINE=/path/to/libFuzzer
  39. fuzz_test: server_fuzzer
  40. ./server_fuzzer fuzzing/corpus/*
  41. # Fuzz target, so that you can choose which $(LIB_FUZZING_ENGINE) to use.
  42. server_fuzzer : fuzzing/server_fuzzer.cc ../httplib.h standalone_fuzz_target_runner.o
  43. $(CXX) -o $@ -I.. $(CXXFLAGS) $< $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread
  44. # Standalone fuzz runner, which just reads inputs from fuzzing/corpus/ dir and
  45. # feeds it to server_fuzzer.
  46. standalone_fuzz_target_runner.o : fuzzing/standalone_fuzz_target_runner.cpp
  47. $(CXX) -o $@ -I.. $(CXXFLAGS) -c $<
  48. httplib.cc : ../httplib.h
  49. python3 ../split.py -o .
  50. cert.pem:
  51. ./gen-certs.sh
  52. clean:
  53. rm -rf test test_split test_proxy server_fuzzer *.pem *.0 *.o *.1 *.srl httplib.h httplib.cc _build*