uClibc_config_fix.pl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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($long_long) = "";
  44. my($float) = "";
  45. my($threads) = "";
  46. my($shadow) = "";
  47. my($filename) = "";
  48. my($shared_support) = "";
  49. my($kernel_dir) = "";
  50. my($devel_prefix) = "";
  51. my($ldso_path) = "";
  52. my($line);
  53. my($got_arch);
  54. # Get commandline parameters
  55. Getopt::Long::Configure("no_ignore_case", "bundling");
  56. &GetOptions( "arch=s" => \$arch,
  57. "cross=s" => \$cross,
  58. "cc=s" => \$xcc,
  59. "native_cc=s" => \$native_cc,
  60. "devel_prefix=s" => \$devel_prefix,
  61. "kernel_dir=s" => \$kernel_dir,
  62. "debug=s" => \$debug,
  63. "mmu=s" => \$mmu,
  64. "large_file=s" => \$large_file,
  65. "rpc_support=s" => \$rpc_support,
  66. "c99_math=s" => \$c99_math,
  67. "long_long=s" => \$long_long,
  68. "float=s" => \$float,
  69. "threads=s" => \$threads,
  70. "shadow=s" => \$shadow,
  71. "shared_support=s" => \$shared_support,
  72. "ldso_path=s" => \$ldso_path,
  73. "file=s" => \$filename,
  74. );
  75. chomp($arch);
  76. chomp($cross);
  77. chomp($xcc);
  78. chomp($native_cc);
  79. chomp($devel_prefix);
  80. chomp($kernel_dir);
  81. chomp($debug);
  82. chomp($mmu);
  83. chomp($large_file);
  84. chomp($rpc_support);
  85. chomp($c99_math);
  86. chomp($long_long);
  87. chomp($float);
  88. chomp($threads);
  89. chomp($shadow);
  90. chomp($shared_support);
  91. chomp($ldso_path);
  92. chomp($filename);
  93. if ($filename) {
  94. open(FILE,"<$filename") or
  95. die "(fatal) Can't open $filename:$!";
  96. } else {
  97. die "(fatal) Please give me a --file argument$!";
  98. }
  99. while($line = <FILE>) {
  100. if ($arch && $line =~ /^TARGET_ARCH.*/) {
  101. print "TARGET_ARCH=$arch\n";
  102. $got_arch=1;
  103. next;
  104. }
  105. if ($cross && $line =~ /^CROSS.*/) {
  106. print "CROSS=$cross\n";
  107. next;
  108. }
  109. if ($xcc && $line =~ /^CC.*/) {
  110. print "CC=$xcc\n";
  111. next;
  112. }
  113. if ($native_cc && $line =~ /^NATIVE_CC.*/) {
  114. print "NATIVE_CC=$native_cc\n";
  115. next;
  116. }
  117. if ($devel_prefix && $line =~ /^DEVEL_PREFIX.*/) {
  118. print "DEVEL_PREFIX=$devel_prefix\n";
  119. next;
  120. }
  121. if ($kernel_dir && $line =~ /^KERNEL_SOURCE.*/) {
  122. print "KERNEL_SOURCE=$kernel_dir\n";
  123. next;
  124. }
  125. if ($debug && $line =~ /^DODEBUG.*/) {
  126. print "DODEBUG=$debug\n";
  127. next;
  128. }
  129. if ($mmu && $line =~ /^HAS_MMU.*/) {
  130. print "HAS_MMU=$mmu\n";
  131. next;
  132. }
  133. if ($large_file && $line =~ /^DOLFS.*/) {
  134. print "DOLFS=$large_file\n";
  135. next;
  136. }
  137. if ($rpc_support && $line =~ /^INCLUDE_RPC.*/) {
  138. print "INCLUDE_RPC=$rpc_support\n";
  139. next;
  140. }
  141. if ($shadow && $line =~ /^HAS_SHADOW.*/) {
  142. print "HAS_SHADOW=$shadow\n";
  143. next;
  144. }
  145. if ($c99_math && $line =~ /^DO_C99_MATH.*/) {
  146. print "DO_C99_MATH=$c99_math\n";
  147. next;
  148. }
  149. if ($long_long && $line =~ /^HAS_LONG_LONG.*/) {
  150. print "HAS_LONG_LONG=$long_long\n";
  151. next;
  152. }
  153. if ($float && $line =~ /^HAS_FLOATING_POINT.*/) {
  154. print "HAS_FLOATING_POINT=$float\n";
  155. next;
  156. }
  157. if ($threads && $line =~ /^INCLUDE_THREADS.*/) {
  158. print "INCLUDE_THREADS=$threads\n";
  159. next;
  160. }
  161. if ($shared_support && $shared_support =~ /true/ ) {
  162. if ($line =~ /^BUILD_UCLIBC_LDSO.*/) {
  163. print "BUILD_UCLIBC_LDSO=true\n";
  164. next;
  165. }
  166. if ($line =~ /^HAVE_SHARED.*/) {
  167. print "HAVE_SHARED=true\n";
  168. next;
  169. }
  170. # Force PIC to be true when HAVE_SHARED is true
  171. if ($line =~ /^DOPIC.*/) {
  172. print "DOPIC=true\n";
  173. next;
  174. }
  175. if ($ldso_path && $line =~ /^SHARED_LIB_LOADER_PATH.*/) {
  176. print "SHARED_LIB_LOADER_PATH=$ldso_path\n";
  177. next;
  178. }
  179. } else {
  180. if ($line =~ /^BUILD_UCLIBC_LDSO.*/) {
  181. print "BUILD_UCLIBC_LDSO=false\n";
  182. next;
  183. }
  184. if ($line =~ /^HAVE_SHARED.*/) {
  185. print "HAVE_SHARED=false\n";
  186. next;
  187. }
  188. if ($line =~ /^DOPIC.*/) {
  189. print "DOPIC=false\n";
  190. next;
  191. }
  192. }
  193. print "$line";
  194. }
  195. if ($arch && ! $got_arch) {
  196. print "TARGET_ARCH=$arch\n";
  197. }