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.

218 lines
6.5 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 - 2016 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. var_append configcache ' ' 'ac_cv_header_sys_sysctl_h=no'
  27. fi
  28. # the most tipical fix is to config.sub
  29. #
  30. musl_fix_configsub() {
  31. local x; for x; do
  32. echo_warning "Adding linux-musl target support to $x"
  33. echo "musl_fix_configsub: adding musl_arch_target support to $x"
  34. cp -f $x $x.orig
  35. sed -e 's,\([-]\?linux\)-gnu\*,\1-gnu\* | \1-musl\*,g' $x.orig > $x
  36. diff -u $x.orig $x || true
  37. done
  38. }
  39. musl_auto_fix_configsub() {
  40. local f
  41. for f in . ./build-aux ./config ./support; do
  42. if [ -e $f/config.sub ] ; then
  43. if ! grep -q '\-musl' $f/config.sub; then
  44. musl_fix_configsub $f/config.sub
  45. fi
  46. fi
  47. done
  48. }
  49. musl_findall_fix_configsub() {
  50. local f
  51. for f in `find . -name config.sub`; do
  52. musl_fix_configsub $f
  53. done
  54. }
  55. # FIXME: i forgot what makes musl_fix_addcases different than musl_fix_configsub //mnemoc
  56. musl_fix_addcases() {
  57. local file; for file; do
  58. echo "musl_fix_addcases: adding *-linux-musl* support to $file"
  59. cp -f $file $file.orig
  60. sed -i -e 's,\([^ ]*\)linux-gnu\*\(.*\)\([\)\\]\),\1linux-gnu* | \1linux-musl*\2\3,g' $file
  61. diff -u $file.orig $file || true
  62. done
  63. }
  64. musl_fix_addcases2() {
  65. local file; for file; do
  66. echo "musl_fix_addcases2: adding *-linux-musl* support to $file"
  67. cp -f $file $file.orig
  68. sed -i -e 's,\( *.*\)linux-gnu\*)\(.*\)\;\;$,\1linux-musl*)\2;;\n\1linux-gnu*)\2;;,g' \
  69. -e 's,\( *.*\)linux-gnu\*)\(.*[^;][^;]\)$,\1linux-musl* \| \\\n\1linux-gnu*)\2,g' \
  70. $file
  71. diff -u $file.orig $file || true
  72. done
  73. }
  74. # fix typical locations
  75. hook_add postpatch 5 'musl_auto_fix_configsub'
  76. # fix issues with included gnulib
  77. # http://openwall.com/lists/musl/2012/06/19/13
  78. musl_fix_gnulib() {
  79. local dir="$1"
  80. echo_status "fixing gnulib weirdness in $dir"
  81. gl_config_cache="
  82. gl_cv_func_fflush_stdin=yes \
  83. gl_cv_func_fprintf_posix=yes \
  84. gl_cv_func_fpurge_works=yes \
  85. gl_cv_func_fseeko=yes \
  86. gl_cv_func_isnanl_works=yes \
  87. gl_cv_header_working_stdint_h=yes \
  88. gl_cv_func_fpurge_works=yes \
  89. gl_cv_func_fcntl_f_dupfd_cloexec=yes \
  90. gl_cv_func_getcwd_path_max=yes \
  91. gl_cv_func_fprintf_posix=yes \
  92. gl_cv_func_printf_sizes_c99=yes \
  93. gl_cv_func_printf_long_double=yes \
  94. gl_cv_func_printf_infinite=yes \
  95. gl_cv_func_printf_infinite_long_double=yes \
  96. gl_cv_func_printf_directive_a=yes \
  97. gl_cv_func_printf_directive_f=yes \
  98. gl_cv_func_printf_directive_n=yes \
  99. gl_cv_func_printf_directive_ls=yes \
  100. gl_cv_func_printf_positions=yes \
  101. gl_cv_func_printf_flag_grouping=yes \
  102. gl_cv_func_printf_flag_leftadjust=yes \
  103. gl_cv_func_printf_flag_zero=yes \
  104. gl_cv_func_printf_precision=yes \
  105. gl_cv_func_printf_enomem=yes"
  106. for x in $gl_config_cache; do
  107. var_append configcache ' ' "$x"
  108. done
  109. empty_file() {
  110. echo "gnulib fix: emptying file $1"
  111. rm -f $1
  112. touch $1
  113. }
  114. for x in fseterr.c freadahead.c fseeko.c; do
  115. empty_file "$dir/$x"
  116. done
  117. echo "void close_stdin(void) {}" > "$dir"/closein.c
  118. echo "#include <stdio_ext.h>" > "$dir"/fseterr.h
  119. echo "#define fseterr(fp) __fseterr (fp)" >> "$dir"/fseterr.h
  120. echo "#include "fseterr.h"" > "$dir"/fsetserr.c
  121. }
  122. #fix libiberty because we already have a libc, thanks...
  123. musl_fix_libiberty() {
  124. empty_file() {
  125. echo "libiberty fix: emptying file $1"
  126. rm -f $1
  127. touch $1
  128. }
  129. local dir="$1"
  130. echo_status "fixing libiberty weirdness in $dir"
  131. culprits="getcwd strtoul clock strncasecmp fnmatch waitpid \
  132. basename strchr snprintf rindex index memcpy mempcpy \
  133. strcasecmp strsignal vsprintf strndup bcmp tmpnam bzero \
  134. stpncpy memchr insque ffs vfork memmove stpcpy bsearch \
  135. copysign strtod vsnprintf strncmp strtol bcopy rename strstr \
  136. strerror putenv strdup memset memcmp vprintf calloc gettimeofday \
  137. atexit getpagesize strverscmp random setenv strrchr asprintf msdos \
  138. vasprintf vfprintf"
  139. for i in $culprits ; do empty_file "$dir"/$i.c ; done
  140. }
  141. # and some others
  142. case "$pkg" in
  143. binutils)
  144. hook_add postpatch 4 'musl_fix_addcases ./bfd/config.bfd ./bfd/configure \
  145. ./ld/configure.tgt'
  146. hook_add postpatch 5 'musl_fix_addcases2 ./gas/configure'
  147. hook_add postpatch 6 'musl_fix_libiberty libiberty'
  148. ;;
  149. gmp)
  150. hook_add postpatch 6 'musl_fix_configsub configfsf.sub'
  151. ;;
  152. lzo|lzop|lvm2)
  153. hook_add postpatch 6 'musl_fix_configsub autoconf/config.sub'
  154. ;;
  155. expat)
  156. hook_add postpatch 6 'musl_fix_configsub conftools/config.sub'
  157. ;;
  158. bdb)
  159. hook_add postpatch 6 'musl_fix_configsub dist/config.sub'
  160. ;;
  161. libtool)
  162. hook_add preconf 9 'musl_findall_fix_configsub'
  163. ;;
  164. # packages to fix gnulib weirdness
  165. gzip|m4)
  166. hook_add preconf 9 'musl_fix_gnulib lib'
  167. ;;
  168. findutils)
  169. hook_add preconf 9 'musl_fix_gnulib gl/lib'
  170. ;;
  171. gcc)
  172. hook_add postpatch 6 'musl_fix_libiberty libiberty'
  173. ;;
  174. esac
  175. # same package translations to look for patches
  176. case "$pkg" in
  177. *)
  178. pkg_musl_pkg=${pkg} ;;
  179. esac
  180. if atstage toolchain; then
  181. pkg_musl_toolchain_patches=$( ls -1 $pkg_musl_dir/pkg/$pkg_musl_pkg/*.patch.toolchain 2> /dev/null | tr '\n' ' ' )
  182. if [ -n "$pkg_musl_toolchain_patches" ]; then
  183. echo_status "Appending musl libc specific toolchain patches"
  184. var_append patchfiles ' ' "$pkg_musl_toolchain_patches"
  185. fi
  186. fi
  187. pkg_musl_patches=$( ls -1 $pkg_musl_dir/pkg/$pkg_musl_pkg/*.patch 2> /dev/null | tr '\n' ' ' )
  188. if [ -n "$pkg_musl_patches" ]; then
  189. echo_status "Appending musl libc specific patches"
  190. var_append patchfiles ' ' "$pkg_musl_patches"
  191. fi
  192. if [ -f $pkg_musl_dir/pkg/$pkg/$pkg.conf ]; then
  193. . $pkg_musl_dir/pkg/$pkg/$pkg.conf
  194. fi
  195. fi