OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
7.2 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/parse-config-9
  5. # Copyright (C) 2012 - 2014 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- SDE-COPYRIGHT-NOTE-END ---
  14. if [ "$SDECFG_LIBC" == "musl" ]; then
  15. pkg_musl_dir=$base/package/base/musl
  16. if [ $pkg != "gettext" ]; then
  17. var_append flistdel "|" "usr/share/locale/locale.alias"
  18. fi
  19. # I don't know what this is for //morfoh
  20. var_append flistdel "|" "$( echo $libdir | cut -d '/' -f2- )/charset.alias"
  21. # cross-compiling help
  22. if atstage cross; then
  23. # assuming a gnu compatible malloc, realloc
  24. var_append configcache ' ' 'ac_cv_func_malloc_0_nonnull=yes'
  25. var_append configcache ' ' 'ac_cv_func_realloc_0_nonnull=yes'
  26. fi
  27. # the most tipical fix is to config.sub
  28. #
  29. musl_fix_configsub() {
  30. local x; for x; do
  31. echo_warning "Adding linux-musl target support to $x"
  32. echo "musl_fix_configsub: adding musl_arch_target support to $x"
  33. cp -f $x $x.orig
  34. sed -e 's,\([-]\?linux\)-gnu\*,\1-gnu\* | \1-musl\*,g' $x.orig > $x
  35. diff -u $x.orig $x || true
  36. done
  37. }
  38. musl_auto_fix_configsub() {
  39. local f
  40. for f in . ./build-aux ./config ./support; do
  41. if [ -e $f/config.sub ] ; then
  42. if ! grep -q '\-musl' $f/config.sub; then
  43. musl_fix_configsub $f/config.sub
  44. fi
  45. fi
  46. done
  47. }
  48. musl_findall_fix_configsub() {
  49. local f
  50. for f in `find . -name config.sub`; do
  51. musl_fix_configsub $f
  52. done
  53. }
  54. # FIXME: i forgot what makes musl_fix_addcases different than musl_fix_configsub //mnemoc
  55. musl_fix_addcases() {
  56. local file; for file; do
  57. echo "musl_fix_addcases: adding *-linux-musl* support to $file"
  58. cp -f $file $file.orig
  59. sed -i -e 's,\([^ ]*\)linux-gnu\*\(.*\)\([\)\\]\),\1linux-gnu* | \1linux-musl*\2\3,g' $file
  60. diff -u $file.orig $file || true
  61. done
  62. }
  63. musl_fix_addcases2() {
  64. local file; for file; do
  65. echo "musl_fix_addcases2: adding *-linux-musl* support to $file"
  66. cp -f $file $file.orig
  67. sed -i -e 's,\( *.*\)linux-gnu\*)\(.*\)\;\;$,\1linux-musl*)\2;;\n\1linux-gnu*)\2;;,g' \
  68. -e 's,\( *.*\)linux-gnu\*)\(.*[^;][^;]\)$,\1linux-musl* \| \\\n\1linux-gnu*)\2,g' \
  69. $file
  70. diff -u $file.orig $file || true
  71. done
  72. }
  73. # fix typical locations
  74. hook_add postpatch 5 'musl_auto_fix_configsub'
  75. # fix issues with included gnulib
  76. # http://openwall.com/lists/musl/2012/06/19/13
  77. musl_fix_gnulib() {
  78. local dir="$1"
  79. echo_status "fixing gnulib weirdness in $dir"
  80. gl_config_cache="
  81. gl_cv_func_isnanl_works=yes \
  82. gl_cv_header_working_stdint_h=yes \
  83. gl_cv_func_fpurge_works=yes \
  84. gl_cv_func_fcntl_f_dupfd_cloexec=yes \
  85. gl_cv_func_getcwd_path_max=yes \
  86. gl_cv_func_fprintf_posix=yes \
  87. gl_cv_func_printf_sizes_c99=yes \
  88. gl_cv_func_printf_long_double=yes \
  89. gl_cv_func_printf_infinite=yes \
  90. gl_cv_func_printf_infinite_long_double=yes \
  91. gl_cv_func_printf_directive_a=yes \
  92. gl_cv_func_printf_directive_f=yes \
  93. gl_cv_func_printf_directive_n=yes \
  94. gl_cv_func_printf_directive_ls=yes \
  95. gl_cv_func_printf_positions=yes \
  96. gl_cv_func_printf_flag_grouping=yes \
  97. gl_cv_func_printf_flag_leftadjust=yes \
  98. gl_cv_func_printf_flag_zero=yes \
  99. gl_cv_func_printf_precision=yes \
  100. gl_cv_func_printf_enomem=yes"
  101. for x in $gl_config_cache; do
  102. var_append configcache ' ' "$x"
  103. done
  104. empty_file() {
  105. echo "gnulib fix: emptying file $1"
  106. rm -f $1
  107. touch $1
  108. }
  109. for x in fseterr.c freadahead.c fseeko.c; do
  110. empty_file "$dir/$x"
  111. done
  112. echo "void close_stdin(void) {}" > "$dir"/closein.c
  113. echo "#include <stdio_ext.h>" > "$dir"/fseterr.h
  114. echo "#define fseterr(fp) __fseterr (fp)" >> "$dir"/fseterr.h
  115. echo "#include "fseterr.h"" > "$dir"/fsetserr.c
  116. # fix stuff trying to reimplement libc
  117. culprits="accept4 acosl alloca alphasort asinl asprintf atanl \
  118. atexit atoll bcopy btowc chown closedir cosl dirfd \
  119. dprintf dup2 dup3 _Exit expl fchdir fchown-stub \
  120. fdatasync fdopendir ffs flock fnmatch forkpty fpending \
  121. fprintf freeaddrinfo fsync ftell ftruncate futimens \
  122. gai_strerror getaddrinfo getdelim getdtablesize \
  123. getgroups gethostname getline getlogin getlogin_r \
  124. getnameinfo getpagesize getpass getsubopt gettimeofday \
  125. getusershell gmtime_r grantpt imaxabs imaxdiv inet_ntop \
  126. inet_pton isblank iswblank lchmod lchown ldexp ldexpl \
  127. link linkat logl mbrlen mbrtowc mbsinit memmove mempcpy \
  128. mkdtemp mkfifo mkfifoat mknod mknodat mkstemp mktime \
  129. nanosleep nl_langinfo open openat opendir openpty pclose \
  130. perror pipe pipe2 poll popen pread pselect ptsname \
  131. pwrite raise readdir readlink renameat rewinddir setenv \
  132. sigaction sigaddset sigdelset sigemptyset sigfillset \
  133. sigismember sigpending sigprocmask sinl snprintf \
  134. spawnattr_destroy spawnattr_getdefault spawnattr_getflags \
  135. spawnattr_getpgroup spawnattr_getsigmask spawnattr_init \
  136. spawnattr_setdefault.c spawnattr_setflags spawnattr_setpgroup \
  137. spawnattr_setsigmask spawn_faction_addclose \
  138. spawn_faction_adddup2 spawn_faction_addopen \
  139. spawn_faction_destroy spawn_faction_init \
  140. spawn_factions_addopen spawn_factions_destroy \
  141. spawn_factions_init sprintf sqrtl stdio-read stdio-write \
  142. strcasecmp strcasestr strchrnul strcspn strncasecmp \
  143. strndup strnlen strpbrk strsep strsignal strstr strtod \
  144. strtoimax strtol symlink symlinkat tanl tcgetsid timegm \
  145. time_r times tmpfile uname unlockpt unsetenv usleep \
  146. vasprintf vdprintf waitpid wcrtomb wctob"
  147. #for x in $culprits ; do empty_file "$dir/$x.c" ; done
  148. }
  149. # and some others
  150. case "$pkg" in
  151. binutils)
  152. hook_add postpatch 4 'musl_fix_addcases ./bfd/config.bfd ./bfd/configure \
  153. ./bfd/configure.in ./ld/configure.tgt'
  154. hook_add postpatch 5 'musl_fix_addcases2 ./gas/configure ./gas/configure.in'
  155. ;;
  156. gmp)
  157. hook_add postpatch 6 'musl_fix_configsub configfsf.sub'
  158. ;;
  159. lzo|lzop|lvm2)
  160. hook_add postpatch 6 'musl_fix_configsub autoconf/config.sub'
  161. ;;
  162. expat)
  163. hook_add postpatch 6 'musl_fix_configsub conftools/config.sub'
  164. ;;
  165. bdb)
  166. hook_add postpatch 6 'musl_fix_configsub dist/config.sub'
  167. ;;
  168. libtool)
  169. hook_add preconf 9 'musl_findall_fix_configsub'
  170. ;;
  171. # packages to fix gnulib weirdness
  172. gzip|m4)
  173. hook_add preconf 9 'musl_fix_gnulib lib'
  174. ;;
  175. findutils)
  176. hook_add preconf 9 'musl_fix_gnulib gnulib/lib'
  177. ;;
  178. esac
  179. # same package translations to look for patches
  180. case "$pkg" in
  181. *)
  182. pkg_musl_pkg=${pkg} ;;
  183. esac
  184. if atstage toolchain; then
  185. pkg_musl_toolchain_patches=$( ls -1 $pkg_musl_dir/pkg/$pkg_musl_pkg/*.patch.toolchain 2> /dev/null | tr '\n' ' ' )
  186. if [ -n "$pkg_musl_toolchain_patches" ]; then
  187. echo_status "Appending musl libc specific toolchain patches"
  188. var_append patchfiles ' ' "$pkg_musl_toolchain_patches"
  189. fi
  190. fi
  191. pkg_musl_patches=$( ls -1 $pkg_musl_dir/pkg/$pkg_musl_pkg/*.patch 2> /dev/null | tr '\n' ' ' )
  192. if [ -n "$pkg_musl_patches" ]; then
  193. echo_status "Appending musl libc specific patches"
  194. var_append patchfiles ' ' "$pkg_musl_patches"
  195. fi
  196. if [ -f $pkg_musl_dir/pkg/$pkg/$pkg.conf ]; then
  197. . $pkg_musl_dir/pkg/$pkg/$pkg.conf
  198. fi
  199. fi