aboutsummaryrefslogblamecommitdiff
path: root/Makefile
blob: 5d712f29ca5185b8d50dac7bde743c7366ab1e1a (plain) (tree)




















                                                                    

                          

                                                                                                                   
 


                        

                                              
                                                  
                                                              
                                                             
                                                                     
                                                                    




                                                     
NAME         ?= monzero
PKGNAME      ?= git.zero-knowledge.org/gibheer/monzero

export GO111MODULE=on

# build specific flags
DESTDIR      ?= .
prefix       ?= /usr/local
exec_prefix  ?= ${prefix}
bindir       ?= ${exec_prefix}/bin
sysconfdir   ?= ${prefix}/etc/${NAME}
WRKDIR       ?= build
GOBIN        ?= go

# set GOOS to linux by default
GOOS         ?= linux
BUILDID      = 0x`head -c20 /dev/urandom | od -An -tx | tr -d ' \n'`
LDFLAGS      += -B ${BUILDID}
BUILD_DATE   ?= `date +%FT%T%z`
LDFLAGS      += -X main.BUILD_DATE=${BUILD_DATE}

build: clean
	mkdir -p ${WRKDIR}
	GOOS=${GOOS} CGO_ENABLED=false go build -ldflags="${LDFLAGS}" -o ${WRKDIR}/moncheck ${PKGNAME}/cmd/moncheck
	GOOS=${GOOS} CGO_ENABLED=false go build -ldflags="${LDFLAGS}" -o ${WRKDIR}/monwork ${PKGNAME}/cmd/monwork

clean:
	-rm -r ${WRKDIR}

install: build
	install -d -m 0755 ${DESTDIR}${bindir}
	install -d -m 0755 ${DESTDIR}${sysconfdir}
	install -m 0755 ${WRKDIR}/moncheck ${DESTDIR}${bindir}
	install -m 0755 ${WRKDIR}/monwork ${DESTDIR}${bindir}
	install -m 0644 moncheck.conf.example ${DESTDIR}${sysconfdir}
	install -m 0644 monwork.conf.example ${DESTDIR}${sysconfdir}

package: DESTDIR = ${NAME}-${VERSION}
package: install
	tar -czf ${NAME}-${VERSION}.tar.gz ${DESTDIR}
	rm -R ${DESTDIR}