alicelinux

A lightweight musl + clang/llvm + libressl + busybox distro
git clone https://codeberg.org/emmett1/alicelinux
Log | Files | Refs | README | LICENSE

portability.patch (9005B)


      1 diff --git a/configure b/configure
      2 index c1fb599..ad6eb33 100755
      3 --- a/configure
      4 +++ b/configure
      5 @@ -1,4 +1,4 @@
      6 -#!/bin/bash
      7 +#!/bin/sh
      8  
      9  if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
     10  cat <<EOF
     11 @@ -62,7 +62,7 @@ exit 1
     12  fi
     13  
     14  log_check() {
     15 -    echo -n "checking $1... " >> config.log
     16 +    echo "checking $1... " >> config.log
     17  }
     18  
     19  log_ok() {
     20 @@ -82,12 +82,12 @@ cc_cflags() {
     21      # suppress them by reducing the warning level rather than having to use #pragmas
     22      for arg in $*; do
     23          [[ "$arg" = -falign-loops* ]] && arg=
     24 +        case $arg in
     25 +            -falign-loops*|-mpreferred-stack-boundary*|-l*|-L*) arg=
     26 +        esac
     27          [ "$arg" = -fno-tree-vectorize ] && arg=
     28          [ "$arg" = -Wshadow ] && arg=
     29          [ "$arg" = -Wno-maybe-uninitialized ] && arg=
     30 -        [[ "$arg" = -mpreferred-stack-boundary* ]] && arg=
     31 -        [[ "$arg" = -l* ]] && arg=
     32 -        [[ "$arg" = -L* ]] && arg=
     33          if [ $compiler_style = MS ]; then
     34              [ "$arg" = -ffast-math ] && arg="-fp:fast"
     35              [ "$arg" = -Wall ] && arg=
     36 @@ -103,14 +103,14 @@ cc_cflags() {
     37          fi
     38          [ $compiler = CL -a "$arg" = -O3 ] && arg=-O2
     39  
     40 -        [ -n "$arg" ] && echo -n "$arg "
     41 +        [ -n "$arg" ] && printf %s "$arg "
     42      done
     43  }
     44  
     45  cl_ldflags() {
     46      for arg in $*; do
     47 -        arg=${arg/LIBPATH/libpath}
     48 -        [ "${arg#-libpath:}" == "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
     49 +        arg=$(echo "$arg" | sed -e 's/LIBPATH/libpath/')
     50 +        [ "${arg#-libpath:}" = "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
     51          [ "${arg#-L}" != "$arg" ] && arg=-libpath:${arg#-L}
     52          [ "$arg" = -Wl,--large-address-aware ] && arg=-largeaddressaware
     53          [ "$arg" = -s ] && arg=
     54 @@ -119,15 +119,17 @@ cl_ldflags() {
     55          [ "$arg" = -Werror ] && arg=
     56          [ "$arg" = -Wshadow ] && arg=
     57          [ "$arg" = -Wmaybe-uninitialized ] && arg=
     58 -        [[ "$arg" = -Qdiag-error* ]] && arg=
     59 +        case $arg in
     60 +            -Qdiag-error*) arg=
     61 +        esac
     62  
     63 -        arg=${arg/pthreadGC/pthreadVC}
     64 +        arg=$(echo "$arg" | sed -e 's/pthreadGC/pthreadVC/')
     65          [ "$arg" = avifil32.lib ] && arg=vfw32.lib
     66          [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
     67          [ "$arg" = gpac.lib ] && arg=libgpac.lib
     68          [ "$arg" = x264.lib ] && arg=libx264.lib
     69  
     70 -        [ -n "$arg" ] && echo -n "$arg "
     71 +        [ -n "$arg" ] && printf %s "$arg "
     72      done
     73  }
     74  
     75 @@ -191,7 +193,7 @@ cpp_check() {
     76      for arg in $1; do
     77          echo "#include <$arg>" >> conftest.c
     78      done
     79 -    echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
     80 +    printf '%b\n' "#if !($3) \n#error $4 \n#endif " >> conftest.c
     81      if [ $compiler_style = MS ]; then
     82          cpp_cmd="$CC conftest.c $(cc_cflags $CFLAGS $2) -P"
     83      else
     84 @@ -340,11 +342,15 @@ rm -rf conftest*
     85  
     86  # Construct a path to the specified directory relative to the working directory
     87  relative_path() {
     88 -    local base="${PWD%/}"
     89 -    local path="$(cd "$1" >/dev/null; printf '%s/.' "${PWD%/}")"
     90 -    local up=''
     91 +    base="${PWD%/}"
     92 +    path="$(cd "$1" >/dev/null; printf '%s/.' "${PWD%/}")"
     93 +    up=''
     94 +
     95 +    while :; do
     96 +        case $path in
     97 +            "$base/"*) break ;;
     98 +        esac
     99  
    100 -    while [[ $path != "$base/"* ]]; do
    101          base="${base%/*}"
    102          up="../$up"
    103      done
    104 @@ -590,48 +596,6 @@ trap 'rm -rf conftest*' EXIT
    105  # test for use of compilers that require specific handling
    106  cc_base="$(basename "$CC")"
    107  QPRE="-"
    108 -if [[ $host_os = mingw* || $host_os = msys* || $host_os = cygwin* ]]; then
    109 -    if [[ "$cc_base" = icl || "$cc_base" = icl[\ .]* ]]; then
    110 -        # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
    111 -        [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
    112 -        compiler=ICL
    113 -        compiler_style=MS
    114 -        CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -I\$(SRCPATH)/extras"
    115 -        QPRE="-Q"
    116 -        cpp_check '' '' '_MSC_VER >= 1400' || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
    117 -        if cpp_check '' '' 'defined(_M_AMD64) || defined(_M_X64)' ; then
    118 -            host_cpu=x86_64
    119 -        elif cpp_check '' '' 'defined(_M_IX86)' ; then
    120 -            host_cpu=i486
    121 -        fi
    122 -        if cc_check '' -Qdiag-error:10006,10157 ; then
    123 -            CHECK_CFLAGS="$CHECK_CFLAGS -Qdiag-error:10006,10157"
    124 -        fi
    125 -    elif [[ "$cc_base" = cl || "$cc_base" = cl[\ .]* ]]; then
    126 -        # Standard Microsoft Visual Studio
    127 -        compiler=CL
    128 -        compiler_style=MS
    129 -        CFLAGS="$CFLAGS -nologo -GS- -DHAVE_STRING_H -I\$(SRCPATH)/extras"
    130 -        cpp_check '' '' '_MSC_VER > 1800 || (_MSC_VER == 1800 && _MSC_FULL_VER >= 180030324)' || die "Microsoft Visual Studio support requires Visual Studio 2013 Update 2 or newer"
    131 -        if cpp_check '' '' 'defined(_M_AMD64) || defined(_M_X64)' ; then
    132 -            host_cpu=x86_64
    133 -        elif cpp_check '' '' 'defined(_M_IX86)' ; then
    134 -            host_cpu=i486
    135 -        elif cpp_check '' '' 'defined(_M_ARM64)' ; then
    136 -            host_cpu=aarch64
    137 -        elif cpp_check '' '' 'defined(_M_ARM)' ; then
    138 -            host_cpu=arm
    139 -        fi
    140 -    else
    141 -        # MinGW uses broken pre-VS2015 Microsoft printf functions unless it's told to use the POSIX ones.
    142 -        CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
    143 -    fi
    144 -else
    145 -    if [[ "$cc_base" = icc || "$cc_base" = icc[\ .]* ]]; then
    146 -        AR="xiar"
    147 -        compiler=ICC
    148 -    fi
    149 -fi
    150  
    151  if [ $compiler = GNU ]; then
    152      if cc_check '' -Werror=unknown-warning-option ; then
    153 @@ -688,18 +652,6 @@ case $host_os in
    154          define HAVE_MALLOC_H
    155          libm="-lm"
    156          ;;
    157 -    cygwin*|mingw*|msys*)
    158 -        EXE=".exe"
    159 -        if [[ $host_os = cygwin* ]] && cpp_check "" "" "defined(__CYGWIN__)" ; then
    160 -            SYS="CYGWIN"
    161 -            define HAVE_MALLOC_H
    162 -        else
    163 -            SYS="WINDOWS"
    164 -            DEVNULL="NUL"
    165 -            cc_check '' -lshell32 && LDFLAGSCLI="$LDFLAGSCLI -lshell32"
    166 -            [ $compiler = GNU ] && RC="${RC-${cross_prefix}windres}" || RC="${RC-rc.exe}"
    167 -        fi
    168 -        ;;
    169      sunos*|solaris*)
    170          SYS="SunOS"
    171          define HAVE_MALLOC_H
    172 @@ -740,30 +692,6 @@ LDFLAGS="$LDFLAGS $libm"
    173  stack_alignment=4
    174  case $host_cpu in
    175      i*86)
    176 -        ARCH="X86"
    177 -        AS="${AS-nasm}"
    178 -        AS_EXT=".asm"
    179 -        ASFLAGS="$ASFLAGS -DARCH_X86_64=0 -I\$(SRCPATH)/common/x86/"
    180 -        if [ $compiler = GNU ]; then
    181 -            if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
    182 -                CFLAGS="$CFLAGS -march=i686"
    183 -            fi
    184 -            if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
    185 -                CFLAGS="$CFLAGS -mfpmath=sse -msse -msse2"
    186 -            fi
    187 -            CFLAGS="-m32 $CFLAGS"
    188 -            LDFLAGS="-m32 $LDFLAGS"
    189 -        fi
    190 -        if [ "$SYS" = MACOSX ]; then
    191 -            ASFLAGS="$ASFLAGS -f macho32 -DPREFIX"
    192 -        elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
    193 -            ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
    194 -            LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
    195 -            [ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
    196 -            [ $compiler = GNU ] && RCFLAGS="--target=pe-i386 $RCFLAGS"
    197 -        else
    198 -            ASFLAGS="$ASFLAGS -f elf32"
    199 -        fi
    200          ;;
    201      x86_64)
    202          ARCH="X86_64"
    203 @@ -979,7 +907,7 @@ fi
    204  
    205  if [ $asm = auto -a $ARCH = ARM ] ; then
    206      # set flags so neon is built by default
    207 -    [ $compiler == CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
    208 +    [ $compiler = CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
    209  
    210      cc_check '' '' '__asm__("add r0, r1, r2");' && define HAVE_ARM_INLINE_ASM
    211      if [ $compiler = CL ] && cpp_check '' '' 'defined(_M_ARM) && _M_ARM >= 7' ; then
    212 @@ -1690,7 +1618,8 @@ cat conftest.log >> config.log
    213  cat conftest.log
    214  
    215  [ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
    216 -mkdir -p common/{aarch64,arm,mips,ppc,x86,loongarch} encoder extras filters/video input output tools
    217 +mkdir -p common/aarch64 common/arm common/mips common/ppc common/x86
    218 +mkdir -p encoder extras filters/video input output tools
    219  
    220  echo
    221  echo "You can run 'make' or 'make fprofiled' now."
    222 diff --git a/tools/cltostr.sh b/tools/cltostr.sh
    223 index 23b6cc7..3feaafe 100755
    224 --- a/tools/cltostr.sh
    225 +++ b/tools/cltostr.sh
    226 @@ -18,7 +18,7 @@ dump() {
    227  }
    228  
    229  # Print MD5 hash w/o newline character to not embed the character in the array.
    230 -hash() {
    231 +_hash() {
    232      # md5sum is not standard, so try different platform-specific alternatives.
    233      { md5sum "$1" || md5 -q "$1" || digest -a md5 "$1"; } 2>/dev/null |
    234          cut -b -32 | tr -d '\n\r'
    235 @@ -29,5 +29,5 @@ trap 'rm -f "$1.temp"' EXIT
    236  sanitize | tee "$1.temp" |
    237      dump 'x264_opencl_source' > "$1"
    238  
    239 -hash "$1.temp" |
    240 +_hash "$1.temp" |
    241      dump 'x264_opencl_source_hash' >> "$1"