Makefile 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/[email protected]
  6. #OPENSSL_DIR = $(PREFIX)/opt/openssl@3
  7. OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -L$(OPENSSL_DIR)/lib -lssl -lcrypto
  8. ifneq ($(OS), Windows_NT)
  9. UNAME_S := $(shell uname -s)
  10. ifeq ($(UNAME_S), Darwin)
  11. OPENSSL_SUPPORT += -DCPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN -framework CoreFoundation -framework Security
  12. endif
  13. endif
  14. ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz
  15. BROTLI_DIR = $(PREFIX)/opt/brotli
  16. BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec
  17. TEST_ARGS = gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) -pthread
  18. # By default, use standalone_fuzz_target_runner.
  19. # This runner does no fuzzing, but simply executes the inputs
  20. # provided via parameters.
  21. # Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
  22. # to link the fuzzer(s) against a real fuzzing engine.
  23. # OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
  24. LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
  25. all : test test_split
  26. ./test
  27. proxy : test_proxy
  28. ./test_proxy
  29. test : test.cc include_httplib.cc ../httplib.h Makefile cert.pem
  30. $(CXX) -o $@ -I.. $(CXXFLAGS) test.cc include_httplib.cc $(TEST_ARGS)
  31. # Note: The intention of test_split is to verify that it works to compile and
  32. # link the split httplib.h, so there is normally no need to execute it.
  33. test_split : test.cc ../httplib.h httplib.cc Makefile cert.pem
  34. $(CXX) -o $@ $(CXXFLAGS) test.cc httplib.cc $(TEST_ARGS)
  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. openssl genrsa 2048 > key.pem
  52. openssl req -new -batch -config test.conf -key key.pem | openssl x509 -days 3650 -req -signkey key.pem > cert.pem
  53. openssl req -x509 -config test.conf -key key.pem -sha256 -days 3650 -nodes -out cert2.pem -extensions SAN
  54. openssl genrsa 2048 > rootCA.key.pem
  55. openssl req -x509 -new -batch -config test.rootCA.conf -key rootCA.key.pem -days 1024 > rootCA.cert.pem
  56. openssl genrsa 2048 > client.key.pem
  57. 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
  58. openssl genrsa -passout pass:test123! 2048 > key_encrypted.pem
  59. openssl req -new -batch -config test.conf -key key_encrypted.pem | openssl x509 -days 3650 -req -signkey key_encrypted.pem > cert_encrypted.pem
  60. #c_rehash .
  61. clean:
  62. rm -f test test_split test_proxy server_fuzzer *.pem *.0 *.o *.1 *.srl httplib.h httplib.cc