Commit 61e3b4c6 authored by Lei Li's avatar Lei Li
Browse files

feat: makefile支持多种编译选项

parent c99715d2
.pre-build: .pre-build:
mkdir -p bin/ mkdir -p bin/
BIN=bin/lw_android_agent
# all=表示对所有go包应用后面的表示标志 # all=表示对所有go包应用后面的表示标志
# -N 禁用优化 # -N 禁用优化
...@@ -7,9 +8,39 @@ ...@@ -7,9 +8,39 @@
# -ldflags 用来设置链接器的标志 # -ldflags 用来设置链接器的标志
# -X 在编译时设置包中的变量的值 # -X 在编译时设置包中的变量的值
build: .pre-build build: .pre-build
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/linkfog_agent ./cmd/agent 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/linkfog_agent -v | tee version $(BIN) -v | tee version
build-dev: .pre-build build-dev: .pre-build
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/linkfog_agent ./cmd/agent 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/linkfog_agent -v | tee version $(BIN) -v | tee version
\ No newline at end of file
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment