-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (48 loc) · 1.8 KB
/
Makefile
File metadata and controls
57 lines (48 loc) · 1.8 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# VARIABLES
TARG=sgs-enabler
PACKAGE="github.com/basilboli/forwardproxy"
BINARY_NAME="forwardproxy"
IMAGE_NAME="basilboli/forwardproxy"
print_success = echo -e "\e[1;32m$(1) $<\e[0m"
print_warning = echo -e "\e[1;33m$(1) $<\e[0m"
print_error = echo -e "\e[1;31m$(1) $<\e[0m"
export GOPATH=$(shell pwd)
# Default target : Do nothing
default:
@echo "You must specify a target with this makefile"
@echo "Usage : "
@echo "make clean Remove binary files"
@echo "make install Compile sources and build binaries"
@echo "make test Run all tests of your application"
@echo "make run Build application and run it !"
@echo "make dockerize Dockerize application !"
# Clean .o files and binary
clean:
@echo "--> cleaning..."
@go clean || (echo "Unable to clean project" && exit 1)
@rm -rf bin/$(BINARY_NAME) 2> /dev/null
@echo "Clean OK"
# Compile sources and build binary
install: clean
@echo "--> installing..."
@echo "GOPATH : $(GOPATH)"
@go install $(PACKAGE) || ($(call print_error,Compilation error) && exit 1)
@echo "Install OK"
# Run your application
run: clean install
@echo "--> running application..."
@./bin/$(BINARY_NAME)
# Test your application
test:
@echo "--> testing..."
@go test -v $(PACKAGE)/...
resolve-deps:
@echo "--> resolving dependencies..."
cd src/github.com/basilboli/forwardproxy; go get -v $(go list -e ./... | grep -v vendor) && go get -t $(go list -e ./... | grep -v vendor)
cd src/github.com/basilboli/forwardproxy; go test -v $(go list -e ./... | grep -v vendor)
# Dockerize your application
dockerize: resolve-deps
@echo "--> dockerizing..."
@CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o $(BINARY_NAME) $(PACKAGE)|| ($(call print_error,Compilation error) && exit 1)
docker build -t $(IMAGE_NAME) -f Dockerfile.scratch .
@rm -f $(BINARY_NAME)