Makefile 2.7 KB

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