Makefile (1564B)
- # SPDX-FileCopyrightText: 2022 Haelwenn (lanodan) Monnier <contact+skeud@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- CC ?= cc
- CFLAGS ?= -O2 -g -Wall -Wextra -Werror=implicit-function-declaration
- PREFIX ?= /usr
- SYS_BINDIR ?= /bin
- BINDIR ?= $(PREFIX)/bin
- MANDIR ?= $(PREFIX)/share/man
- # Dynamically linked executables are unsupported
- LDSTATIC = -static
- SYS_EXE = login su
- TEST_EXE = common_test
- MAN1 = login.1
- all: $(SYS_EXE)
- .c:
- $(CC) -std=c11 $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDSTATIC)
- common.c: common.h
- login_SRC = login.c common.c
- login: $(login_SRC) Makefile
- $(CC) -std=c11 $(CFLAGS) -o $@ $(login_SRC) -lcrypt $(LDFLAGS) $(LDSTATIC)
- su_SRC = su.c common.c
- su: $(su_SRC) Makefile
- $(CC) -std=c11 $(CFLAGS) -o $@ $(su_SRC) -lcrypt $(LDFLAGS) $(LDSTATIC)
- common_test: common_test.c common.c Makefile
- $(CC) -std=c11 $(CFLAGS) `pkg-config --cflags atf-c` -o $@ common_test.c common.c `pkg-config --libs atf-c` -lcrypt $(LDFLAGS)
- .PHONY: test
- test: $(TEST_EXE)
- kyua test || (kyua report --verbose; false)
- .PHONY: install
- install: all
- mkdir -p $(DESTDIR)$(SYS_BINDIR)/
- cp $(SYS_EXE) $(DESTDIR)$(SYS_BINDIR)/
- chmod 0755 $(DESTDIR)$(SYS_BINDIR)/login
- chmod 4755 $(DESTDIR)$(SYS_BINDIR)/su
- mkdir -p $(DESTDIR)$(MANDIR)/man1/
- cp $(MAN1) $(DESTDIR)$(MANDIR)/man1/
- C_SOURCES = *.c *.h
- .PHONY: format
- format:
- clang-format -style=file -assume-filename=.clang-format -i $(C_SOURCES)
- .PHONY: clean
- clean:
- rm -f $(SYS_EXE) $(TEST_EXE)
- .PHONY: lint
- lint:
- reuse lint
- mandoc -Tlint -Wunsupp,error,warning $(MAN1)
- flawfinder -DQ --error-level=4 .