Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. NAME=imgproxy
  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. CC=CGO_ENABLED=0 go build
  10. # リリース。なし=デバッグ。
  11. RELEASE=-ldflags="-s -w" -buildvcs=false
  12. all:
  13. ${CC} ${RELEASE} -o ${NAME}
  14. release:
  15. env GOOS=linux GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-amd64
  16. env GOOS=linux GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-arm64
  17. env GOOS=linux GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-arm
  18. env GOOS=linux GOARCH=riscv64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-riscv64
  19. env GOOS=linux GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-386
  20. env GOOS=linux GOARCH=ppc64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-ppc64
  21. env GOOS=linux GOARCH=mips64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-linux-mips64
  22. env GOOS=openbsd GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-amd64
  23. env GOOS=openbsd GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-386
  24. env GOOS=openbsd GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-arm64
  25. env GOOS=openbsd GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-arm
  26. env GOOS=openbsd GOARCH=mips64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-openbsd-mips64
  27. env GOOS=freebsd GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-amd64
  28. env GOOS=freebsd GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-386
  29. env GOOS=freebsd GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-arm4
  30. env GOOS=freebsd GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-arm64
  31. env GOOS=freebsd GOARCH=riscv64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-freebsd-riscv64
  32. env GOOS=netbsd GOARCH=amd64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-amd64
  33. env GOOS=netbsd GOARCH=386 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-386
  34. env GOOS=netbsd GOARCH=arm ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-arm4
  35. env GOOS=netbsd GOARCH=arm64 ${CC} ${RELEASE} -o bin/${NAME}-${VERSION}-netbsd-arm64
  36. clean:
  37. rm -f ${NAME} ${NAME}-${VERSION}.tar.gz
  38. dist: clean
  39. mkdir -p ${NAME}-${VERSION}
  40. cp -R Makefile *.go go.mod ${NAME}-${VERSION}
  41. tar zcfv ${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
  42. rm -rf ${NAME}-${VERSION}
  43. install: all
  44. mkdir -p ${DESTDIR}${PREFIX}/bin
  45. cp -f ${NAME} ${DESTDIR}${PREFIX}/bin
  46. chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}
  47. uninstall:
  48. rm -f ${DESTDIOR}${PREFIX}/bin/${NAME}
  49. .PHONY: all release clean dist install uninstall