xref: /freebsd/crypto/openssh/regress/misc/fuzz-harness/Makefile (revision a91a246563dffa876a52f53a98de4af9fa364c52)
14f52dfbbSDag-Erling Smørgrav# NB. libssh and libopenbsd-compat should be built with the same sanitizer opts.
2*a91a2465SEd MasteCC=clang-16
3*a91a2465SEd MasteCXX=clang++-16
419261079SEd MasteFUZZ_FLAGS=-fsanitize=address,fuzzer -fno-omit-frame-pointer
5*a91a2465SEd MasteFUZZ_LIBS=-L/usr/lib/llvm-16/lib -lFuzzer
64f52dfbbSDag-Erling Smørgrav
7*a91a2465SEd MasteCXXFLAGS=-O2 -g -Wall -Wextra -Wno-unused-parameter -Wno-exceptions -I ../../.. $(FUZZ_FLAGS)
819261079SEd MasteCFLAGS=$(CXXFLAGS)
94f52dfbbSDag-Erling SmørgravLDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS)
101323ec57SEd MasteLIBS=-lssh -lopenbsd-compat -lmd -lcrypto -lfido2 -lcbor $(FUZZ_LIBS)
1119261079SEd MasteSK_NULL_OBJS=ssh-sk-null.o
1219261079SEd MasteCOMMON_DEPS=../../../libssh.a
134f52dfbbSDag-Erling Smørgrav
1438a52bd3SEd MasteTARGETS=pubkey_fuzz sig_fuzz authopt_fuzz authkeys_fuzz sshsig_fuzz \
1519261079SEd Maste	sshsigopt_fuzz privkey_fuzz kex_fuzz agent_fuzz
1619261079SEd Maste
1719261079SEd Masteall: $(TARGETS)
184f52dfbbSDag-Erling Smørgrav
194f52dfbbSDag-Erling Smørgrav.cc.o:
204f52dfbbSDag-Erling Smørgrav	$(CXX) $(CXXFLAGS) -c $< -o $@
214f52dfbbSDag-Erling Smørgrav
2219261079SEd Mastepubkey_fuzz: pubkey_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
2319261079SEd Maste	$(CXX) -o $@ pubkey_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS)
244f52dfbbSDag-Erling Smørgrav
2519261079SEd Mastesig_fuzz: sig_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
2619261079SEd Maste	$(CXX) -o $@ sig_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS)
274f52dfbbSDag-Erling Smørgrav
2819261079SEd Masteauthopt_fuzz: authopt_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
2919261079SEd Maste	$(CXX) -o $@ authopt_fuzz.o $(SK_NULL_OBJS) ../../../auth-options.o $(LDFLAGS) $(LIBS)
3019261079SEd Maste
3138a52bd3SEd Masteauthkeys_fuzz: authkeys_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
3238a52bd3SEd Maste	$(CXX) -o $@ authkeys_fuzz.o $(SK_NULL_OBJS) ../../../auth-options.o ../../../auth2-pubkeyfile.o $(LDFLAGS) $(LIBS)
3338a52bd3SEd Maste
3419261079SEd Mastesshsig_fuzz: sshsig_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
3519261079SEd Maste	$(CXX) -o $@ sshsig_fuzz.o $(SK_NULL_OBJS) ../../../sshsig.o $(LDFLAGS) $(LIBS)
3619261079SEd Maste
3719261079SEd Mastesshsigopt_fuzz: sshsigopt_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
3819261079SEd Maste	$(CXX) -o $@ sshsigopt_fuzz.o $(SK_NULL_OBJS) ../../../sshsig.o $(LDFLAGS) $(LIBS)
3919261079SEd Maste
4019261079SEd Masteprivkey_fuzz: privkey_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
4119261079SEd Maste	$(CXX) -o $@ privkey_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS)
4219261079SEd Maste
4319261079SEd Mastekex_fuzz: kex_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
4419261079SEd Maste	$(CXX) -o $@ kex_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS) -lz
4519261079SEd Maste
4619261079SEd Masteagent_fuzz: agent_fuzz.o agent_fuzz_helper.o sk-dummy.o ../../../ssh-sk.o $(COMMON_DEPS)
4719261079SEd Maste	$(CXX) -o $@ agent_fuzz.o agent_fuzz_helper.o sk-dummy.o ../../../ssh-sk.o $(LDFLAGS) $(LIBS) -lz
4819261079SEd Maste
4919261079SEd Masteagent_fuzz_helper.o: agent_fuzz_helper.c ../../../ssh-agent.c
5019261079SEd Maste
5119261079SEd Mastesk-dummy.o: ../sk-dummy/sk-dummy.c
5219261079SEd Maste	$(CC) $(CFLAGS) -c -o $@ ../sk-dummy/sk-dummy.c -DSK_DUMMY_INTEGRATE=1 $(LDFLAGS)
532f513db7SEd Maste
544f52dfbbSDag-Erling Smørgravclean:
5519261079SEd Maste	-rm -f *.o $(TARGETS)
56