2024-05-19 05:29:13 +04:00
|
|
|
TARGET := kwh-cost
|
2021-12-23 23:58:23 +04:00
|
|
|
|
2024-05-19 05:29:13 +04:00
|
|
|
DESTDIR ?=
|
|
|
|
PREFIX ?= /usr/local
|
2023-09-17 22:46:12 +04:00
|
|
|
|
2024-05-19 05:29:13 +04:00
|
|
|
CC ?= cc
|
2024-05-19 22:14:29 +04:00
|
|
|
CFLAGS := -std=c99 -O3 -Wall -Werror -Wextra -pedantic -flto
|
2021-12-23 23:58:23 +04:00
|
|
|
|
2021-12-24 02:37:36 +04:00
|
|
|
|
2023-09-17 22:46:12 +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
|
2021-12-25 23:22:32 +04:00
|
|
|
${CC} ${CFLAGS} ${LDFLAGS} $< -o $@
|
2021-12-23 23:58:23 +04:00
|
|
|
|
|
|
|
clean:
|
2024-05-19 05:29:13 +04:00
|
|
|
rm -f ${TARGET}
|
2021-12-23 23:58:23 +04:00
|
|
|
|
2024-05-19 05:29:13 +04:00
|
|
|
install: | ${TARGET}
|
2024-05-19 23:17:04 +04:00
|
|
|
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:
|
2023-09-17 22:46:12 +04:00
|
|
|
rm -f ${DESTDIR}${PREFIX}/bin/${TARGET}
|
2024-05-19 05:29:13 +04:00
|
|
|
rm -f ${DESTDIR}${PREFIX}/share/licenses/${TARGET}/LICENSE
|
|
|
|
rmdir ${DESTDIR}${PREFIX}/share/licenses/${TARGET}
|
2022-01-06 04:21:08 +04:00
|
|
|
|
2024-05-19 23:18:05 +04:00
|
|
|
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? "
|
2022-01-06 04:21:08 +04:00
|
|
|
@test "${shell ./kwh-cost 3.68 120 30d}" = "317.95" && { echo -e "\e[32mYES\e[0m"; } || { echo -e "\e[31mNO\e[0m"; }
|