forked from jclehner/nmrpflash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (52 loc) · 2.06 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
CC ?= gcc
PKG_CONFIG ?= pkg-config
PREFIX ?= /usr/local
VERSION := $(shell if [ -d .git ] && which git 2>&1 > /dev/null; then git describe --always | tail -c +2; else echo $$STANDALONE_VERSION; fi)
CFLAGS += -Wall -g -DNMRPFLASH_VERSION=\"$(VERSION)\"
SUFFIX ?=
ifeq ($(shell uname -s),Linux)
CFLAGS += $(shell $(PKG_CONFIG) libnl-route-3.0 --cflags)
LDFLAGS += $(shell $(PKG_CONFIG) libnl-route-3.0 --libs) -lpcap
else
LDFLAGS += -lpcap
endif
ifeq ($(shell uname -s),Darwin)
AFL=afl-clang
else
AFL=afl-gcc
endif
nmrpflash_OBJ = nmrp.o tftp.o ethsock.o main.o util.o
.PHONY: clean install release release/macos release/linux release/win32
nmrpflash$(SUFFIX): $(nmrpflash_OBJ)
$(CC) $(CFLAGS) -o nmrpflash$(SUFFIX) $(nmrpflash_OBJ) $(LDFLAGS)
tftptest:
CFLAGS=-DNMRPFLASH_TFTP_TEST make clean nmrpflash
%.o: %.c nmrpd.h
$(CC) -c $(CFLAGS) $< -o $@
fuzz_nmrp: tftp.c util.c nmrp.c fuzz.c
$(AFL) $(CFLAGS) -DNMRPFLASH_FUZZ $^ -o $@
fuzz_tftp: tftp.c util.c nmrp.c fuzz.c
$(AFL) $(CFLAGS) -DNMRPFLASH_FUZZ -DNMRPFLASH_FUZZ_TFTP $^ -o $@
dofuzz_tftp: fuzz_tftp
echo core | sudo tee /proc/sys/kernel/core_pattern
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
afl-fuzz -i fuzzin/tftp -o fuzzout/tftp -- ./fuzz_tftp fuzzin/tftp.bin
echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clean:
rm -f $(nmrpflash_OBJ) nmrpflash nmrpflash.exe fuzz_nmrp fuzz_tftp
install: nmrpflash
install -m 755 nmrpflash $(PREFIX)/bin
release/macos:
CFLAGS="-target arm64-apple-macos11" SUFFIX=".arm64" make release
CFLAGS="-target x86_64-apple-macos10.8" SUFFIX=".x86_64" make release
lipo -create -output nmrpflash nmrpflash.x86_64 nmrpflash.arm64
zip nmrpflash-$(VERSION)-macos.zip nmrpflash
rm -f nmrpflash.x86_64 nmrpflash.arm64
release/linux: release
zip nmrpflash-$(VERSION)-linux.zip nmrpflash
release/win32:
zip nmrpflash-$(VERSION)-win32.zip nmrpflash.exe
release: clean nmrpflash$(SUFFIX)
strip nmrpflash$(SUFFIX)
nmrpflash.ico: nmrpflash.svg
convert -background transparent -define icon:auto-resize=256,64,48,32,16 $< $@