uClibc_config_fix.pl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #!/usr/bin/perl
  2. # Silly script to fixup the uClibc config file
  3. # (c) Erik Andersen <andersee@codepoet.org>
  4. #
  5. # This program is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU General Public License as published by the
  7. # Free Software Foundation; either version 2 of the License, or (at your
  8. # option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. # The easiest way to use this script is to put something like this in
  19. # your Makefile for building uClibc... Adjust config optiongs to
  20. # taste of course.... And of course you will want to add some defines
  21. # into your Makefile to set ARCH, STAGING_DIR, KERNEL_DIR, and whatnot.
  22. #
  23. # $(UCLIBC_DIR)/extra/Configs/uClibc_config_fix.pl --arch=$(ARCH) --cross="$(CROSS)" \
  24. # --devel_prefix=$(STAGING_DIR) --kernel_dir=$(KERNEL_DIR) --large_file=false \
  25. # --rpc_support=true --c99_math=true --shared_support=true --ldso_path="/lib" \
  26. # --shadow=true --file=$(UCLIBC_DIR)/extra/Configs/Config.$(ARCH) > $(UCLIBC_DIR)/Config;
  27. #
  28. # Have fun,
  29. # -Erik
  30. #
  31. use strict;
  32. use Getopt::Long;
  33. # User Specified variables (commandline)
  34. my($arch) = "";
  35. my($cross) = "";
  36. my($xcc) = "";
  37. my($native_cc) = "";
  38. my($debug) = "";
  39. my($mmu) = "";
  40. my($large_file) = "";
  41. my($rpc_support) = "";
  42. my($c99_math) = "";
  43. my($float) = "";
  44. my($threads) = "";
  45. my($shadow) = "";
  46. my($filename) = "";
  47. my($shared_support) = "";
  48. my($kernel_dir) = "";
  49. my($devel_prefix) = "";
  50. my($ldso_path) = "";
  51. my($line);
  52. my($got_arch);
  53. # Get commandline parameters
  54. Getopt::Long::Configure("no_ignore_case", "bundling");
  55. &GetOptions( "arch=s" => \$arch,
  56. "cross=s" => \$cross,
  57. "cc=s" => \$xcc,
  58. "native_cc=s" => \$native_cc,
  59. "devel_prefix=s" => \$devel_prefix,
  60. "kernel_dir=s" => \$kernel_dir,
  61. "debug=s" => \$debug,
  62. "mmu=s" => \$mmu,
  63. "large_file=s" => \$large_file,
  64. "rpc_support=s" => \$rpc_support,
  65. "c99_math=s" => \$c99_math,
  66. "float=s" => \$float,
  67. "threads=s" => \$threads,
  68. "shadow=s" => \$shadow,
  69. "shared_support=s" => \$shared_support,
  70. "ldso_path=s" => \$ldso_path,
  71. "file=s" => \$filename,
  72. );
  73. chomp($arch);
  74. chomp($cross);
  75. chomp($xcc);
  76. chomp($native_cc);
  77. chomp($devel_prefix);
  78. chomp($kernel_dir);
  79. chomp($debug);
  80. chomp($mmu);
  81. chomp($large_file);
  82. chomp($rpc_support);
  83. chomp($c99_math);
  84. chomp($float);
  85. chomp($threads);
  86. chomp($shadow);
  87. chomp($shared_support);
  88. chomp($ldso_path);
  89. chomp($filename);
  90. if ($filename) {
  91. open(FILE,"<$filename") or
  92. die "(fatal) Can't open $filename:$!";
  93. } else {
  94. die "(fatal) Please give me a --file argument$!";
  95. }
  96. while($line = <FILE>) {
  97. if ($arch && $line =~ /^TARGET_ARCH.*/) {
  98. print "TARGET_ARCH=$arch\n";
  99. $got_arch=1;
  100. next;
  101. }
  102. if ($cross && $line =~ /^CROSS.*/) {
  103. print "CROSS=$cross\n";
  104. next;
  105. }
  106. if ($xcc && $line =~ /^CC.*/) {
  107. print "CC=$xcc\n";
  108. next;
  109. }
  110. if ($native_cc && $line =~ /^NATIVE_CC.*/) {
  111. print "NATIVE_CC=$native_cc\n";
  112. next;
  113. }
  114. if ($devel_prefix && $line =~ /^DEVEL_PREFIX.*/) {
  115. print "DEVEL_PREFIX=$devel_prefix\n";
  116. next;
  117. }
  118. if ($kernel_dir && $line =~ /^KERNEL_SOURCE.*/) {
  119. print "KERNEL_SOURCE=$kernel_dir\n";
  120. next;
  121. }
  122. if ($debug && $line =~ /^DODEBUG.*/) {
  123. print "DODEBUG=$debug\n";
  124. next;
  125. }
  126. if ($mmu && $line =~ /^HAS_MMU.*/) {
  127. print "HAS_MMU=$mmu\n";
  128. next;
  129. }
  130. if ($large_file && $line =~ /^DOLFS.*/) {
  131. print "DOLFS=$large_file\n";
  132. next;
  133. }
  134. if ($rpc_support && $line =~ /^INCLUDE_RPC.*/) {
  135. print "INCLUDE_RPC=$rpc_support\n";
  136. next;
  137. }
  138. if ($shadow && $line =~ /^HAS_SHADOW.*/) {
  139. print "HAS_SHADOW=$shadow\n";
  140. next;
  141. }
  142. if ($c99_math && $line =~ /^DO_C99_MATH.*/) {
  143. print "DO_C99_MATH=$c99_math\n";
  144. next;
  145. }
  146. if ($float && $line =~ /^HAS_FLOATING_POINT.*/) {
  147. print "HAS_FLOATING_POINT=$float\n";
  148. next;
  149. }
  150. if ($threads && $line =~ /^INCLUDE_THREADS.*/) {
  151. print "INCLUDE_THREADS=$threads\n";
  152. next;
  153. }
  154. if ($shared_support && $shared_support =~ /true/ ) {
  155. if ($line =~ /^BUILD_UCLIBC_LDSO.*/) {
  156. print "BUILD_UCLIBC_LDSO=true\n";
  157. next;
  158. }
  159. if ($line =~ /^HAVE_SHARED.*/) {
  160. print "HAVE_SHARED=true\n";
  161. next;
  162. }
  163. # Force PIC to be true when HAVE_SHARED is true
  164. if ($line =~ /^DOPIC.*/) {
  165. print "DOPIC=true\n";
  166. next;
  167. }
  168. if ($ldso_path && $line =~ /^SHARED_LIB_LOADER_PATH.*/) {
  169. print "SHARED_LIB_LOADER_PATH=$ldso_path\n";
  170. next;
  171. }
  172. } else {
  173. if ($line =~ /^BUILD_UCLIBC_LDSO.*/) {
  174. print "BUILD_UCLIBC_LDSO=false\n";
  175. next;
  176. }
  177. if ($line =~ /^HAVE_SHARED.*/) {
  178. print "HAVE_SHARED=false\n";
  179. next;
  180. }
  181. if ($line =~ /^DOPIC.*/) {
  182. print "DOPIC=false\n";
  183. next;
  184. }
  185. }
  186. print "$line";
  187. }
  188. if ($arch && ! $got_arch) {
  189. print "TARGET_ARCH=$arch\n";
  190. }