11# CXX = clang++
2- CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion # -fsanitize=address
2+ CXXFLAGS = -g -std=c++11 -I. -I.. - Wall -Wextra -Wtype-limits -Wconversion # -fsanitize=address
33
44OPENSSL_DIR = /usr/local/opt/
[email protected] 55OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR ) /include -L$(OPENSSL_DIR ) /lib -lssl -lcrypto
@@ -11,22 +11,44 @@ BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_
1111
1212TEST_ARGS = gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT ) $(ZLIB_SUPPORT ) $(BROTLI_SUPPORT ) -pthread
1313
14+ # By default, use standalone_fuzz_target_runner.
15+ # This runner does no fuzzing, but simply executes the inputs
16+ # provided via parameters.
17+ # Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
18+ # to link the fuzzer(s) against a real fuzzing engine.
19+ # OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
20+ LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
21+
1422all : test test_split
1523 ./test
16- # Note: The intention of test_split is to verify that it works to compile and
17- # link the split httplib.h, so there is normally no need to execute it.
1824
1925proxy : test_proxy
2026 ./test_proxy
2127
2228test : test.cc include_httplib.cc ../httplib.h Makefile cert.pem
23- $(CXX ) -o $@ -I.. $(CXXFLAGS ) test.cc include_httplib.cc $(TEST_ARGS )
29+ $(CXX ) -o $@ $(CXXFLAGS ) test.cc include_httplib.cc $(TEST_ARGS )
2430
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.
2533test_split : test.cc ../httplib.h httplib.cc Makefile cert.pem
2634 $(CXX ) -o $@ $(CXXFLAGS ) test.cc httplib.cc $(TEST_ARGS )
2735
2836test_proxy : test_proxy.cc ../httplib.h Makefile cert.pem
29- $(CXX ) -o $@ -I.. $(CXXFLAGS ) test_proxy.cc $(TEST_ARGS )
37+ $(CXX ) -o $@ $(CXXFLAGS ) test_proxy.cc $(TEST_ARGS )
38+
39+ # Runs server_fuzzer.cc based on value of $(LIB_FUZZING_ENGINE).
40+ # Usage: make fuzz_test LIB_FUZZING_ENGINE=/path/to/libFuzzer
41+ fuzz_test : server_fuzzer
42+ ./server_fuzzer fuzzing/corpus/*
43+
44+ # Fuzz target, so that you can choose which $(LIB_FUZZING_ENGINE) to use.
45+ server_fuzzer : fuzzing/server_fuzzer.cc ../httplib.h standalone_fuzz_target_runner.o
46+ $(CXX ) $(CXXFLAGS ) -o $@ $< $(OPENSSL_SUPPORT ) $(ZLIB_SUPPORT ) $(BROTLI_SUPPORT ) $(LIB_FUZZING_ENGINE ) -pthread
47+
48+ # Standalone fuzz runner, which just reads inputs from fuzzing/corpus/ dir and
49+ # feeds it to server_fuzzer.
50+ standalone_fuzz_target_runner.o : fuzzing/standalone_fuzz_target_runner.cpp
51+ $(CXX ) $(CXXFLAGS ) -c -o $@ $<
3052
3153httplib.cc : ../httplib.h
3254 python3 ../split.py -o .
@@ -42,4 +64,4 @@ cert.pem:
4264 # c_rehash .
4365
4466clean :
45- rm -f test test_proxy pem * .0 * .1 * .srl httplib.h httplib.cc
67+ rm -f test test_proxy server_fuzzer pem * .0 * .o * .1 * .srl httplib.h httplib.cc
0 commit comments