-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (34 loc) · 1004 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Makefile for Go project
BINARY_NAME=ourbible
BASEDIR ?= $(PWD)
PREFIX ?= /usr/local
# Check the operating system
ifeq ($(OS),Windows_NT)
NAME=$(BINARY_NAME).exe
BUILD_COMMAND=go build -o build/$(NAME) -ldflags "-H=windowsgui" ./cmd
else
BUILD_COMMAND=go build -o build/$(BINARY_NAME) ./cmd
endif
# Default target
.PHONY: all
all: build
# Build target
.PHONY: build
build:
go mod tidy
$(BUILD_COMMAND)
# Install target
.PHONY: install
install: build
install -d $(BASEDIR)$(PREFIX)/bin
install -m 755 build/$(BINARY_NAME) $(BASEDIR)$(PREFIX)/bin/$(BINARY_NAME)
install -d $(BASEDIR)/usr/share/applications
install -d $(BASEDIR)$(PREFIX)/share/$(BINARY_NAME)/static
install -d $(BASEDIR)$(PREFIX)/share/$(BINARY_NAME)/database
mv static/* $(BASEDIR)$(PREFIX)/share/$(BINARY_NAME)/static
mv database/* $(BASEDIR)$(PREFIX)/share/$(BINARY_NAME)/database
mv "$(BINARY_NAME).desktop" $(BASEDIR)/usr/share/applications
# Clean target
.PHONY: clean
clean:
rm -f build/$(BINARY_NAME)