1ifeq "" "$(LLVM_CONFIG)" 2 LLVM_CONFIG=llvm-config 3endif 4 5ifeq "$(shell uname -s)" "Darwin" 6 # On some odd MacOS system configurations, the Xcode sdk path is not set correctly 7 SDK_LD = -L$(shell xcrun --show-sdk-path)/usr/lib 8 LDFLAGS += $(SDK_LD) 9endif 10 11LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null) 12ifneq "" "$(LLVM_BINDIR)" 13 LLVM_BINDIR := $(LLVM_BINDIR)/ 14endif 15 16CFLAGS := -O3 -funroll-loops -g -fPIC 17 18all: libAFLDriver.a libAFLQemuDriver.a aflpp_qemu_driver_hook.so 19 20aflpp_driver.o: aflpp_driver.c 21 -$(LLVM_BINDIR)clang -I. -I../../include $(CFLAGS) -c aflpp_driver.c 22 23libAFLDriver.a: aflpp_driver.o 24 @ar rc libAFLDriver.a aflpp_driver.o 25 @cp -vf libAFLDriver.a ../../ 26 27debug: 28 $(LLVM_BINDIR)clang -Wno-deprecated -I../../include $(CFLAGS) -D_DEBUG=\"1\" -c -o afl-performance.o ../../src/afl-performance.c 29 $(LLVM_BINDIR)clang -I../../include -D_DEBUG=\"1\" -g -funroll-loops -c aflpp_driver.c 30 #$(LLVM_BINDIR)clang -S -emit-llvm -Wno-deprecated -I../../include $(CFLAGS) -D_DEBUG=\"1\" -c -o afl-performance.ll ../../src/afl-performance.c 31 #$(LLVM_BINDIR)clang -S -emit-llvm -I../../include -D_DEBUG=\"1\" -g -funroll-loops -c aflpp_driver.c 32 ar rc libAFLDriver.a afl-performance.o aflpp_driver.o 33 34aflpp_qemu_driver.o: aflpp_qemu_driver.c 35 -$(LLVM_BINDIR)clang $(CFLAGS) -O0 -funroll-loops -c aflpp_qemu_driver.c 36 37libAFLQemuDriver.a: aflpp_qemu_driver.o 38 @-ar rc libAFLQemuDriver.a aflpp_qemu_driver.o 39 @-cp -vf libAFLQemuDriver.a ../../ 40 41aflpp_qemu_driver_hook.so: aflpp_qemu_driver_hook.o 42 @-test -e aflpp_qemu_driver_hook.o && $(LLVM_BINDIR)clang $(LDFLAGS) -shared aflpp_qemu_driver_hook.o -o aflpp_qemu_driver_hook.so || echo "Note: Optional aflpp_qemu_driver_hook.so not built." 43 44aflpp_qemu_driver_hook.o: aflpp_qemu_driver_hook.c 45 @-test -e ../../qemu_mode/qemuafl/qemuafl/api.h && $(LLVM_BINDIR)clang $(CFLAGS) -funroll-loops -c aflpp_qemu_driver_hook.c || echo "Note: Optional aflpp_qemu_driver_hook.o not built." 46 47test: debug 48 #clang -S -emit-llvm -D_DEBUG=\"1\" -I../../include -Wl,--allow-multiple-definition -funroll-loops -o aflpp_driver_test.ll aflpp_driver_test.c 49 afl-clang-fast -D_DEBUG=\"1\" -I../../include -Wl,--allow-multiple-definition -funroll-loops -o aflpp_driver_test aflpp_driver_test.c libAFLDriver.a afl-performance.o 50 51clean: 52 rm -f *.o libAFLDriver*.a libAFLQemuDriver.a aflpp_qemu_driver_hook.so *~ core aflpp_driver_test 53