Ensure that NMRP packets are at least 64 bytes
[oweals/nmrpflash.git] / Makefile
1 CC ?= gcc
2 PREFIX ?= /usr/local
3 VERSION = $(shell git describe --always | tail -c +2)
4 LIBS = -lpcap
5 CFLAGS += -Wall -g -DNMRPFLASH_VERSION=\"$(VERSION)\"
6 LDFLAGS += $(LIBS)
7
8 nmrpflash_OBJ = nmrp.o tftp.o ethsock.o main.o util.o
9
10 .PHONY: clean install release release/osx release/linux release/win32
11
12 nmrpflash: $(nmrpflash_OBJ)
13         $(CC) $(CFLAGS) -o nmrpflash $(nmrpflash_OBJ) $(LDFLAGS)
14
15 tftptest:
16         CFLAGS=-DNMRPFLASH_TFTP_TEST make clean nmrpflash
17
18 %.o: %.c nmrpd.h
19         $(CC) -c $(CFLAGS) $< -o $@
20
21 fuzz: clean
22         CC=afl-gcc CFLAGS=-DNMRPFLASH_FUZZ make nmrpflash
23         mv nmrpflash fuzz
24
25 dofuzz: fuzz
26         echo core | sudo tee /proc/sys/kernel/core_pattern
27         echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
28         afl-fuzz -i fuzzin -o fuzzout -- ./fuzz
29 clean:
30         rm -f $(nmrpflash_OBJ) nmrpflash
31
32 install: nmrpflash
33         install -m 755 nmrpflash $(PREFIX)/bin
34
35 release/osx:
36         CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.6" make release
37         zip nmrpflash-$(VERSION)-osx.zip nmrpflash
38
39 release/linux: release
40         zip nmrpflash-$(VERSION)-linux.zip nmrpflash
41
42 release/win32:
43         zip nmrpflash-$(VERSION)-win32.zip nmrpflash.exe
44
45 release: clean nmrpflash
46         strip nmrpflash