1
- # Makefile that builds serve-grpc, a "go" program .
1
+ # Makefile for serve-grpc.
2
2
3
- # Detect the operating system and architecture
3
+ # Detect the operating system and architecture.
4
4
5
5
include Makefile.osdetect
6
6
@@ -24,13 +24,13 @@ BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's
24
24
GIT_REMOTE_URL := $(shell git config --get remote.origin.url)
25
25
GO_PACKAGE_NAME :=
$(shell echo $(GIT_REMOTE_URL ) | sed -e 's|^[email protected] :|github.com/|' -e 's|\.git$$||' -e 's|Senzing|senzing|')
26
26
PATH := $(MAKEFILE_DIRECTORY ) /bin:$(PATH )
27
- GO_OSARCH = $(subst /, ,$@ )
28
- GO_OS = $(word 1, $(GO_OSARCH ) )
29
- GO_ARCH = $(word 2, $(GO_OSARCH ) )
30
27
31
28
# Recursive assignment ('=')
32
29
33
30
CC = gcc
31
+ GO_OSARCH = $(subst /, ,$@ )
32
+ GO_OS = $(word 1, $(GO_OSARCH ) )
33
+ GO_ARCH = $(word 2, $(GO_OSARCH ) )
34
34
35
35
# Conditional assignment. ('?=')
36
36
# Can be overridden with "export"
@@ -43,9 +43,6 @@ SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@/tmp/sqlite/G2C.db
43
43
44
44
.EXPORT_ALL_VARIABLES :
45
45
46
- -include Makefile.$(OSTYPE )
47
- -include Makefile.$(OSTYPE ) _$(OSARCH )
48
-
49
46
# -----------------------------------------------------------------------------
50
47
# The first "make" target runs as default.
51
48
# -----------------------------------------------------------------------------
@@ -54,8 +51,14 @@ SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@/tmp/sqlite/G2C.db
54
51
default : help
55
52
56
53
# -----------------------------------------------------------------------------
57
- # Build
58
- # - The "build" target is implemented in Makefile.OS.ARCH files.
54
+ # Operating System / Architecture targets
55
+ # -----------------------------------------------------------------------------
56
+
57
+ -include Makefile.$(OSTYPE )
58
+ -include Makefile.$(OSTYPE ) _$(OSARCH )
59
+
60
+ # -----------------------------------------------------------------------------
61
+ # Dependency management
59
62
# -----------------------------------------------------------------------------
60
63
61
64
.PHONY : dependencies
@@ -64,6 +67,11 @@ dependencies:
64
67
@go get -t -u ./...
65
68
@go mod tidy
66
69
70
+ # -----------------------------------------------------------------------------
71
+ # Build
72
+ # - The "build" target is implemented in Makefile.OS.ARCH files.
73
+ # - docker-build: https://docs.docker.com/engine/reference/commandline/build/
74
+ # -----------------------------------------------------------------------------
67
75
68
76
PLATFORMS := darwin/amd64 linux/amd64 windows/amd64
69
77
$(PLATFORMS ) :
@@ -72,20 +80,6 @@ $(PLATFORMS):
72
80
@GOOS=$(GO_OS ) GOARCH=$(GO_ARCH ) go build -o $(TARGET_DIRECTORY ) /$(GO_OS ) -$(GO_ARCH ) /$(PROGRAM_NAME )
73
81
74
82
75
- .PHONY : build-all $(PLATFORMS )
76
- build-all : $(PLATFORMS )
77
- @mv $(TARGET_DIRECTORY ) /windows-amd64/$(PROGRAM_NAME ) $(TARGET_DIRECTORY ) /windows-amd64/$(PROGRAM_NAME ) .exe
78
-
79
- # -----------------------------------------------------------------------------
80
- # Test
81
- # - The "test" target is implemented in Makefile.OS.ARCH files.
82
- # -----------------------------------------------------------------------------
83
-
84
- # -----------------------------------------------------------------------------
85
- # docker-build
86
- # - https://docs.docker.com/engine/reference/commandline/build/
87
- # -----------------------------------------------------------------------------
88
-
89
83
.PHONY : docker-build
90
84
docker-build :
91
85
@docker build \
@@ -98,33 +92,17 @@ docker-build:
98
92
--tag $(DOCKER_IMAGE_NAME ) :$(BUILD_VERSION ) \
99
93
.
100
94
101
-
102
- .PHONY : docker-build-package
103
- docker-build-package :
104
- @docker build \
105
- --build-arg BUILD_ITERATION=$(BUILD_ITERATION ) \
106
- --build-arg BUILD_VERSION=$(BUILD_VERSION ) \
107
- --build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME ) \
108
- --build-arg PROGRAM_NAME=$(PROGRAM_NAME ) \
109
- --no-cache \
110
- --file package.Dockerfile \
111
- --tag $(DOCKER_BUILD_IMAGE_NAME ) \
112
- .
113
-
114
95
# -----------------------------------------------------------------------------
115
- # Package
116
- # - The "package " target is implemented in Makefile.OS.ARCH files.
96
+ # Test
97
+ # - The "test " target is implemented in Makefile.OS.ARCH files.
117
98
# -----------------------------------------------------------------------------
118
99
100
+
119
101
# -----------------------------------------------------------------------------
120
102
# Run
103
+ # - The "run" target is implemented in Makefile.OS.ARCH files.
121
104
# -----------------------------------------------------------------------------
122
105
123
- .PHONY : run
124
- run :
125
- @go run main.go
126
-
127
-
128
106
.PHONY : docker-run
129
107
docker-run :
130
108
@docker run \
@@ -134,20 +112,25 @@ docker-run:
134
112
$(DOCKER_IMAGE_NAME )
135
113
136
114
# -----------------------------------------------------------------------------
137
- # Utility targets
115
+ # Package
116
+ # - The "package" target is implemented in Makefile.OS.ARCH files.
138
117
# -----------------------------------------------------------------------------
139
118
140
- .PHONY : new-sqlite
141
- new-sqlite :
142
- @rm -rf /tmp/sqlite
143
- @mkdir /tmp/sqlite
144
- @cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db
145
-
146
- .PHONY : update-pkg-cache
147
- update-pkg-cache :
148
- @GOPROXY=https://proxy.golang.org GO111MODULE=on \
149
- go get $(GO_PACKAGE_NAME ) @$(BUILD_TAG )
119
+ .PHONY : docker-build-package
120
+ docker-build-package :
121
+ @docker build \
122
+ --build-arg BUILD_ITERATION=$(BUILD_ITERATION ) \
123
+ --build-arg BUILD_VERSION=$(BUILD_VERSION ) \
124
+ --build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME ) \
125
+ --build-arg PROGRAM_NAME=$(PROGRAM_NAME ) \
126
+ --no-cache \
127
+ --file package.Dockerfile \
128
+ --tag $(DOCKER_BUILD_IMAGE_NAME ) \
129
+ .
150
130
131
+ # -----------------------------------------------------------------------------
132
+ # Utility targets
133
+ # -----------------------------------------------------------------------------
151
134
152
135
.PHONY : clean
153
136
clean :
@@ -159,26 +142,28 @@ clean:
159
142
@rm -f $(GOPATH ) /bin/$(PROGRAM_NAME ) || true
160
143
161
144
145
+ .PHONY : help
146
+ help :
147
+ @echo " Build $( PROGRAM_NAME) version $( BUILD_VERSION) -$( BUILD_ITERATION) " .
148
+ @echo " Makefile targets:"
149
+ @$(MAKE ) -pRrq -f $(firstword $(MAKEFILE_LIST ) ) : 2> /dev/null | awk -v RS= -F: ' /^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e ' ^[^[:alnum:]]' -e ' ^$@$$' | xargs
150
+
151
+
162
152
.PHONY : print-make-variables
163
153
print-make-variables :
164
154
@$(foreach V,$(sort $(.VARIABLES ) ) , \
165
155
$(if $(filter-out environment% default automatic, \
166
156
$(origin $V ) ),$(warning $V=$($V ) ($(value $V) ) )))
167
157
168
- # -----------------------------------------------------------------------------
169
- # Help
170
- # -----------------------------------------------------------------------------
171
158
172
- .PHONY : help
173
- help :
174
- @echo " Build $( PROGRAM_NAME ) version $( BUILD_VERSION ) - $( BUILD_ITERATION ) " .
175
- @echo " Makefile targets: "
176
- @$( MAKE ) -pRrq -f $( firstword $( MAKEFILE_LIST ) ) : 2> /dev/null | awk -v RS= -F: ' /^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}} ' | sort | egrep -v -e ' ^[^[:alnum:]] ' -e ' ^$@$$ ' | xargs
159
+ .PHONY : setup
160
+ setup :
161
+ @rm -rf /tmp/sqlite
162
+ @mkdir /tmp/sqlite
163
+ @cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db
177
164
178
- # -----------------------------------------------------------------------------
179
- # Optionally include platform-specific settings and targets.
180
- # - Note: This is last because the "last one wins" when over-writing targets.
181
- # -----------------------------------------------------------------------------
182
165
183
- # -include Makefile.$(OSTYPE)
184
- # -include Makefile.$(OSTYPE)_$(OSARCH)
166
+ .PHONY : update-pkg-cache
167
+ update-pkg-cache :
168
+ @GOPROXY=https://proxy.golang.org GO111MODULE=on \
169
+ go get $(GO_PACKAGE_NAME ) @$(BUILD_TAG )
0 commit comments