[maven] IDEA-313767 refactoring: simplify scheduleResolve()
[idea/community.git] / native / fsNotifier / linux / make.sh
1 #!/bin/bash
2 # Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
3 set -euo pipefail
4
5 VER="${1:-}"
6 if [ -z "${VER:-}" ]; then
7   VER=$(date "+%Y%m%d.%H%M")
8 fi
9
10 rm -f fsnotifier
11 ${CC:-clang} -O2 -Wall -Wextra -Wpedantic -D "VERSION=\"$VER\"" -std=c11 main.c inotify.c util.c -o fsnotifier
12 chmod 755 fsnotifier
13
14 # ensuring supported builds are compatible with RHEL/CentOS 7
15 MAX_GLIBC_VERSION="2.17"
16 ARCH=$(uname -m)
17 if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ] || [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
18   glibc_version="$(objdump -x fsnotifier | grep -o "GLIBC_.*" | sort | uniq | cut -d _ -f 2 | sort -V | tail -n 1)"
19   newest=$(printf "%s\n%s\n" "$MAX_GLIBC_VERSION" "$glibc_version" | sort -V | tail -n 1)
20   if [ "$newest" != "$MAX_GLIBC_VERSION" ]; then
21     echo "ERROR: fsnotifier uses glibc version $glibc_version which is newer than $MAX_GLIBC_VERSION"
22     exit 1
23   fi
24 fi