2024-06-17 22:41:46 +09:00
|
|
|
UNAME_S != uname -s
|
|
|
|
UNAME_M != uname -m
|
2024-06-18 17:59:04 +09:00
|
|
|
OS = ${UNAME_S}
|
|
|
|
|
|
|
|
.if ${UNAME_S} == "OpenBSD"
|
|
|
|
OS = openbsd
|
|
|
|
.elif ${UNAME_S} == "NetBSD"
|
|
|
|
OS = netbsd
|
|
|
|
.elif ${UNAME_S} == "FreeBSD"
|
|
|
|
OS = freebsd
|
|
|
|
.elif ${UNAME_S} == "Linux"
|
|
|
|
OS = linux
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if ${UNAME_M} == "x86_64"
|
|
|
|
UNAME_M = amd64
|
|
|
|
.endif
|
2024-06-17 22:41:46 +09:00
|
|
|
|
2024-06-18 19:54:12 +09:00
|
|
|
NAME != cat main.c | grep "const char \*sofname" | awk '{print $$5}' |\
|
2024-06-17 22:41:46 +09:00
|
|
|
sed "s/\"//g" | sed "s/;//"
|
2024-06-18 19:54:12 +09:00
|
|
|
VERSION != cat main.c | grep "const char \*version" | awk '{print $$5}' |\
|
2024-06-17 22:41:46 +09:00
|
|
|
sed "s/\"//g" | sed "s/;//"
|
|
|
|
PREFIX = /usr/local
|
|
|
|
.if ${UNAME_S} == "Linux"
|
|
|
|
PREFIX = /usr
|
|
|
|
.endif
|
|
|
|
|
|
|
|
MANPREFIX = ${PREFIX}/share/man
|
|
|
|
|
|
|
|
.if ${UNAME_S} == "OpenBSD"
|
|
|
|
MANPREFIX = ${PREFIX}/man
|
|
|
|
.endif
|
|
|
|
|
|
|
|
CC = cc
|
2024-06-18 22:04:27 +09:00
|
|
|
FILES = main.c src/*.c src/logo/*.c
|
2024-06-17 22:41:46 +09:00
|
|
|
CFLAGS = -Wall -Wextra -O3 -I${PREFIX}/include -L${PREFIX}/lib
|
|
|
|
.if ${UNAME_S} == "NetBSD"
|
|
|
|
CFLAGS += -I/usr/pkg/include -L/usr/pkg/lib -I/usr/include -L/usr/lib
|
|
|
|
.endif
|
2024-06-18 19:54:12 +09:00
|
|
|
LDFLAGS = -lc
|
2024-06-17 22:41:46 +09:00
|
|
|
|
|
|
|
all:
|
|
|
|
${CC} ${CFLAGS} -o ${NAME} ${FILES} ${LDFLAGS}
|
|
|
|
strip ${NAME}
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f ${NAME}
|
|
|
|
|
2024-06-18 17:59:04 +09:00
|
|
|
dist:
|
|
|
|
mkdir -p ${NAME}-${VERSION} release/src
|
2024-06-18 19:54:12 +09:00
|
|
|
cp -R LICENSE.txt Makefile README.md CHANGELOG.md\
|
2024-06-17 22:41:46 +09:00
|
|
|
${NAME}-completion.zsh ${NAME}.1 main.c src ${NAME}-${VERSION}
|
2024-06-18 17:59:04 +09:00
|
|
|
tar zcfv release/src/${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
|
2024-06-17 22:41:46 +09:00
|
|
|
rm -rf ${NAME}-${VERSION}
|
|
|
|
|
2024-06-18 17:59:04 +09:00
|
|
|
man:
|
|
|
|
mkdir -p release/man
|
|
|
|
cp ${NAME}.1 release/man/${NAME}-${VERSION}.1
|
|
|
|
|
2024-06-17 22:41:46 +09:00
|
|
|
depend:
|
|
|
|
${DEPS}
|
|
|
|
|
2024-06-18 17:59:04 +09:00
|
|
|
release:
|
|
|
|
mkdir -p release/bin
|
2024-06-18 19:54:12 +09:00
|
|
|
${CC} ${CFLAGS} -o release/bin/${NAME}-${VERSION}-${OS}-${UNAME_M} ${FILES}\
|
|
|
|
-static ${LDFLAGS}
|
2024-06-18 17:59:04 +09:00
|
|
|
strip release/bin/${NAME}-${VERSION}-${OS}-${UNAME_M}
|
2024-06-17 22:41:46 +09:00
|
|
|
|
2024-06-19 20:14:02 +09:00
|
|
|
install:
|
2024-06-17 22:41:46 +09:00
|
|
|
mkdir -p ${DESTDIR}${PREFIX}/bin
|
|
|
|
cp -f ${NAME} ${DESTDIR}${PREFIX}/bin
|
|
|
|
chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}
|
|
|
|
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
|
|
|
sed "s/VERSION/${VERSION}/g" < ${NAME}.1 > ${DESTDIR}${MANPREFIX}/man1/${NAME}.1
|
|
|
|
chmod 644 ${DESTDIR}${MANPREFIX}/man1/${NAME}.1
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -f ${DESTDIR}${PREFIX}/bin/${NAME}
|
|
|
|
|
|
|
|
.PHONY: all clean dist install uninstall
|