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 11ifeq "" "$(LLVM_CONFIG)" 12 LLVM_CONFIG := llvm-config 13endif 14LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null) 15ifneq "" "$(LLVM_BINDIR)" 16 ifeq "$(shell test -x $(LLVM_BINDIR)/clang && echo 1)" "1" 17 CC := $(LLVM_BINDIR)/clang 18 endif 19endif 20 21CFLAGS := -O3 -funroll-loops -g -fPIC 22 23all: libAFLDriver.a libAFLQemuDriver.a aflpp_qemu_driver_hook.so 24 25aflpp_driver.o: aflpp_driver.c 26 -$(CC) -I. -I../../include $(CFLAGS) -c aflpp_driver.c 27 28libAFLDriver.a: aflpp_driver.o 29 @ar rc libAFLDriver.a aflpp_driver.o 30 @cp -vf libAFLDriver.a ../../ 31 32debug: 33 $(CC) -Wno-deprecated -I../../include $(CFLAGS) -D_DEBUG=\"1\" -c -o afl-performance.o ../../src/afl-performance.c 34 $(CC) -I../../include -D_DEBUG=\"1\" -g -funroll-loops -c aflpp_driver.c 35 #$(CC) -S -emit-llvm -Wno-deprecated -I../../include $(CFLAGS) -D_DEBUG=\"1\" -c -o afl-performance.ll ../../src/afl-performance.c 36 #$(CC) -S -emit-llvm -I../../include -D_DEBUG=\"1\" -g -funroll-loops -c aflpp_driver.c 37 ar rc libAFLDriver.a afl-performance.o aflpp_driver.o 38 39aflpp_qemu_driver.o: aflpp_qemu_driver.c 40 -$(CC) $(CFLAGS) -O0 -funroll-loops -c aflpp_qemu_driver.c 41 42libAFLQemuDriver.a: aflpp_qemu_driver.o 43 @-ar rc libAFLQemuDriver.a aflpp_qemu_driver.o 44 @-cp -vf libAFLQemuDriver.a ../../ 45 46aflpp_qemu_driver_hook.so: aflpp_qemu_driver_hook.o 47 @-test -e aflpp_qemu_driver_hook.o && $(CC) $(LDFLAGS) -shared aflpp_qemu_driver_hook.o -o aflpp_qemu_driver_hook.so || echo "Note: Optional aflpp_qemu_driver_hook.so not built." 48 49aflpp_qemu_driver_hook.o: aflpp_qemu_driver_hook.c 50 @-test -e ../../qemu_mode/qemuafl/qemuafl/api.h && $(CC) $(CFLAGS) -funroll-loops -c aflpp_qemu_driver_hook.c || echo "Note: Optional aflpp_qemu_driver_hook.o not built." 51 52test: debug 53 #clang -S -emit-llvm -D_DEBUG=\"1\" -I../../include -Wl,--allow-multiple-definition -funroll-loops -o aflpp_driver_test.ll aflpp_driver_test.c 54 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 55 56clean: 57 rm -f *.o libAFLDriver*.a libAFLQemuDriver.a aflpp_qemu_driver_hook.so *~ core aflpp_driver_test 58