29 lines
766 B
Makefile
29 lines
766 B
Makefile
TARGET := kwh-cost
|
|
|
|
DESTDIR ?=
|
|
PREFIX ?= /usr/local
|
|
|
|
CC ?= cc
|
|
CFLAGS := -std=c99 -O3 -Wall -Werror -Wextra -pedantic -flto
|
|
|
|
|
|
.PHONY: clean install uninstall test
|
|
|
|
${TARGET}: ${TARGET}.c
|
|
${CC} ${CFLAGS} ${LDFLAGS} $< -o $@
|
|
|
|
clean:
|
|
rm -f ${TARGET}
|
|
|
|
install: | ${TARGET}
|
|
install -spDm755 ${TARGET} ${DESTDIR}${PREFIX}/bin/${TARGET}
|
|
install -pDm644 LICENSE ${DESTDIR}${PREFIX}/share/licenses/${TARGET}/LICENSE
|
|
|
|
uninstall:
|
|
rm -f ${DESTDIR}${PREFIX}/bin/${TARGET}
|
|
rm -f ${DESTDIR}${PREFIX}/share/licenses/${TARGET}/LICENSE
|
|
rmdir ${DESTDIR}${PREFIX}/share/licenses/${TARGET}
|
|
|
|
test: | ${TARGET}
|
|
@echo -n "Does input \"3.68 120 30d\" 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"; }
|