logo

utils-std

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

Makefile (9239B)


  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)
  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. cmd/date: cmd/date.c lib/iso_parse.c Makefile
  64. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  65. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/date.c lib/iso_parse.c $(LDFLAGS) $(LDSTATIC)
  66. build/cmd/date.1: cmd/date.1.in lib/iso_parse.mdoc Makefile
  67. $(M4) cmd/date.1.in > $@
  68. cmd/touch: cmd/touch.c lib/iso_parse.c Makefile
  69. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  70. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/touch.c lib/iso_parse.c $(LDFLAGS) $(LDSTATIC)
  71. build/cmd/touch.1: cmd/touch.1.in lib/iso_parse.mdoc Makefile
  72. $(M4) cmd/touch.1.in > $@
  73. cmd/sleep: cmd/sleep.c lib/strtodur.c Makefile
  74. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  75. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sleep.c lib/strtodur.c $(LDFLAGS) $(LDSTATIC)
  76. cmd/timeout: cmd/timeout.c lib/strtodur.c lib/sys_signame.h lib/sys_signame.c Makefile
  77. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  78. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/timeout.c lib/strtodur.c lib/sys_signame.c $(LDFLAGS) $(LDSTATIC)
  79. test-lib/t_mode: test-lib/t_mode.c lib/mode.c Makefile
  80. $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_mode.c lib/mode.c $(LDFLAGS) $(LDSTATIC)
  81. test-lib/t_strtodur: test-lib/t_strtodur.c lib/strtodur.c Makefile
  82. $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_strtodur.c lib/strtodur.c $(LDFLAGS) $(LDSTATIC)
  83. test-lib/t_symbolize_mode: test-lib/t_symbolize_mode.c lib/symbolize_mode.c Makefile
  84. $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_symbolize_mode.c lib/symbolize_mode.c $(LDFLAGS) $(LDSTATIC)
  85. test-lib/t_truncation: test-lib/t_truncation.c lib/truncation.c Makefile
  86. $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_truncation.c lib/truncation.c $(LDFLAGS) $(LDSTATIC)
  87. test-lib/t_sha1: test-lib/t_sha1.c lib/sha1.c lib/sha1.h lib/bytes2hex.c lib/strconv.h Makefile
  88. $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_sha1.c lib/sha1.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
  89. test-lib/t_sha256: test-lib/t_sha256.c lib/sha256.c lib/sha256.h lib/bytes2hex.c lib/strconv.h Makefile
  90. $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_sha256.c lib/sha256.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
  91. test-lib/t_sha512: test-lib/t_sha512.c lib/sha512.c lib/sha512.h lib/bytes2hex.c lib/strconv.h Makefile
  92. $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_sha512.c lib/sha512.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
  93. cmd/df: cmd/df.c lib/humanize.c Makefile
  94. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  95. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/df.c lib/humanize.c $(LDFLAGS) $(LDSTATIC)
  96. cmd/chmod: cmd/chmod.c lib/mode.c lib/symbolize_mode.c Makefile
  97. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  98. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/chmod.c lib/mode.c lib/symbolize_mode.c $(LDFLAGS) $(LDSTATIC)
  99. cmd/mkdir: cmd/mkdir.c lib/mode.c lib/mode.h lib/lib_mkdir.c lib/lib_mkdir.h Makefile
  100. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  101. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mkdir.c lib/mode.c lib/lib_mkdir.c $(LDFLAGS) $(LDSTATIC)
  102. cmd/mknod: cmd/mknod.c lib/mode.c Makefile
  103. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  104. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mknod.c lib/mode.c $(LDFLAGS) $(LDSTATIC)
  105. cmd/mkfifo: cmd/mkfifo.c lib/mode.c Makefile
  106. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  107. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mkfifo.c lib/mode.c $(LDFLAGS) $(LDSTATIC)
  108. cmd/seq: cmd/seq.c Makefile
  109. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  110. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/seq.c -lm $(LDFLAGS) $(LDSTATIC)
  111. cmd/rm: cmd/rm.c lib/consent.c lib/consent.h Makefile
  112. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  113. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/rm.c lib/consent.c $(LDFLAGS) $(LDSTATIC)
  114. cmd/truncate: cmd/truncate.c lib/truncation.c lib/truncation.h Makefile
  115. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  116. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/truncate.c lib/truncation.c $(LDFLAGS) $(LDSTATIC)
  117. cmd/head: cmd/head.c lib/truncation.c lib/truncation.h lib/fs.c lib/fs.h Makefile
  118. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  119. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/head.c lib/truncation.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
  120. cmd/split: cmd/split.c lib/truncation.c lib/truncation.h lib/fs.c lib/fs.h Makefile
  121. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  122. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/split.c lib/truncation.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
  123. cmd/tr: cmd/tr.c lib/tr_str.c lib/tr_str.h Makefile
  124. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  125. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/tr.c lib/tr_str.c $(LDFLAGS) $(LDSTATIC)
  126. cmd/chown: cmd/chown.c lib/fs.c lib/fs.h lib/user_group_parse.c lib/user_group_parse.h Makefile
  127. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  128. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/chown.c lib/fs.c lib/user_group_parse.c $(LDFLAGS) $(LDSTATIC)
  129. cmd/realpath: cmd/realpath.c lib/fs.c lib/offline_realpath.c lib/fs.h Makefile
  130. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  131. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/realpath.c lib/fs.c lib/offline_realpath.c $(LDFLAGS) $(LDSTATIC)
  132. cmd/expr.tab.c: cmd/expr.y Makefile
  133. $(YACC) -b cmd/expr cmd/expr.y
  134. cmd/expr: cmd/expr.tab.c Makefile
  135. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  136. $(CC) -std=c99 $(CFLAGS) -D_POSIX_C_SOURCE=200809L -o $@ cmd/expr.tab.c $(LDFLAGS) $(LDSTATIC)
  137. cmd/cat: cmd/cat.c lib/fs.c lib/fs.h Makefile config.mk
  138. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  139. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/cat.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
  140. cmd/install: cmd/install.c lib/mode.c lib/user_group_parse.c lib/user_group_parse.h lib/fs.c lib/fs.h lib/lib_mkdir.c lib/lib_mkdir.h Makefile config.mk
  141. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  142. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/install.c lib/mode.c lib/user_group_parse.c lib/fs.c lib/lib_mkdir.c $(LDFLAGS) $(LDSTATIC)
  143. cmd/mv: cmd/mv.c lib/consent.c lib/consent.h lib/fs.c lib/fs.h Makefile config.mk
  144. $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
  145. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mv.c lib/consent.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
  146. cmd/sha1sum: cmd/sha1sum.c lib/sha1.c lib/sha1.h lib/bytes2hex.c lib/strconv.h Makefile
  147. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sha1sum.c lib/sha1.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
  148. cmd/sha256sum: cmd/sha256sum.c lib/sha256.c lib/sha256.h lib/bytes2hex.c lib/strconv.h Makefile
  149. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sha256sum.c lib/sha256.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
  150. cmd/sha512sum: cmd/sha512sum.c lib/sha512.c lib/sha512.h lib/bytes2hex.c lib/strconv.h Makefile
  151. $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sha512sum.c lib/sha512.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
  152. test-cmd/pathchk-getlimits: test-cmd/pathchk-getlimits.c Makefile
  153. $(CC) -std=c99 $(CFLAGS) -o $@ test-cmd/pathchk-getlimits.c $(LDFLAGS) $(LDSTATIC)
  154. test-cmd/getpriority: test-cmd/getpriority.c Makefile
  155. $(CC) -std=c99 $(CFLAGS) -o $@ test-cmd/getpriority.c $(LDFLAGS) $(LDSTATIC)