kwh-cost/Makefile

29 lines
761 B
Makefile
Raw Permalink Normal View History

TARGET := kwh-cost
2021-12-23 23:58:23 +04:00
DESTDIR ?=
PREFIX ?= /usr/local
CC ?= cc
2024-05-21 04:27:20 +04:00
CFLAGS := -std=c99 -O3 -Wall -Werror -Wextra -pedantic
2021-12-23 23:58:23 +04:00
.PHONY: clean install uninstall test
2021-12-23 23:58:23 +04:00
2024-05-19 04:36:33 +04:00
${TARGET}: ${TARGET}.c
2024-05-20 18:11:44 +04:00
${CC} ${CFLAGS} $< -o $@
2021-12-23 23:58:23 +04:00
clean:
rm -f ${TARGET}
2021-12-23 23:58:23 +04:00
install: | ${TARGET}
install -spDm755 ${TARGET} ${DESTDIR}${PREFIX}/bin/${TARGET}
install -pDm644 LICENSE ${DESTDIR}${PREFIX}/share/licenses/${TARGET}/LICENSE
2021-12-23 23:58:23 +04:00
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/${TARGET}
rm -f ${DESTDIR}${PREFIX}/share/licenses/${TARGET}/LICENSE
rmdir ${DESTDIR}${PREFIX}/share/licenses/${TARGET}
test: | ${TARGET}
2024-05-19 23:22:26 +04:00
@echo -en "Does input \e[36m\"3.68 120 30d\"\e[0m gives 317.95? "
@test "${shell ./kwh-cost 3.68 120 30d}" = "317.95" && { echo -e "\e[32mYES\e[0m"; } || { echo -e "\e[31mNO\e[0m"; }