Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. PREFIX ?= /usr/local
  2. WFLAGS ?= -Wall -Wextra -Wmissing-prototypes -Wdiv-by-zero -Wbad-function-cast -Wcast-align -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wnested-externs -Wno-unknown-pragmas -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wno-type-limits
  3. CFLAGS ?= -Os -mcpu=native -fno-exceptions $(WFLAGS)
  4. CFLAGS += -I.
  5. OBJ = hydrogen.o
  6. AR ?= ar
  7. RANLIB ?= ranlib
  8. SRC = \
  9. hydrogen.c \
  10. hydrogen.h \
  11. impl/common.h \
  12. impl/core.h \
  13. impl/gimli-core.h \
  14. impl/hash.h \
  15. impl/hydrogen_p.h \
  16. impl/kdf.h \
  17. impl/kx.h \
  18. impl/pwhash.h \
  19. impl/random.h \
  20. impl/secretbox.h \
  21. impl/sign.h \
  22. impl/x25519.h
  23. all: lib test
  24. lib: libhydrogen.a
  25. install: lib
  26. mkdir -p $(PREFIX)/lib
  27. install -o 0 -g 0 -m 0755 libhydrogen.a $(PREFIX)/lib 2> /dev/null || install -m 0755 libhydrogen.a $(PREFIX)/lib
  28. mkdir -p $(PREFIX)/include
  29. install -o 0 -g 0 -m 0644 hydrogen.h $(PREFIX)/include 2> /dev/null || install -m 0644 hydrogen.h $(PREFIX)/include
  30. ldconfig 2> /dev/null || true
  31. uninstall:
  32. rm -f $(PREFIX)/lib/libhydrogen.a
  33. rm -f $(PREFIX)/include/hydrogen.h
  34. test: tests/tests
  35. rm -f tests/tests.done
  36. tests/tests && touch tests/tests.done
  37. tests/tests: $(SRC) tests/tests.c
  38. $(CC) $(CFLAGS) -O3 -o tests/tests hydrogen.c tests/tests.c
  39. $(OBJ): $(SRC)
  40. libhydrogen.a: $(OBJ)
  41. $(AR) -r $@ $^
  42. $(RANLIB) $@
  43. .PHONY: clean
  44. clean:
  45. rm -f libhydrogen.a $(OBJ)
  46. rm -f tests/tests tests/*.done
  47. check: test
  48. distclean: clean