uClibc_config_fix.pl 4.6 KB

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