Makefile 1.4 KB

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