Makefile (9239B)
- # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- include config.mk
- # Commands implemented as scripts
- SCRIPTS=
- # Commands linking to another executable
- SYMLINKS=cmd/'[' cmd/chgrp cmd/readlink
- RM=rm
- all: $(EXE) $(MAN1SO)
- bootstrap.sh: Makefile bootstrap-regen.sh
- ./bootstrap-regen.sh
- .c:
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDSTATIC)
- .c.o:
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -c -o $@ $<
- # selfcheck: Check without extra dependencies
- .PHONY: selfcheck
- selfcheck: selfcheck-cmds selfcheck-libs
- .PHONY: selfcheck-cmds
- TEST_CMDS = test-cmd/pathchk-getlimits test-cmd/getpriority
- selfcheck-cmds: $(EXE) $(TEST_CMDS)
- LDSTATIC="$(LDSTATIC)" ./check-cmds.sh
- .PHONY: selfcheck-libs
- 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
- selfcheck-libs: $(TEST_LIBS)
- LDSTATIC="$(LDSTATIC)" ./check-libs.sh $(TEST_LIBS)
- # Manpages with examples that cram/prysk can grok
- MAN_EXAMPLES = cmd/readlink.1
- .PHONY: check
- check: all check-man selfcheck-libs selfcheck-cmds
- MALLOC_CHECK_=3 POSIX_ME_HARDER=1 POSIXLY_CORRECT=1 LC_ALL=C.UTF-8 $(CRAM) test-cmd/*.t ${MAN_EXAMPLES}
- .PHONY: check_status
- check_status:
- 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
- .PHONY: check-man
- check-man: $(MAN1SO)
- 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
- 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
- .PHONY: build-checks
- build-checks: all $(TEST_CMDS) $(TEST_LIBS)
- .PHONY: lint
- lint: $(MAN1SO)
- $(MANDOC) -Tlint -Wunsupp,error,warning $(MAN1)
- $(REUSE) lint --quiet
- .PHONY: clean
- clean:
- $(RM) -fr $(EXE) ${EXE:=.c.gcov} ${EXE:=.gcda} ${EXE:=.gcno} cmd/expr.tab.c $(MAN1SO) $(TEST_CMDS) $(TEST_LIBS)
- install: all
- mkdir -p ${DESTDIR}${BINDIR}/
- cp -pP ${EXE} ${SCRIPTS} ${SYMLINKS} ${DESTDIR}${BINDIR}/
- mkdir -p ${DESTDIR}${MANDIR}/man1
- cp -pP ${MAN1} ${DESTDIR}${MANDIR}/man1
- .PHONY: coverage
- coverage:
- $(GCOV) -b $(EXE)
- C_SOURCES = cmd/*.c lib/*.h lib/*.c test-lib/*.c configure.d/*.c
- format: $(C_SOURCES)
- clang-format -style=file -assume-filename=.clang-format -i $(C_SOURCES)
- lib/sys_signame.c: lib/sys_signame.sh
- lib/sys_signame.sh >|lib/sys_signame.c
- cmd/date: cmd/date.c lib/iso_parse.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/date.c lib/iso_parse.c $(LDFLAGS) $(LDSTATIC)
- build/cmd/date.1: cmd/date.1.in lib/iso_parse.mdoc Makefile
- $(M4) cmd/date.1.in > $@
- cmd/touch: cmd/touch.c lib/iso_parse.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/touch.c lib/iso_parse.c $(LDFLAGS) $(LDSTATIC)
- build/cmd/touch.1: cmd/touch.1.in lib/iso_parse.mdoc Makefile
- $(M4) cmd/touch.1.in > $@
- cmd/sleep: cmd/sleep.c lib/strtodur.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sleep.c lib/strtodur.c $(LDFLAGS) $(LDSTATIC)
- cmd/timeout: cmd/timeout.c lib/strtodur.c lib/sys_signame.h lib/sys_signame.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/timeout.c lib/strtodur.c lib/sys_signame.c $(LDFLAGS) $(LDSTATIC)
- test-lib/t_mode: test-lib/t_mode.c lib/mode.c Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_mode.c lib/mode.c $(LDFLAGS) $(LDSTATIC)
- test-lib/t_strtodur: test-lib/t_strtodur.c lib/strtodur.c Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_strtodur.c lib/strtodur.c $(LDFLAGS) $(LDSTATIC)
- test-lib/t_symbolize_mode: test-lib/t_symbolize_mode.c lib/symbolize_mode.c Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_symbolize_mode.c lib/symbolize_mode.c $(LDFLAGS) $(LDSTATIC)
- test-lib/t_truncation: test-lib/t_truncation.c lib/truncation.c Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_truncation.c lib/truncation.c $(LDFLAGS) $(LDSTATIC)
- test-lib/t_sha1: test-lib/t_sha1.c lib/sha1.c lib/sha1.h lib/bytes2hex.c lib/strconv.h Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_sha1.c lib/sha1.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
- test-lib/t_sha256: test-lib/t_sha256.c lib/sha256.c lib/sha256.h lib/bytes2hex.c lib/strconv.h Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_sha256.c lib/sha256.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
- test-lib/t_sha512: test-lib/t_sha512.c lib/sha512.c lib/sha512.h lib/bytes2hex.c lib/strconv.h Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-lib/t_sha512.c lib/sha512.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
- cmd/df: cmd/df.c lib/humanize.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/df.c lib/humanize.c $(LDFLAGS) $(LDSTATIC)
- cmd/chmod: cmd/chmod.c lib/mode.c lib/symbolize_mode.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/chmod.c lib/mode.c lib/symbolize_mode.c $(LDFLAGS) $(LDSTATIC)
- cmd/mkdir: cmd/mkdir.c lib/mode.c lib/mode.h lib/lib_mkdir.c lib/lib_mkdir.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mkdir.c lib/mode.c lib/lib_mkdir.c $(LDFLAGS) $(LDSTATIC)
- cmd/mknod: cmd/mknod.c lib/mode.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mknod.c lib/mode.c $(LDFLAGS) $(LDSTATIC)
- cmd/mkfifo: cmd/mkfifo.c lib/mode.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mkfifo.c lib/mode.c $(LDFLAGS) $(LDSTATIC)
- cmd/seq: cmd/seq.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/seq.c -lm $(LDFLAGS) $(LDSTATIC)
- cmd/rm: cmd/rm.c lib/consent.c lib/consent.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/rm.c lib/consent.c $(LDFLAGS) $(LDSTATIC)
- cmd/truncate: cmd/truncate.c lib/truncation.c lib/truncation.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/truncate.c lib/truncation.c $(LDFLAGS) $(LDSTATIC)
- cmd/head: cmd/head.c lib/truncation.c lib/truncation.h lib/fs.c lib/fs.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/head.c lib/truncation.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
- cmd/split: cmd/split.c lib/truncation.c lib/truncation.h lib/fs.c lib/fs.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/split.c lib/truncation.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
- cmd/tr: cmd/tr.c lib/tr_str.c lib/tr_str.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/tr.c lib/tr_str.c $(LDFLAGS) $(LDSTATIC)
- cmd/chown: cmd/chown.c lib/fs.c lib/fs.h lib/user_group_parse.c lib/user_group_parse.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/chown.c lib/fs.c lib/user_group_parse.c $(LDFLAGS) $(LDSTATIC)
- cmd/realpath: cmd/realpath.c lib/fs.c lib/offline_realpath.c lib/fs.h Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/realpath.c lib/fs.c lib/offline_realpath.c $(LDFLAGS) $(LDSTATIC)
- cmd/expr.tab.c: cmd/expr.y Makefile
- $(YACC) -b cmd/expr cmd/expr.y
- cmd/expr: cmd/expr.tab.c Makefile
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -D_POSIX_C_SOURCE=200809L -o $@ cmd/expr.tab.c $(LDFLAGS) $(LDSTATIC)
- cmd/cat: cmd/cat.c lib/fs.c lib/fs.h Makefile config.mk
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/cat.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
- 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
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(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)
- cmd/mv: cmd/mv.c lib/consent.c lib/consent.h lib/fs.c lib/fs.h Makefile config.mk
- $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/mv.c lib/consent.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
- cmd/sha1sum: cmd/sha1sum.c lib/sha1.c lib/sha1.h lib/bytes2hex.c lib/strconv.h Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sha1sum.c lib/sha1.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
- cmd/sha256sum: cmd/sha256sum.c lib/sha256.c lib/sha256.h lib/bytes2hex.c lib/strconv.h Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sha256sum.c lib/sha256.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
- cmd/sha512sum: cmd/sha512sum.c lib/sha512.c lib/sha512.h lib/bytes2hex.c lib/strconv.h Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sha512sum.c lib/sha512.c lib/bytes2hex.c $(LDFLAGS) $(LDSTATIC)
- test-cmd/pathchk-getlimits: test-cmd/pathchk-getlimits.c Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-cmd/pathchk-getlimits.c $(LDFLAGS) $(LDSTATIC)
- test-cmd/getpriority: test-cmd/getpriority.c Makefile
- $(CC) -std=c99 $(CFLAGS) -o $@ test-cmd/getpriority.c $(LDFLAGS) $(LDSTATIC)