Makefile 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 = /usr/local
  4. #PREFIX = $(shell brew --prefix)
  5. OPENSSL_DIR = $(PREFIX)/opt/openssl@3
  6. OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -L$(OPENSSL_DIR)/lib -lssl -lcrypto
  7. ifneq ($(OS), Windows_NT)
  8. UNAME_S := $(shell uname -s)
  9. ifeq ($(UNAME_S), Darwin)
  10. OPENSSL_SUPPORT += -DCPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN -framework CoreFoundation -framework Security
  11. endif
  12. endif
  13. ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz
  14. BROTLI_DIR = $(PREFIX)/opt/brotli
  15. BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec
  16. TEST_ARGS = gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) -pthread
  17. # By default, use standalone_fuzz_target_runner.
  18. # This runner does no fuzzing, but simply executes the inputs
  19. # provided via parameters.
  20. # Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
  21. # to link the fuzzer(s) against a real fuzzing engine.
  22. # OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
  23. LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
  24. all : test test_split
  25. ./test
  26. proxy : test_proxy
  27. ./test_proxy
  28. test : test.cc include_httplib.cc ../httplib.h Makefile cert.pem
  29. $(CXX) -o $@ -I.. $(CXXFLAGS) test.cc include_httplib.cc $(TEST_ARGS)
  30. # Note: The intention of test_split is to verify that it works to compile and
  31. # link the split httplib.h, so there is normally no need to execute it.
  32. test_split : test.cc ../httplib.h httplib.cc Makefile cert.pem
  33. $(CXX) -o $@ $(CXXFLAGS) test.cc httplib.cc $(TEST_ARGS)
  34. test_proxy : test_proxy.cc ../httplib.h Makefile cert.pem
  35. $(CXX) -o $@ -I.. $(CXXFLAGS) test_proxy.cc $(TEST_ARGS)
  36. # Runs server_fuzzer.cc based on value of $(LIB_FUZZING_ENGINE).
  37. # Usage: make fuzz_test LIB_FUZZING_ENGINE=/path/to/libFuzzer
  38. fuzz_test: server_fuzzer
  39. ./server_fuzzer fuzzing/corpus/*
  40. # Fuzz target, so that you can choose which $(LIB_FUZZING_ENGINE) to use.
  41. server_fuzzer : fuzzing/server_fuzzer.cc ../httplib.h standalone_fuzz_target_runner.o
  42. $(CXX) -o $@ -I.. $(CXXFLAGS) $< $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread
  43. # Standalone fuzz runner, which just reads inputs from fuzzing/corpus/ dir and
  44. # feeds it to server_fuzzer.
  45. standalone_fuzz_target_runner.o : fuzzing/standalone_fuzz_target_runner.cpp
  46. $(CXX) -o $@ -I.. $(CXXFLAGS) -c $<
  47. httplib.cc : ../httplib.h
  48. python3 ../split.py -o .
  49. cert.pem:
  50. openssl genrsa 2048 > key.pem
  51. openssl req -new -batch -config test.conf -key key.pem | openssl x509 -days 3650 -req -signkey key.pem > cert.pem
  52. openssl req -x509 -config test.conf -key key.pem -sha256 -days 3650 -nodes -out cert2.pem -extensions SAN
  53. openssl genrsa 2048 > rootCA.key.pem
  54. openssl req -x509 -new -batch -config test.rootCA.conf -key rootCA.key.pem -days 1024 > rootCA.cert.pem
  55. openssl genrsa 2048 > client.key.pem
  56. openssl req -new -batch -config test.conf -key client.key.pem | openssl x509 -days 370 -req -CA rootCA.cert.pem -CAkey rootCA.key.pem -CAcreateserial > client.cert.pem
  57. openssl genrsa -passout pass:test123! 2048 > key_encrypted.pem
  58. openssl req -new -batch -config test.conf -key key_encrypted.pem | openssl x509 -days 3650 -req -signkey key_encrypted.pem > cert_encrypted.pem
  59. #c_rehash .
  60. clean:
  61. rm -f test test_split test_proxy server_fuzzer *.pem *.0 *.o *.1 *.srl httplib.h httplib.cc