logo

checkpassword-ng

Uniform password checking interface for applications

Makefile (1558B)


  1. # POSIX-ish Makefile with extensions common to *BSD and GNU such as:
  2. # - Usage of backticks for shell evaluation
  3. # - Usage of ?= for defining variables when not already defined
  4. # - Usage of += for appending to a variable
  5. VERSION = 0.1.0
  6. VERSION_FULL = $(VERSION)`./version.sh`
  7. PREFIX = /usr/local
  8. BINDIR = $(PREFIX)/bin
  9. LIBDIR = $(PREFIX)/lib
  10. MANDIR = $(PREFIX)/share/man
  11. CC ?= cc
  12. AR ?= ar
  13. EXE_CFLAGS = -pie -fPIE
  14. LIB_CFLAGS = -fpic -fPIC
  15. CFLAGS ?= -g -O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -O2 -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla
  16. LIBS = -lcrypt
  17. EXE = checkpassword
  18. LIBSO = libchkpw.so
  19. LIBA = libchkpw.a
  20. SRC = checkpassword.c chkpw.c
  21. all: $(EXE) $(LIBSO) $(LIBA)
  22. checkpassword: checkpassword.c chkpw.o
  23. $(CC) -std=c99 $(EXE_CFLAGS) $(CFLAGS) -o $@ $< chkpw.o $(LIBS) $(LDFLAGS)
  24. libchkpw.so: chkpw.c
  25. $(CC) -std=c99 -c -shared $(LIB_CFLAGS) $(CFLAGS) -o $@ $<
  26. chkpw.o: chkpw.c
  27. $(CC) -std=c99 -c $(LIB_CFLAGS) $(CFLAGS) -o $@ $<
  28. libchkpw.a: chkpw.o
  29. $(AR) -rv $@ $<
  30. .PHONY: install
  31. install: all
  32. mkdir -p $(DESTDIR)$(BINDIR)
  33. cp -p $(EXE) $(DESTDIR)$(BINDIR)/$(EXE)
  34. mkdir -p $(DESTDIR)$(LIBDIR)
  35. cp -p $(LIBSO) $(LIBA) $(DESTDIR)$(LIBDIR)/
  36. mkdir -p $(DESTDIR)$(MANDIR)/man3
  37. cp -p chkpwd.8 $(DESTDIR)$(MANDIR)/man3
  38. mkdir -p $(DESTDIR)$(MANDIR)/man8
  39. cp -p $(EXE).8 $(DESTDIR)$(MANDIR)/man8
  40. .PHONY: clean
  41. clean:
  42. rm -fr $(EXE) chkpw.o $(LIBSO) $(LIBA)
  43. format: *.c
  44. clang-format -style=file -assume-filename=.clang-format -i *.c