2024-04-16 00:43:13 +09:00
|
|
|
UNAME_S!=uname -s
|
2024-02-01 17:13:24 +09:00
|
|
|
|
2024-04-16 13:06:34 +09:00
|
|
|
NAME!=cat main.c | grep "const char\* sofname" | awk '{print $$5}' | \
|
|
|
|
sed "s/\"//g" | sed "s/;//"
|
|
|
|
VERSION!=cat main.c | grep "const char\* version" | awk '{print $$5}' | \
|
|
|
|
sed "s/\"//g" | sed "s/;//"
|
2024-04-16 00:43:13 +09:00
|
|
|
PREFIX=/usr/local
|
|
|
|
|
|
|
|
.if ${UNAME_S} == "FreeBSD"
|
|
|
|
MANPREFIX=${PREFIX}/share/man
|
|
|
|
.elif ${UNAME_S} == "Linux"
|
2023-11-29 21:19:53 +09:00
|
|
|
PREFIX=/usr
|
2024-02-03 00:17:50 +09:00
|
|
|
MANPREFIX=${PREFIX}/share/man
|
2024-04-16 00:43:13 +09:00
|
|
|
.elif ${UNAME_S} == "NetBSD"
|
|
|
|
PREFIX=/usr/pkg
|
|
|
|
MANPREFIX=${PREFIX}/share/man
|
|
|
|
.endif
|
|
|
|
|
2023-11-29 21:19:53 +09:00
|
|
|
CC=cc
|
2024-04-16 13:06:34 +09:00
|
|
|
FILES=main.c src/*.c
|
2024-02-01 16:01:47 +09:00
|
|
|
CFLAGS=-Wall -Wextra -O3 -I${PREFIX}/include -L${PREFIX}/lib
|
2024-04-16 13:06:34 +09:00
|
|
|
.if ${UNAME_S} == "NetBSD"
|
2024-04-16 18:06:04 +09:00
|
|
|
CFLAGS+=-I/usr/local/include -L/usr/local/lib -I/usr/include -L/usr/lib
|
2024-04-16 13:06:34 +09:00
|
|
|
.endif
|
2023-12-01 02:25:27 +09:00
|
|
|
LDFLAGS=-lgpgme -lcrypto
|
2023-11-29 21:19:53 +09:00
|
|
|
|
|
|
|
all:
|
|
|
|
${CC} ${CFLAGS} -o ${NAME} ${FILES} ${LDFLAGS}
|
2024-02-01 16:01:47 +09:00
|
|
|
strip ${NAME}
|
2023-11-29 21:19:53 +09:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f ${NAME}
|
|
|
|
|
2023-11-30 08:15:37 +09:00
|
|
|
dist: clean
|
2024-04-16 13:33:38 +09:00
|
|
|
mkdir -p dist
|
2023-11-30 08:15:37 +09:00
|
|
|
mkdir -p ${NAME}-${VERSION}
|
2024-04-16 13:06:34 +09:00
|
|
|
cp -R LICENSE.txt Makefile README.md CHANGELOG.md \
|
|
|
|
${NAME}-completion.zsh ${NAME}.1 main.c src ${NAME}-${VERSION}
|
|
|
|
tar zcfv dist/${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
|
2023-11-30 08:15:37 +09:00
|
|
|
rm -rf ${NAME}-${VERSION}
|
|
|
|
|
2024-04-16 00:43:13 +09:00
|
|
|
release-openbsd:
|
2024-04-16 13:33:38 +09:00
|
|
|
mkdir -p release
|
2024-04-16 13:06:34 +09:00
|
|
|
${CC} ${CFLAGS} -o release/${NAME}-${VERSION}-openbsd-amd64 ${FILES} \
|
|
|
|
-static -lgpgme -lcrypto -lc -lassuan -lgpg-error -lintl -liconv
|
|
|
|
strip release/${NAME}-${VERSION}-openbsd-amd64
|
2024-04-16 00:43:13 +09:00
|
|
|
|
2024-04-16 12:27:59 +09:00
|
|
|
release-freebsd:
|
2024-04-16 13:33:38 +09:00
|
|
|
mkdir -p release
|
2024-04-16 13:09:01 +09:00
|
|
|
${CC} ${CFLAGS} -o release/${NAME}-${VERSION}-freebsd-amd64 ${FILES} \
|
2024-04-16 13:06:34 +09:00
|
|
|
-static -lgpgme -lcrypto -lc -lassuan -lgpg-error -lthr -lintl
|
2024-04-16 13:09:01 +09:00
|
|
|
strip release/${NAME}-${VERSION}-freebsd-amd64
|
2024-04-16 12:27:59 +09:00
|
|
|
|
2024-04-16 18:06:04 +09:00
|
|
|
release-netbsd:
|
|
|
|
mkdir -p release
|
|
|
|
${CC} ${CFLAGS} -o release/${NAME}-${VERSION}-netbsd-amd64 ${FILES} \
|
|
|
|
-static -lgpgme -lcrypto -lcrypt -lc -lassuan -lgpg-error -lintl
|
|
|
|
strip release/${NAME}-${VERSION}-netbsd-amd64
|
|
|
|
|
2024-04-16 12:30:37 +09:00
|
|
|
release-linux:
|
2024-04-16 13:33:38 +09:00
|
|
|
mkdir -p release
|
2024-04-16 13:06:34 +09:00
|
|
|
${CC} ${CFLAGS} -o release/${NAME}-${VERSION}-linux-amd64 ${FILES} \
|
|
|
|
-static -lgpgme -lcrypto -lc -lassuan -lgpg-error
|
|
|
|
strip release/${NAME}-${VERSION}-linux-amd64
|
2024-04-16 12:30:37 +09:00
|
|
|
|
2023-11-29 21:19:53 +09:00
|
|
|
install: all
|
|
|
|
mkdir -p ${DESTDIR}${PREFIX}/bin
|
|
|
|
cp -f ${NAME} ${DESTDIR}${PREFIX}/bin
|
|
|
|
chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}
|
2024-02-03 00:17:50 +09:00
|
|
|
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
|
|
|
sed "s/VERSION/${VERSION}/g" < ${NAME}.1 > ${DESTDIR}${MANPREFIX}/man1/${NAME}.1
|
|
|
|
chmod 644 ${DESTDIR}${MANPREFIX}/man1/${NAME}.1
|
2023-11-29 21:19:53 +09:00
|
|
|
|
2023-12-01 02:25:27 +09:00
|
|
|
install-zsh:
|
2023-12-01 12:41:36 +09:00
|
|
|
cp sp-completion.zsh ${DESTDIR}${PREFIX}/share/zsh/site-functions/_sp
|
2023-12-01 02:25:27 +09:00
|
|
|
|
2023-11-29 21:19:53 +09:00
|
|
|
uninstall:
|
|
|
|
rm -f ${DESTDIR}${PREFIX}/bin/${NAME}
|
|
|
|
|
2023-12-01 02:29:59 +09:00
|
|
|
.PHONY: all clean dist install install-zsh uninstall
|