From 6e98b3ebb2ba6adb58fe06226f90d4d0c9430b0d Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Sat, 16 May 2020 12:15:03 +0200 Subject: non GNU Makefiles: message when gmake is not found, gcc_plugin portability --- gcc_plugin/Makefile | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'gcc_plugin') diff --git a/gcc_plugin/Makefile b/gcc_plugin/Makefile index e81924e0..7eff326a 100644 --- a/gcc_plugin/Makefile +++ b/gcc_plugin/Makefile @@ -35,11 +35,11 @@ CFLAGS = -Wall -I../include -Wno-pointer-sign \ -DGCC_VERSION=\"$(GCCVER)\" -DGCC_BINDIR=\"$(GCCBINDIR)\" \ -Wno-unused-function -CXXFLAGS ?= -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2 +CXXFLAGS = -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2 CXXEFLAGS = $(CXXFLAGS) -Wall -CC ?= gcc -CXX ?= g++ +CC = gcc +CXX = g++ MYCC=$(CC:clang=gcc) MYCXX=$(CXX:clang++=g++) @@ -50,7 +50,9 @@ PLUGIN_FLAGS = -fPIC -fno-rtti -I"$(PLUGIN_PATH)/include" HASH=\# GCCVER = $(shell $(MYCC) --version 2>/dev/null | awk 'NR == 1 {print $$NF}') +GCCVER:sh= gcc --version 2>/dev/null | awk 'NR == 1 {print $$NF}' GCCBINDIR = $(shell dirname `command -v $(MYCC)` 2>/dev/null ) +GCCBINDIR:sh= dirname `command -v $(MYCC)` 2>/dev/null _SHMAT_OK= $(shell echo '$(HASH)include @$(HASH)include @int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(MYCC) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 ) _SHMAT_OK:sh= echo '$(HASH)include @$(HASH)include @int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(MYCC) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 @@ -70,7 +72,7 @@ LDFLAGS += $(LDFLAGS_ADD) PROGS = ../afl-gcc-pass.so ../afl-gcc-fast ../afl-gcc-rt.o -all: test_shm test_deps $(PROGS) afl-gcc-fast.8 test_build all_done +all: test_shm test_deps $(PROGS) ../afl-gcc-fast.8 test_build all_done debug: @echo _SHMAT_OK = $(_SHMAT_OK) @@ -101,24 +103,24 @@ test_deps: afl-common.o: ../src/afl-common.c $(MYCC) $(CFLAGS) -c $< -o $@ $(LDFLAGS) -../afl-gcc-fast: afl-gcc-fast.c afl-common.o | test_deps - $(MYCC) -DAFL_GCC_CC=\"$(MYCC)\" -DAFL_GCC_CXX=\"$(MYCXX)\" $(CFLAGS) $< afl-common.o -o $@ $(LDFLAGS) +../afl-gcc-fast: afl-gcc-fast.c afl-common.o + $(MYCC) -DAFL_GCC_CC=\"$(MYCC)\" -DAFL_GCC_CXX=\"$(MYCXX)\" $(CFLAGS) afl-gcc-fast.c afl-common.o -o $@ $(LDFLAGS) ln -sf afl-gcc-fast ../afl-g++-fast -../afl-gcc-pass.so: afl-gcc-pass.so.cc | test_deps - $(MYCXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared $< -o $@ +../afl-gcc-pass.so: afl-gcc-pass.so.cc + $(MYCXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared afl-gcc-pass.so.cc -o $@ -../afl-gcc-rt.o: afl-gcc-rt.o.c | test_deps - $(MYCC) $(CFLAGS) -fPIC -c $< -o $@ +../afl-gcc-rt.o: afl-gcc-rt.o.c + $(MYCC) $(CFLAGS) -fPIC -c afl-gcc-rt.o.c -o $@ test_build: $(PROGS) @echo "[*] Testing the CC wrapper and instrumentation output..." - unset AFL_USE_ASAN AFL_USE_MSAN; AFL_QUIET=1 AFL_INST_RATIO=100 AFL_PATH=. AFL_CC=$(CC) ../afl-gcc-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS) + @unset AFL_USE_ASAN AFL_USE_MSAN; AFL_QUIET=1 AFL_INST_RATIO=100 AFL_PATH=. AFL_CC=$(CC) ../afl-gcc-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS) # unset AFL_USE_ASAN AFL_USE_MSAN; AFL_INST_RATIO=100 AFL_PATH=. AFL_CC=$(CC) ../afl-gcc-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS) - ASAN_OPTIONS=detect_leaks=0 ../afl-showmap -m none -q -o .test-instr0 ./test-instr ../$@ @echo .SH NAME >> ../$@ @echo .B $* >> ../$@ -- cgit 1.4.1