diff --git a/Makefile b/Makefile index c22622a..4bdc12c 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ LDLIBS = -lwolfssl -lFuzzer PYTHON = python2 +prefix = ./out + libFuzzer = libFuzzer.a fuzzer_dir = Fuzzer fuzzer_src = https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer @@ -19,15 +21,31 @@ clang_dir = $(new_clang)/clang/clang clang_tool = $(clang_dir)/scripts/update.py clang_bin = $(new_clang)/third_party/llvm-build/Release+Asserts/bin/ -src = $(wildcard */target.c) -out = $(patsubst %.c,%,$(src)) +src = $(wildcard ./*/target.c) +opt = $(wildcard ./*/target.options) +trg = $(notdir $(src:/target.c=)) +trg_opt = $(notdir $(opt:/target.options=)) +obj = $(src:.c=.o) +out = $(src:.c=) -all: deps $(out) # make all +targets = $(patsubst %,$(prefix)/%, $(trg)) +corpi = $(patsubst %,$(prefix)/%_seed_corpus.zip,$(trg)) +optionses = $(patsubst %,$(prefix)/%.options, $(trg_opt)) + +found_dictionaries = $(wildcard ./*.dict) +dictionaries = $(addprefix $(prefix)/,$(notdir $(found_dictionaries))) + +exports = $(targets) $(corpi) $(optionses) $(dictionaries) + +all: $(out) # make all +export: $(prefix) $(exports) # not quite install, but close deps: $(CC) $(CXX) $(libFuzzer) # dependencies dependencies: deps # deps alias %: %.c # cancel the implicit rule %: %.cc # cancel the implicit rule -.PHONY: clean spotless # .PHONYs + +.PHONY: clean spotless export unexport +.INTERMEDIATE: $(obj) $(fuzzer_dir) @@ -66,17 +84,44 @@ $(CXX): $(clang_bin)/$(CXX) # actual source code -%.o: %.c +$(obj): %.o: %.c @echo "CC $< -o $@" @$(CC) -c $< $(CFLAGS) -o $@ -%: %.o +$(out): %: %.o @echo "C++ $< -o $@" @$(CXX) $< $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ +# export + +$(prefix): + @mkdir -p $(prefix) + +$(corpi): $(prefix)/%_seed_corpus.zip: ./% + @find $