OLD | NEW |
(Empty) | |
| 1 # |
| 2 # american fuzzy lop - makefile |
| 3 # ----------------------------- |
| 4 # |
| 5 # Written and maintained by Michal Zalewski <lcamtuf@google.com> |
| 6 # |
| 7 # Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved. |
| 8 # |
| 9 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 # you may not use this file except in compliance with the License. |
| 11 # You may obtain a copy of the License at: |
| 12 # |
| 13 # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 # |
| 15 |
| 16 PROGNAME = afl |
| 17 VERSION = 2.14b |
| 18 |
| 19 PREFIX ?= /usr/local |
| 20 BIN_PATH = $(PREFIX)/bin |
| 21 HELPER_PATH = $(PREFIX)/lib/afl |
| 22 DOC_PATH = $(PREFIX)/share/doc/afl |
| 23 MISC_PATH = $(PREFIX)/share/afl |
| 24 |
| 25 # PROGS intentionally omit afl-as, which gets installed to its own dir. |
| 26 |
| 27 PROGS = afl-gcc afl-fuzz afl-showmap afl-tmin afl-gotcpu afl-analyze |
| 28 SH_PROGS = afl-plot afl-cmin afl-whatsup |
| 29 |
| 30 CFLAGS ?= -O3 -funroll-loops |
| 31 CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \ |
| 32 -DAFL_PATH=\"$(HELPER_PATH)\" -DDOC_PATH=\"$(DOC_PATH)\" \ |
| 33 -DBIN_PATH=\"$(BIN_PATH)\" -DVERSION=\"$(VERSION)\" |
| 34 |
| 35 ifneq "$(filter Linux GNU%,$(shell uname))" "" |
| 36 LDFLAGS += -ldl |
| 37 endif |
| 38 |
| 39 ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" "" |
| 40 TEST_CC = afl-gcc |
| 41 else |
| 42 TEST_CC = afl-clang |
| 43 endif |
| 44 |
| 45 COMM_HDR = alloc-inl.h config.h debug.h types.h |
| 46 |
| 47 all: test_x86 $(PROGS) afl-as test_build all_done |
| 48 |
| 49 ifndef AFL_NO_X86 |
| 50 |
| 51 test_x86: |
| 52 @echo "[*] Checking for the ability to compile x86 code..." |
| 53 @echo 'main() { __asm__("xorb %al, %al"); }' | $(CC) -w -x c - -o .test
|| ( echo; echo "Oops, looks like your compiler can't generate x86 code."; echo;
echo "Don't panic! You can use the LLVM or QEMU mode, but see docs/INSTALL firs
t."; echo "(To ignore this error, set AFL_NO_X86=1 and try again.)"; echo; exit
1 ) |
| 54 @rm -f .test |
| 55 @echo "[+] Everything seems to be working, ready to compile." |
| 56 |
| 57 else |
| 58 |
| 59 test_x86: |
| 60 @echo "[!] Note: skipping x86 compilation checks (AFL_NO_X86 set)." |
| 61 |
| 62 endif |
| 63 |
| 64 afl-gcc: afl-gcc.c $(COMM_HDR) | test_x86 |
| 65 $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) |
| 66 set -e; for i in afl-g++ afl-clang afl-clang++; do ln -sf afl-gcc $$i; d
one |
| 67 |
| 68 afl-as: afl-as.c afl-as.h $(COMM_HDR) | test_x86 |
| 69 $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) |
| 70 ln -sf afl-as as |
| 71 |
| 72 afl-fuzz: afl-fuzz.c $(COMM_HDR) | test_x86 |
| 73 $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) |
| 74 |
| 75 afl-showmap: afl-showmap.c $(COMM_HDR) | test_x86 |
| 76 $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) |
| 77 |
| 78 afl-tmin: afl-tmin.c $(COMM_HDR) | test_x86 |
| 79 $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) |
| 80 |
| 81 afl-analyze: afl-analyze.c $(COMM_HDR) | test_x86 |
| 82 $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) |
| 83 |
| 84 afl-gotcpu: afl-gotcpu.c $(COMM_HDR) | test_x86 |
| 85 $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) |
| 86 |
| 87 ifndef AFL_NO_X86 |
| 88 |
| 89 test_build: afl-gcc afl-as afl-showmap |
| 90 @echo "[*] Testing the CC wrapper and instrumentation output..." |
| 91 unset AFL_USE_ASAN AFL_USE_MSAN; AFL_QUIET=1 AFL_INST_RATIO=100 AFL_PATH
=. ./$(TEST_CC) $(CFLAGS) test-instr.c -o test-instr $(LDFLAGS) |
| 92 echo 0 | ./afl-showmap -m none -q -o .test-instr0 ./test-instr |
| 93 echo 1 | ./afl-showmap -m none -q -o .test-instr1 ./test-instr |
| 94 @rm -f test-instr |
| 95 @cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-in
str1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not s
eem to be behaving correctly!"; echo; echo "Please ping <lcamtuf@google.com> to
troubleshoot the issue."; echo; exit 1; fi |
| 96 @echo "[+] All right, the instrumentation seems to be working!" |
| 97 |
| 98 else |
| 99 |
| 100 test_build: afl-gcc afl-as afl-showmap |
| 101 @echo "[!] Note: skipping build tests (you may need to use LLVM or QEMU
mode)." |
| 102 |
| 103 endif |
| 104 |
| 105 all_done: test_build |
| 106 @if [ ! "`which clang 2>/dev/null`" = "" ]; then echo "[+] LLVM users: s
ee llvm_mode/README.llvm for a faster alternative to afl-gcc."; fi |
| 107 @echo "[+] All done! Be sure to review README - it's pretty short and us
eful." |
| 108 @if [ "`uname`" = "Darwin" ]; then printf "\nWARNING: Fuzzing on MacOS X
is slow because of the unusually high overhead of\nfork() on this OS. Consider
using Linux or *BSD. You can also use VirtualBox\n(virtualbox.org) to put AFL in
side a Linux or *BSD VM.\n\n"; fi |
| 109 @! tty <&1 >/dev/null || printf "\033[0;30mNOTE: If you can read this, y
our terminal probably uses white background.\nThis will make the UI hard to read
. See docs/status_screen.txt for advice.\033[0m\n" 2>/dev/null |
| 110 |
| 111 .NOTPARALLEL: clean |
| 112 |
| 113 clean: |
| 114 rm -f $(PROGS) afl-as as afl-g++ afl-clang afl-clang++ *.o *~ a.out core
core.[1-9][0-9]* *.stackdump test .test test-instr .test-instr0 .test-instr1 qe
mu_mode/qemu-2.3.0.tar.bz2 afl-qemu-trace |
| 115 rm -rf out_dir qemu_mode/qemu-2.3.0 |
| 116 $(MAKE) -C llvm_mode clean |
| 117 |
| 118 install: all |
| 119 mkdir -p -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DEST
DIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH) |
| 120 rm -f $${DESTDIR}$(BIN_PATH)/afl-plot.sh |
| 121 install -m 755 $(PROGS) $(SH_PROGS) $${DESTDIR}$(BIN_PATH) |
| 122 rm -f $${DESTDIR}$(BIN_PATH)/afl-as |
| 123 if [ -f afl-qemu-trace ]; then install -m 755 afl-qemu-trace $${DESTDIR}
$(BIN_PATH); fi |
| 124 if [ -f afl-clang-fast -a -f afl-llvm-pass.so -a -f afl-llvm-rt.o ]; the
n set -e; install -m 755 afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang
-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 afl-llvm-pass.so a
fl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi |
| 125 if [ -f afl-llvm-rt-32.o ]; then set -e; install -m 755 afl-llvm-rt-32.o
$${DESTDIR}$(HELPER_PATH); fi |
| 126 if [ -f afl-llvm-rt-64.o ]; then set -e; install -m 755 afl-llvm-rt-64.o
$${DESTDIR}$(HELPER_PATH); fi |
| 127 set -e; for i in afl-g++ afl-clang afl-clang++; do ln -sf afl-gcc $${DES
TDIR}$(BIN_PATH)/$$i; done |
| 128 install -m 755 afl-as $${DESTDIR}$(HELPER_PATH) |
| 129 ln -sf afl-as $${DESTDIR}$(HELPER_PATH)/as |
| 130 install -m 644 docs/README docs/ChangeLog docs/*.txt $${DESTDIR}$(DOC_PA
TH) |
| 131 cp -r testcases/ $${DESTDIR}$(MISC_PATH) |
| 132 |
| 133 publish: clean |
| 134 test "`basename $$PWD`" = "afl" || exit 1 |
| 135 test -f ~/www/afl/releases/$(PROGNAME)-$(VERSION).tgz; if [ "$$?" = "0"
]; then echo; echo "Change program version in Makefile, mmkay?"; echo; exit 1; f
i |
| 136 cd ..; rm -rf $(PROGNAME)-$(VERSION); cp -pr $(PROGNAME) $(PROGNAME)-$(V
ERSION); \ |
| 137 tar -cvz -f ~/www/afl/releases/$(PROGNAME)-$(VERSION).tgz $(PROGNAME)-
$(VERSION) |
| 138 chmod 644 ~/www/afl/releases/$(PROGNAME)-$(VERSION).tgz |
| 139 ( cd ~/www/afl/releases/; ln -s -f $(PROGNAME)-$(VERSION).tgz $(PROGNAME
)-latest.tgz ) |
| 140 cat docs/README >~/www/afl/README.txt |
| 141 cat docs/status_screen.txt >~/www/afl/status_screen.txt |
| 142 cat docs/historical_notes.txt >~/www/afl/historical_notes.txt |
| 143 cat docs/technical_details.txt >~/www/afl/technical_details.txt |
| 144 cat docs/ChangeLog >~/www/afl/ChangeLog.txt |
| 145 cat docs/QuickStartGuide.txt >~/www/afl/QuickStartGuide.txt |
| 146 echo -n "$(VERSION)" >~/www/afl/version.txt |
OLD | NEW |