.pre-build: mkdir -p bin/ BIN=bin/lw_android_agent # all=表示对所有go包应用后面的表示标志 # -N 禁用优化 # -l 禁用内联 # -ldflags 用来设置链接器的标志 # -X 在编译时设置包中的变量的值 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) ./cmd/agent $(BIN) -v | tee version 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) ./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