# Define AGENT_OS if not present.
if [ -z "${AGENT_OS+1}" ]; then
  AGENT_OS=$(uname -s)
fi

# It seems that protoc really wants its dependencies to be in /usr/local/lib.
# In some setups, e.g., Azure pipelines, this does not work, so we need to help
# it find its dynamic libraries.
if [ "${AGENT_OS?}" == "Darwin" ]; then
  install_name_tool \
      -change \
          /usr/local/lib/libprotobuf.17.dylib \
          ./deps/protobuf/src/.libs/libprotobuf.17.dylib \
      deps/protobuf/src/.libs/libprotoc.17.dylib
  install_name_tool \
      -change \
          /usr/local/lib/libprotobuf.17.dylib \
          ./deps/protobuf/src/.libs/libprotobuf.17.dylib \
      deps/protobuf/src/.libs/protoc
  install_name_tool \
      -change \
          /usr/local/lib/libprotoc.17.dylib \
          ./deps/protobuf/src/.libs/libprotoc.17.dylib \
      deps/protobuf/src/.libs/protoc
elif [ "${AGENT_OS?}" == "Linux" ]; then
  export LD_LIBRARY_PATH="./deps/protobuf/src/.libs:$LD_LIBRARY_PATH"
fi

make test
make release

# It seems that protoc really wants its dependencies to be in /usr/local/lib.
# In some setups, e.g., Azure pipelines, this does not work, so we need to help
# it find its dynamic libraries.
if [ "${AGENT_OS?}" == "Darwin" ]; then
  install_name_tool \
      -change \
          /usr/local/lib/libprotobuf.17.dylib \
          ./deps/protobuf/src/.libs/libprotobuf.17.dylib \
      deps/protobuf/src/.libs/libprotoc.17.dylib
  install_name_tool \
      -change \
          /usr/local/lib/libprotobuf.17.dylib \
          ./deps/protobuf/src/.libs/libprotobuf.17.dylib \
      deps/protobuf/src/.libs/protoc
  install_name_tool \
      -change \
          /usr/local/lib/libprotoc.17.dylib \
          ./deps/protobuf/src/.libs/libprotoc.17.dylib \
      deps/protobuf/src/.libs/protoc
elif [ "${AGENT_OS?}" == "Linux" ]; then
  export LD_LIBRARY_PATH="./deps/protobuf/src/.libs:$LD_LIBRARY_PATH"
fi

make test
make release

Revert "Define AGENT_OS if not present in make script."
Revert "Define AGENT_OS if not present in make script."

This reverts commit 7f636b938b0d7be099b6ffb13a026580ad4bb5f0.
