aboutsummaryrefslogtreecommitdiff
path: root/protoc-artifacts/build-protoc.sh
blob: 4e0e5498e796b0ebcdcdd0bb5cb506fe91a39f1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

cd $(dirname "$0")
WORKING_DIR=$(pwd)

# Override the default value set in configure.ac that has '-g' which produces
# huge binary.
export CXXFLAGS="-DNDEBUG"

# Statically link libgcc and libstdc++.
# -s to produce stripped binary
export LDFLAGS="-static-libgcc -static-libstdc++ -s"

# Under Cygwin we use MinGW GCC because the executable produced by Cygwin GCC
# depends on Cygwin DLL.
if [[ "$(uname)" == CYGWIN* ]]; then
  export CC=i686-pc-mingw32-gcc
  export CXX=i686-pc-mingw32-c++
  export CXXCPP=i686-pc-mingw32-cpp
fi

cd "$WORKING_DIR"/.. && ./configure --disable-shared && make clean && make &&
  cd "$WORKING_DIR" && mkdir -p target &&
  (cp ../src/protoc target/protoc.exe || cp ../src/protoc.exe target/protoc.exe)