logo

skeud

Simple and portable utilities to deal with user accounts (su, login)

Makefile (1564B)


  1. # SPDX-FileCopyrightText: 2022 Haelwenn (lanodan) Monnier <contact+skeud@hacktivis.me>
  2. # SPDX-License-Identifier: MPL-2.0
  3. CC ?= cc
  4. CFLAGS ?= -O2 -g -Wall -Wextra -Werror=implicit-function-declaration
  5. PREFIX ?= /usr
  6. SYS_BINDIR ?= /bin
  7. BINDIR ?= $(PREFIX)/bin
  8. MANDIR ?= $(PREFIX)/share/man
  9. # Dynamically linked executables are unsupported
  10. LDSTATIC = -static
  11. SYS_EXE = login su
  12. TEST_EXE = common_test
  13. MAN1 = login.1
  14. all: $(SYS_EXE)
  15. .c:
  16. $(CC) -std=c11 $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDSTATIC)
  17. common.c: common.h
  18. login_SRC = login.c common.c
  19. login: $(login_SRC) Makefile
  20. $(CC) -std=c11 $(CFLAGS) -o $@ $(login_SRC) -lcrypt $(LDFLAGS) $(LDSTATIC)
  21. su_SRC = su.c common.c
  22. su: $(su_SRC) Makefile
  23. $(CC) -std=c11 $(CFLAGS) -o $@ $(su_SRC) -lcrypt $(LDFLAGS) $(LDSTATIC)
  24. common_test: common_test.c common.c Makefile
  25. $(CC) -std=c11 $(CFLAGS) `pkg-config --cflags atf-c` -o $@ common_test.c common.c `pkg-config --libs atf-c` -lcrypt $(LDFLAGS)
  26. .PHONY: test
  27. test: $(TEST_EXE)
  28. kyua test || (kyua report --verbose; false)
  29. .PHONY: install
  30. install: all
  31. mkdir -p $(DESTDIR)$(SYS_BINDIR)/
  32. cp $(SYS_EXE) $(DESTDIR)$(SYS_BINDIR)/
  33. chmod 0755 $(DESTDIR)$(SYS_BINDIR)/login
  34. chmod 4755 $(DESTDIR)$(SYS_BINDIR)/su
  35. mkdir -p $(DESTDIR)$(MANDIR)/man1/
  36. cp $(MAN1) $(DESTDIR)$(MANDIR)/man1/
  37. C_SOURCES = *.c *.h
  38. .PHONY: format
  39. format:
  40. clang-format -style=file -assume-filename=.clang-format -i $(C_SOURCES)
  41. .PHONY: clean
  42. clean:
  43. rm -f $(SYS_EXE) $(TEST_EXE)
  44. .PHONY: lint
  45. lint:
  46. reuse lint
  47. mandoc -Tlint -Wunsupp,error,warning $(MAN1)
  48. flawfinder -DQ --error-level=4 .