Bump version
[oweals/nmrpflash.git] / Makefile
index 0ad5c8b110f27cf8d0075b84b988e4b362ee2e51..175ff0689dbcfa0f8e126a852787d7cd75e7f219 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,39 @@
 CC ?= gcc
-CFLAGS = -Wall
+PREFIX ?= /usr/local
+VERSION = $(shell git describe --always | tail -c +2)
+LIBS = -lpcap
+CFLAGS += -Wall -g -DNMRPFLASH_VERSION=\"$(VERSION)\"
+LDFLAGS += $(LIBS)
 
-nmrp-flash: nmrp.o tftp.o main.o
-       $(CC) $(CFLAGS) -o nmrp-flash nmrp.o tftp.o main.o
+nmrpflash_OBJ = nmrp.o tftp.o ethsock.o main.o util.o
 
-nmrp.o: nmrp.c nmrpd.h
-       $(CC) $(CFLAGS) -c -o nmrp.o nmrp.c
+.PHONY: clean install release release/osx release/linux release/win32
 
-tftp.o: tftp.c nmrpd.h
-       $(CC) $(CFLAGS) -c -o tftp.o tftp.c
+nmrpflash: $(nmrpflash_OBJ)
+       $(CC) $(CFLAGS) -o nmrpflash $(nmrpflash_OBJ) $(LDFLAGS)
 
-main.o: main.c nmrpd.h
-       $(CC) $(CFLAGS) -c -o main.o main.c
+%.o: %.c nmrpd.h
+       $(CC) -c $(CFLAGS) $< -o $@
+
+fuzz: clean
+       CC=afl-gcc CFLAGS=-DNMRPFLASH_FUZZ make nmrpflash
+       mv nmrpflash fuzz
 
 clean:
-       rm -f nmrp.o tftp.o main.o nmrpd
+       rm -f nmrp.o tftp.o main.o ethsock.o nmrpflash
+
+install: nmrpflash
+       install -m 755 nmrpflash $(PREFIX)/bin
+
+release/osx:
+       CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.6" make release
+       zip nmrpflash-$(VERSION)-osx.zip nmrpflash
+
+release/linux: release
+       zip nmrpflash-$(VERSION)-linux.zip nmrpflash
+
+release/win32:
+       zip nmrpflash-$(VERSION)-win32.zip nmrpflash.exe
 
+release: clean nmrpflash
+       strip nmrpflash