Makefile 3.1 KB

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