uClibc_config_fix.pl 4.7 KB

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