Add TFTP upload spinner
[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 ifeq ($(shell uname -s),Linux)
9         CFLAGS += $(shell pkg-config libnl-route-3.0 --cflags)
10         LIBS += $(shell pkg-config libnl-route-3.0 --libs)
11 endif
12
13 nmrpflash_OBJ = nmrp.o tftp.o ethsock.o main.o util.o
14
15 .PHONY: clean install release release/macos release/linux release/win32
16
17 nmrpflash: $(nmrpflash_OBJ)
18         $(CC) $(CFLAGS) -o nmrpflash $(nmrpflash_OBJ) $(LDFLAGS)
19
20 tftptest:
21         CFLAGS=-DNMRPFLASH_TFTP_TEST make clean nmrpflash
22
23 %.o: %.c nmrpd.h
24         $(CC) -c $(CFLAGS) $< -o $@
25
26 fuzz: clean
27         CC=afl-gcc CFLAGS=-DNMRPFLASH_FUZZ make nmrpflash
28         mv nmrpflash fuzz
29
30 dofuzz: fuzz
31         echo core | sudo tee /proc/sys/kernel/core_pattern
32         echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
33         afl-fuzz -i fuzzin -o fuzzout -- ./fuzz
34         echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
35 clean:
36         rm -f $(nmrpflash_OBJ) nmrpflash
37
38 install: nmrpflash
39         install -m 755 nmrpflash $(PREFIX)/bin
40
41 release/macos:
42         CFLAGS="-mmacosx-version-min=10.6" make release
43         zip nmrpflash-$(VERSION)-macos.zip nmrpflash
44
45 release/linux: release
46         zip nmrpflash-$(VERSION)-linux.zip nmrpflash
47
48 release/win32:
49         zip nmrpflash-$(VERSION)-win32.zip nmrpflash.exe
50
51 release: clean nmrpflash
52         strip nmrpflash