Add util.c
[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 .PHONY: clean install release release/osx release/linux release/win32
9
10 nmrpflash: nmrp.o tftp.o ethsock.o main.o
11         $(CC) $(CFLAGS) -o nmrpflash nmrp.o tftp.o ethsock.o main.o $(LDFLAGS)
12
13 nmrp.o: nmrp.c nmrpd.h
14         $(CC) $(CFLAGS) -c -o nmrp.o nmrp.c
15
16 tftp.o: tftp.c nmrpd.h
17         $(CC) $(CFLAGS) -c -o tftp.o tftp.c
18
19 ethsock.o: ethsock.c nmrpd.h
20         $(CC) $(CFLAGS) -c -o ethsock.o ethsock.c
21
22 main.o: main.c nmrpd.h
23         $(CC) $(CFLAGS) -c -o main.o main.c
24
25 fuzz: clean
26         CC=afl-gcc CFLAGS=-DNMRPFLASH_FUZZ make nmrpflash
27         mv nmrpflash fuzz
28
29 clean:
30         rm -f nmrp.o tftp.o main.o ethsock.o 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