logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

Makefile (5253B)


  1. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  2. # SPDX-License-Identifier: MPL-2.0
  3. include config.mk
  4. # Commands implemented as scripts
  5. SCRIPTS=
  6. # Commands linking to another executable
  7. SYMLINKS=cmd/'[' cmd/chgrp cmd/readlink
  8. RM=rm
  9. all: $(EXE) $(MAN1SO)
  10. bootstrap.sh: Makefile bootstrap-regen.sh
  11. ./bootstrap-regen.sh
  12. .c:
  13. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  14. $(CC) -std=c99 $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDSTATIC)
  15. .c.o:
  16. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  17. $(CC) -std=c99 $(CFLAGS) -c -o $@ $<
  18. # selfcheck: Check without extra dependencies
  19. .PHONY: selfcheck
  20. selfcheck: selfcheck-cmds selfcheck-libs
  21. .PHONY: selfcheck-cmds
  22. TEST_CMDS = test-cmd/pathchk-getlimits test-cmd/getpriority
  23. selfcheck-cmds: $(EXE) $(TEST_CMDS)
  24. LDSTATIC="$(LDSTATIC)" ./check-cmds.sh
  25. .PHONY: selfcheck-libs
  26. TEST_LIBS = test-lib/t_mode test-lib/t_strtodur test-lib/t_symbolize_mode test-lib/t_truncation test-lib/t_sha1 test-lib/t_sha256 test-lib/t_sha512
  27. selfcheck-libs: $(TEST_LIBS)
  28. LDSTATIC="$(LDSTATIC)" ./check-libs.sh $(TEST_LIBS)
  29. # Manpages with examples that cram/prysk can grok
  30. MAN_EXAMPLES = cmd/readlink.1
  31. .PHONY: check
  32. check: all check-man selfcheck-libs selfcheck-cmds
  33. MALLOC_CHECK_=3 POSIX_ME_HARDER=1 POSIXLY_CORRECT=1 LC_ALL=C.UTF-8 $(CRAM) test-cmd/*.t ${MAN_EXAMPLES}
  34. .PHONY: check_status
  35. check_status:
  36. grep EXE config.mk | sed -e 's;^EXE = ;;' -e 's;cmd/;;g' | tr ' ' '\n' | grep -v '^$$' | sed -e 's;^;^;' -e 's;$$;\\b;' | grep -f - *.txt | grep -iv done
  37. .PHONY: check-man
  38. check-man: $(MAN1SO)
  39. err=0; for i in $(EXE); do if test ! -f $$i.1 && test ! -f $$i.1.in; then echo "$$i: missing manpage"; err=1; fi; done; exit $$err
  40. for i in $(MAN1) ; do grep -q 'EXIT STATUS' $$i || echo "$i lacks EXIT STATUS"; grep -q -e 'STANDARDS' -e 'HISTORY' $$i || echo "$i lacks STANDARDS/HISTORY"; done
  41. .PHONY: build-checks
  42. build-checks: all $(TEST_CMDS) $(TEST_LIBS)
  43. .PHONY: lint
  44. lint: $(MAN1SO)
  45. $(MANDOC) -Tlint -Wunsupp,error,warning $(MAN1)
  46. $(REUSE) lint --quiet
  47. .PHONY: clean
  48. clean:
  49. $(RM) -fr $(EXE) ${EXE:=.c.gcov} ${EXE:=.gcda} ${EXE:=.gcno} cmd/expr.tab.c $(MAN1SO) $(TEST_CMDS) $(TEST_LIBS) ${LIBUTILS_O}
  50. install: all
  51. mkdir -p ${DESTDIR}${BINDIR}/
  52. cp -pP ${EXE} ${SCRIPTS} ${SYMLINKS} ${DESTDIR}${BINDIR}/
  53. mkdir -p ${DESTDIR}${MANDIR}/man1
  54. cp -pP ${MAN1} ${DESTDIR}${MANDIR}/man1
  55. .PHONY: coverage
  56. coverage:
  57. $(GCOV) -b $(EXE)
  58. C_SOURCES = cmd/*.c lib/*.h lib/*.c test-lib/*.c configure.d/*.c
  59. format: $(C_SOURCES)
  60. clang-format -style=file -assume-filename=.clang-format -i $(C_SOURCES)
  61. lib/sys_signame.c: lib/sys_signame.sh
  62. lib/sys_signame.sh >|lib/sys_signame.c
  63. LIBUTILS_O = ${LIBUTILS_C:.c=.o}
  64. lib/utils.a: ${LIBUTILS_O} ${LIBUTILS_H} config.mk Makefile
  65. ${AR} rc ${ARFLAGS} lib/utils.a ${LIBUTILS_O}
  66. build/cmd/date.1: cmd/date.1.in lib/iso_parse.mdoc Makefile
  67. $(M4) cmd/date.1.in > $@
  68. build/cmd/touch.1: cmd/touch.1.in lib/iso_parse.mdoc Makefile
  69. $(M4) cmd/touch.1.in > $@
  70. cmd/expr.tab.c: cmd/expr.y Makefile
  71. $(YACC) -b cmd/expr cmd/expr.y
  72. # Needs -D_POSIX_C_SOURCE=200809L due to OpenBSD yacc
  73. cmd/expr: cmd/expr.tab.c lib/utils.a
  74. $(RM) -f cmd/expr.tab.c.gcov cmd/expr.tab.o.gcda cmd/expr.tab.o.gcno
  75. $(CC) -std=c99 $(CFLAGS) -D_POSIX_C_SOURCE=200809L -o cmd/expr cmd/expr.tab.c lib/utils.a $(LDFLAGS) $(LDSTATIC)
  76. # Needs -lm
  77. cmd/seq: cmd/seq.c Makefile
  78. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  79. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/seq.c -lm $(LDFLAGS) $(LDSTATIC)
  80. # ./bootstrap.sh binaries should be kept simple
  81. lib/fs.o: lib/fs.c lib/fs.h
  82. lib/err.o: lib/err.c lib/err.h
  83. lib/consent.o: lib/consent.c lib/consent.h
  84. lib/tr_str.o: lib/tr_str.c lib/tr_str.h
  85. cmd/cat: cmd/cat.c lib/fs.o
  86. cmd/printf: cmd/printf.c lib/err.o
  87. cmd/rm: cmd/rm.c lib/consent.o
  88. cmd/tr: cmd/tr.c lib/tr_str.o lib/err.o
  89. cmd/chmod: cmd/chmod.c lib/utils.a
  90. cmd/chown: cmd/chown.c lib/utils.a
  91. cmd/date: cmd/date.c lib/utils.a
  92. cmd/df: cmd/df.c lib/utils.a
  93. cmd/head: cmd/head.c lib/utils.a
  94. cmd/install: cmd/install.c lib/utils.a
  95. cmd/join: cmd/join.c lib/utils.a
  96. cmd/mkdir: cmd/mkdir.c lib/utils.a
  97. cmd/mkfifo: cmd/mkfifo.c lib/utils.a
  98. cmd/mknod: cmd/mknod.c lib/utils.a
  99. cmd/mv: cmd/mv.c lib/utils.a
  100. cmd/paste: cmd/paste.c lib/utils.a
  101. cmd/realpath: cmd/realpath.c lib/utils.a
  102. cmd/seq: cmd/seq.c lib/utils.a
  103. cmd/sha1sum: cmd/sha1sum.c lib/utils.a
  104. cmd/sha256sum: cmd/sha256sum.c lib/utils.a
  105. cmd/sha512sum: cmd/sha512sum.c lib/utils.a
  106. cmd/sleep: cmd/sleep.c lib/utils.a
  107. cmd/split: cmd/split.c lib/utils.a
  108. cmd/timeout: cmd/timeout.c lib/utils.a
  109. cmd/touch: cmd/touch.c lib/utils.a
  110. cmd/truncate: cmd/truncate.c lib/utils.a
  111. cmd/whoami: cmd/whoami.c lib/utils.a
  112. lib/mode.o: lib/mode.c lib/mode.h
  113. lib/sha1.o: lib/sha1.c lib/sha1.h
  114. lib/sha256.o: lib/sha256.c lib/sha256.h
  115. lib/sha512.o: lib/sha512.c lib/sha512.h
  116. lib/bytes2hex.o: lib/bytes2hex.c lib/strconv.h
  117. test-lib/t_mode: test-lib/t_mode.c lib/mode.o
  118. test-lib/t_strtodur: test-lib/t_strtodur.c lib/strtodur.o
  119. test-lib/t_symbolize_mode: test-lib/t_symbolize_mode.c lib/symbolize_mode.o
  120. test-lib/t_truncation: test-lib/t_truncation.c lib/truncation.o
  121. test-lib/t_sha1: test-lib/t_sha1.c lib/sha1.c lib/bytes2hex.o
  122. test-lib/t_sha256: test-lib/t_sha256.c lib/sha256.c lib/bytes2hex.o
  123. test-lib/t_sha512: test-lib/t_sha512.c lib/sha512.c lib/bytes2hex.o