Makefile 2.01 KB
Newer Older
“李磊”'s avatar
“李磊” committed
1
2
.pre-build:
	mkdir -p bin/
3
BIN=bin/lw_android_agent
“李磊”'s avatar
“李磊” committed
4
5
6
7
8
9
10

# all=表示对所有go包应用后面的表示标志
# -N 禁用优化
# -l 禁用内联
# -ldflags 用来设置链接器的标志
# -X 在编译时设置包中的变量的值
build: .pre-build
11
12
	go build -gcflags='all=-N -l' -ldflags "-X agent/cmd/agent/config.Version=`./branch_info.sh get_version` -X agent/cmd/agent/config.BuildCommit=`git rev-list -1 HEAD`" -o $(BIN) ./cmd/agent
	$(BIN) -v | tee version
Lei Li's avatar
Lei Li committed
13
14

build-dev: .pre-build
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
	go build -tags dev -gcflags='all=-N -l' -ldflags "-X agent/cmd/agent/config.Version=`./branch_info.sh get_version` -X agent/cmd/agent/config.BuildCommit=`git rev-list -1 HEAD`" -o $(BIN) ./cmd/agent
	$(BIN) -v | tee version


x86:
	export GOARCH=amd64 GOOS=linux GO111MODULE=on CGO_ENABLED=0 && go build  -a -ldflags '-extldflags "-static"'  -o $(BIN)_x86
	upx -9 $(BIN)_x86

arm:
	export GOARCH=arm GOOS=linux GO111MODULE=on CGO_ENABLED=0 CC=arm-linux-gnueabi-gcc  && go build -ldflags="-extldflags '-static' " -o $(BIN)
	upx -9 $(BIN)
	# ./updateVersion.sh lw_android_agent

android:
	#export GOARCH=arm GOOS=android GO111MODULE=on CGO_ENABLED=1 CC=/usr/local/android-ndk-r14b/android-14-toolchain/bin/arm-linux-androideabi-gcc
	export GOARCH=arm GOOS=android GO111MODULE=on CGO_ENABLED=1 CC=/usr/local/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi19-clang && go build -o $(BIN)_ndk
	upx -9 $(BIN)_ndk
	./updateVersion.sh lw_android_agent_ndk

test:
	export GOARCH=arm GOOS=linux GO111MODULE=on CGO_ENABLED=0 CC=arm-linux-gnueabi-gcc  && go build -ldflags="-extldflags '-static' " -o $(BIN).arm
	upx -9 $(BIN).arm

test-android:
	#export GOARCH=arm GOOS=android GO111MODULE=on CGO_ENABLED=1 CC=/usr/local/android-ndk-r14b/android-14-toolchain/bin/arm-linux-androideabi-gcc
	export GOARCH=arm GOOS=android GO111MODULE=on CGO_ENABLED=1 CC=/usr/local/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi19-clang && go build -o $(BIN)_ndk_test
	upx -9 $(BIN)_ndk_test



clean:
	$(RM) -r $(BIN).arm || true