Makefile 2.9 KB

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