Makefile 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. NAME=norikae
  2. VERSION := $(shell cat main.go | grep "var version" | awk '{print $$4}' | sed "s/\"//g")
  3. # LinuxとIllumos=/usr、FreeBSDとOpenBSD=/usr/local、NetBSD=/usr/pkg
  4. PREFIX=/usr
  5. MANPREFIX=${PREFIX}/share/man
  6. CC=CGO_ENABLED=0 go build
  7. # リリース。なし=デバッグ。
  8. RELEASE=-ldflags="-s -w" -buildvcs=false
  9. all:
  10. ${CC} ${RELEASE} -o ${NAME}
  11. release:
  12. env GOOS=linux GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-amd64
  13. env GOOS=linux GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-arm64
  14. env GOOS=linux GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-arm
  15. env GOOS=linux GOARCH=riscv64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-riscv64
  16. env GOOS=linux GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-386
  17. env GOOS=linux GOARCH=ppc64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-ppc64
  18. env GOOS=linux GOARCH=mips64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-mips64
  19. env GOOS=openbsd GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-amd64
  20. env GOOS=openbsd GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-386
  21. env GOOS=openbsd GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-arm64
  22. env GOOS=openbsd GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-arm
  23. env GOOS=openbsd GOARCH=mips64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-mips64
  24. env GOOS=freebsd GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-amd64
  25. env GOOS=freebsd GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-386
  26. env GOOS=freebsd GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-arm4
  27. env GOOS=freebsd GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-arm64
  28. env GOOS=freebsd GOARCH=riscv64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-riscv64
  29. env GOOS=netbsd GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-amd64
  30. env GOOS=netbsd GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-386
  31. env GOOS=netbsd GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-arm4
  32. env GOOS=netbsd GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-arm64
  33. env GOOS=illumos GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-illumos-amd64
  34. env GOOS=darwin GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-macos-amd64
  35. env GOOS=darwin GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-macos-arm64
  36. env GOOS=windows GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-windows-amd64
  37. env GOOS=windows GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-windows-arm64
  38. clean:
  39. rm -f ${NAME} ${NAME}-${VERSION}.tar.gz
  40. dist: clean
  41. mkdir -p ${NAME}-${VERSION}
  42. cp -R LICENSE.txt Makefile README.md CHANGELOG.md\
  43. ${NAME}.1 *.go go.mod go.sum ${NAME}-${VERSION}
  44. tar zcfv ${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
  45. rm -rf ${NAME}-${VERSION}
  46. install: all
  47. mkdir -p ${DESTDIR}${PREFIX}/bin
  48. cp -f ${NAME} ${DESTDIR}${PREFIX}/bin
  49. chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}
  50. mkdir -p ${DESTDIR}${MANPREFIX}/man1
  51. sed "s/VERSION/${VERSION}/g" < ${NAME}.1 > ${DESTDIR}${MANPREFIX}/man1/${NAME}.1
  52. chmod 644 ${DESTDIR}${MANPREFIX}/man1/${NAME}.1
  53. uninstall:
  54. rm -f ${DESTDIR}${PREFIX}/bin/${NAME}\
  55. ${DESTDIR}${MANPREFIX}/man1/${NAME}.1
  56. .PHONY: all release clean dist install uninstall