Add make export, separate make all from make deps
parent
a1c6b5381f
commit
168332e84a
57
Makefile
57
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 $</* -maxdepth 0 -type d \
|
||||
-printf "zip\t$@\t%f\n" \
|
||||
-exec zip -q -r $@ {} +
|
||||
|
||||
$(optionses): $(prefix)/%.options: ./%/target.options
|
||||
@echo "cp $< $@"
|
||||
@cp $< $@
|
||||
|
||||
$(targets): $(prefix)/%: ./%/target
|
||||
@echo "cp $< $@"
|
||||
@cp $< $@
|
||||
|
||||
$(dictionaries): $(prefix)/%: ./%
|
||||
@echo "cp $< $@"
|
||||
@cp $< $@
|
||||
|
||||
# cleanup
|
||||
|
||||
clean:
|
||||
@rm -f $(out)
|
||||
@echo "Cleaned!"
|
||||
spotless:
|
||||
@rm -rf $(fuzzer_dir) $(libFuzzer) $(new_clang) $(CC) $(CXX) $(out)
|
||||
@echo "Cleaned harder!"
|
||||
unexport:
|
||||
@rm -rf $(prefix)/*
|
||||
@echo "Un-exported!"
|
||||
|
|
Loading…
Reference in New Issue