Makefile 3.3 KB

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