2
0

Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. CC ?= gcc
  2. PKG_CONFIG ?= pkg-config
  3. PREFIX ?= /usr/local
  4. VERSION := $(shell if [ -d .git ] && which git 2>&1 > /dev/null; then git describe --always | tail -c +2; else echo $$STANDALONE_VERSION; fi)
  5. CFLAGS += -Wall -g -DNMRPFLASH_VERSION=\"$(VERSION)\"
  6. LDFLAGS += -lpcap
  7. ifeq ($(shell uname -s),Linux)
  8. CFLAGS += $(shell $(PKG_CONFIG) libnl-route-3.0 --cflags)
  9. LDFLAGS += $(shell $(PKG_CONFIG) libnl-route-3.0 --libs)
  10. endif
  11. ifeq ($(shell uname -s),Darwin)
  12. AFL=afl-clang
  13. else
  14. AFL=afl-gcc
  15. endif
  16. nmrpflash_OBJ = nmrp.o tftp.o ethsock.o main.o util.o
  17. .PHONY: clean install release release/macos release/linux release/win32
  18. nmrpflash: $(nmrpflash_OBJ)
  19. $(CC) $(CFLAGS) -o nmrpflash $(nmrpflash_OBJ) $(LDFLAGS)
  20. tftptest:
  21. CFLAGS=-DNMRPFLASH_TFTP_TEST make clean nmrpflash
  22. %.o: %.c nmrpd.h
  23. $(CC) -c $(CFLAGS) $< -o $@
  24. fuzz_nmrp: tftp.c util.c nmrp.c fuzz.c
  25. $(AFL) $(CFLAGS) -DNMRPFLASH_FUZZ $^ -o $@
  26. fuzz_tftp: tftp.c util.c nmrp.c fuzz.c
  27. $(AFL) $(CFLAGS) -DNMRPFLASH_FUZZ -DNMRPFLASH_FUZZ_TFTP $^ -o $@
  28. dofuzz_tftp: fuzz_tftp
  29. echo core | sudo tee /proc/sys/kernel/core_pattern
  30. echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  31. afl-fuzz -i fuzzin/tftp -o fuzzout/tftp -- ./fuzz_tftp fuzzin/tftp.bin
  32. echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  33. clean:
  34. rm -f $(nmrpflash_OBJ) nmrpflash fuzz_nmrp fuzz_tftp
  35. install: nmrpflash
  36. install -m 755 nmrpflash $(PREFIX)/bin
  37. release/macos:
  38. CFLAGS="-mmacosx-version-min=10.6" make release
  39. zip nmrpflash-$(VERSION)-macos.zip nmrpflash
  40. release/linux: release
  41. zip nmrpflash-$(VERSION)-linux.zip nmrpflash
  42. release/win32:
  43. zip nmrpflash-$(VERSION)-win32.zip nmrpflash.exe
  44. release: clean nmrpflash
  45. strip nmrpflash