[uClibc][PATCH] Update uClibc build script to new config system

M. R. Brown mrbrown at 0xd6.org
Tue Nov 5 07:03:40 UTC 2002


The first patch allows extra/scripts/get-needed-libgcc-objects.sh to find
the correct libgcc.a even when multilibs are used.  I needed this when
building the default "sh-linux" target, I suspect others will also.

The second patch are the modifications to the
gcc-3.2-uclibc-20020916.src.tar.bz2 Makefile so that it works with the new
uClibc config system.  I've added a USE_CONFIG option that you can use to
point to a custom .config that will override uClibc's default .config
(which only exists for i386 currently, *hint* *hint*).

Although I copied all substitution cases for the default .config, it seems
that something is missing because ISO C99 support isn't properly enabled in
the second-pass GCC.  The libstdc++ build fails due to missing strtof() and
strtold(), which are #ifdef'd under __USEISO99.  I couldn't trace to where
and why this wasn't being enabled, so please have a look.

Other than that, it should work fine w/ the latest snapshot.

M. R.
-------------- next part --------------
diff -bur -x CVS /home/mrbrown/cvs/uClibc/uClibc/Rules.mak uClibc/Rules.mak
--- /home/mrbrown/cvs/uClibc/uClibc/Rules.mak	2002-11-04 22:06:11.000000000 -0600
+++ uClibc/Rules.mak	2002-11-05 00:12:56.000000000 -0600
@@ -136,12 +136,14 @@
 	CPU_CFLAGS-$(CONFIG_SH5)+="-m5"
 endif
 
+CPU_CFLAGS:=$(CPU_CFLAGS-y)
+
 # Add a bunch of extra pedantic annoyingly strict checks
 WARNINGS+=-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
 
 # Some nice CFLAGS to work with
-CFLAGS:=$(WARNINGS) $(OPTIMIZATION) -fno-builtin -nostdinc $(CPUFLAGS) \
-	-D_LIBC $(CPU_CFLAGS-y) $(ARCH_CFLAGS) -I$(TOPDIR)include -I.
+CFLAGS:=$(WARNINGS) $(OPTIMIZATION) -fno-builtin -nostdinc -D_LIBC \
+	$(CPU_CFLAGS) $(ARCH_CFLAGS) -I$(TOPDIR)include -I.
 
 # Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
 #CFLAGS+=-iwithprefix include
diff -bur -x CVS /home/mrbrown/cvs/uClibc/uClibc/extra/scripts/get-needed-libgcc-objects.sh uClibc/extra/scripts/get-needed-libgcc-objects.sh
--- /home/mrbrown/cvs/uClibc/uClibc/extra/scripts/get-needed-libgcc-objects.sh	2002-10-31 07:35:57.000000000 -0600
+++ uClibc/extra/scripts/get-needed-libgcc-objects.sh	2002-11-05 00:14:02.000000000 -0600
@@ -15,7 +15,7 @@
 #Enable this when debugging
 #set -x
 
-LIBGCC=`$CC -print-libgcc-file-name`
+LIBGCC=`$CC $CPU_CFLAGS -print-libgcc-file-name`
 
 echo Finding missing symbols in libc.a ...
 echo "    partial linking..."
diff -bur -x CVS /home/mrbrown/cvs/uClibc/uClibc/libc/Makefile uClibc/libc/Makefile
--- /home/mrbrown/cvs/uClibc/uClibc/libc/Makefile	2002-10-28 23:37:10.000000000 -0600
+++ uClibc/libc/Makefile	2002-11-05 00:13:48.000000000 -0600
@@ -49,7 +49,7 @@
 	@rm -rf tmp
 	@mkdir tmp
 	$(AR) rv ./tmp/libgcc-need.a
-	@(cd tmp && CC=$(CC) LD=$(LD) NM=$(NM) AR=$(AR) \
+	@(cd tmp && CC=$(CC) LD=$(LD) NM=$(NM) AR=$(AR) CPU_CFLAGS="$(CPU_CFLAGS)" \
 		/bin/sh $(TOPDIR)../extra/scripts/get-needed-libgcc-objects.sh)
 	$(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \
 		--whole-archive ./tmp/libgcc-need.a $(LIBNAME) --no-whole-archive \
-------------- next part --------------
--- gcc-3.2.orig/Makefile	2002-09-16 13:07:32.000000000 -0500
+++ gcc-3.2/Makefile	2002-11-05 00:53:51.000000000 -0600
@@ -38,6 +38,10 @@
 #ARCH:=mipsel
 #ARCH:=powerpc
 
+# Set this to the path of a custom .config that will be used in place
+# of the uClibc default.
+USE_CONFIG:=false
+
 # Set this to `false' if you are building for a CPU does not have
 # a memory management unit (MMU) -- i.e. an uClinux system..  If
 # you are targeting a regular Linux system, leave this "true".
@@ -320,47 +324,54 @@
 	touch $(UCLIBC_DIR)/.unpacked
 
 $(UCLIBC_DIR)/.configured: $(UCLIBC_DIR)/.unpacked
-	cp $(UCLIBC_DIR)/extra/Configs/Config.$(ARCH) $(UCLIBC_DIR)/Config~;
-	echo "TARGET_ARCH=$(ARCH)" >> $(UCLIBC_DIR)/Config~
-	perl -i -p -e 's,^HAS_WCHAR.*,HAS_WCHAR=true,g' $(UCLIBC_DIR)/Config~
-	perl -i -p -e 's,^PREFIX.*,,g' $(UCLIBC_DIR)/Config~
-	perl -i -p -e 's,^CROSS.*,CROSS=,g' $(UCLIBC_DIR)/Config~
-	perl -i -p -e 's,^SYSTEM_DEVEL_PREFIX.*,SYSTEM_DEVEL_PREFIX=$(STAGING_DIR),g' \
-		$(UCLIBC_DIR)/Config~
-	perl -i -p -e 's,^UNIX98PTY_ONLY.*,UNIX98PTY_ONLY=false,g' $(UCLIBC_DIR)/Config~
-	$(UCLIBC_DIR)/extra/Configs/uClibc_config_fix.pl \
-		--arch=$(ARCH) \
-		--cross=$(STAGING_DIR)/bin/$(ARCH)-uclibc- \
-		--c99_math=$(HAS_MMU) \
-		--devel_prefix=$(STAGING_DIR) \
-		--kernel_dir=$(LINUX_DIR) \
-		--long_long=true \
-		--float=true \
-		--shadow=true \
-		--threads=true \
-		--rpc_support=true \
-		--large_file=$(HAS_MMU) \
-		--mmu=$(HAS_MMU) \
-		--debug=false \
-		--ldso_path="/lib" \
-		--shared_support=$(HAS_MMU) \
-		--file=$(UCLIBC_DIR)/Config~ \
-		> $(UCLIBC_DIR)/Config; 
+ifneq ($(USE_CONFIG),false)
+	cp $(USE_CONFIG) $(UCLIBC_DIR)/.config
+else
+	cp $(UCLIBC_DIR)/extra/Configs/Config.$(TARGET_ARCH).default \
+		$(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# UCLIBC_HAS_FLOATS.*,UCLIBC_HAS_FLOATS=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# HAS_SHADOW.*,HAS_SHADOW=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# UCLIBC_HAS_THREADS.*,UCLIBC_HAS_THREADS=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# UCLIBC_HAS_RPC.*,UCLIBC_HAS_RPC=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^UNIX98PTY_ONLY=y.*,# UNIX98PTY_ONLY is not set,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^DODEBUG=y.*,# DODEBUG is not set,g' $(UCLIBC_DIR)/.config
+ifeq ($(HAS_MMU),true)
+	perl -i -p -e 's,^# UCLIBC_HAS_MMU.*,UCLIBC_HAS_MMU=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# DO_C99_MATH.*,DO_C99_MATH=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=y,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^# HAVE_SHARED.*,HAVE_SHARED=y,g' $(UCLIBC_DIR)/.config
+else
+	perl -i -p -e 's,^UCLIBC_HAS_MMU=y.*,# UCLIBC_HAS_MMU is not set,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^DO_C99_MATH=y.*,# DO_C99_MATH is not set,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^UCLIBC_HAS_LFS=y.*,# UCLIBC_HAS_LFS is not set,g' $(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^HAVE_SHARED=y.*,# HAVE_SHARED is not set,g' $(UCLIBC_DIR)/.config
+endif
+endif
+	perl -i -p -e 's,^DEVEL_PREFIX.*,DEVEL_PREFIX=\"$(STAGING_DIR)\",g' \
+		$(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^SYSTEM_DEVEL_PREFIX.*,SYSTEM_DEVEL_PREFIX=\"$(STAGING_DIR)\",g' \
+		$(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^KERNEL_SOURCE.*,KERNEL_SOURCE=\"$(LINUX_DIR)\",g' \
+		$(UCLIBC_DIR)/.config
+	perl -i -p -e 's,^SHARED_LIB_LOADER_PATH.*,SHARED_LIB_LOADER_PATH=\"/lib\",g' \
+		$(UCLIBC_DIR)/.config
+	$(MAKE) -C $(UCLIBC_DIR) oldconfig
 	# Note that since the target compiler does not yet exist, we will not
 	# be able to properly generate include/bits/syscall.h so we will need
 	# to run part again later...
-	$(MAKE) -C $(UCLIBC_DIR) headers uClibc_config install_dev;
+	$(MAKE) -C $(UCLIBC_DIR) headers install_dev
 	touch $(UCLIBC_DIR)/.configured
 
 # Now that we have a working target compiler, rebuild the header files for the
 # target so things like include/bits/syscall.h can actually be built this time
 # around...
 $(UCLIBC_DIR)/.config_final: $(UCLIBC_DIR)/.configured
-	$(MAKE) -C $(UCLIBC_DIR) headers uClibc_config install_dev
+	$(MAKE) -C $(UCLIBC_DIR) headers install_dev
 	touch $(UCLIBC_DIR)/.config_final
 
 $(UCLIBC_DIR)/lib/libc.a: $(UCLIBC_DIR)/.config_final
-	$(MAKE) -C $(UCLIBC_DIR)
+	$(MAKE) -C $(UCLIBC_DIR) CROSS=$(STAGING_DIR)/bin/$(ARCH)-uclibc-
 
 $(STAGING_DIR)/lib/libc.a: $(UCLIBC_DIR)/lib/libc.a
 	$(MAKE) -C $(UCLIBC_DIR) install_dev install_runtime install_utils
@@ -369,7 +380,7 @@
 
 uclibc-clean:
 	-$(MAKE) -C $(UCLIBC_DIR) clean
-	rm -f $(UCLIBC_DIR)/Config
+	rm -f $(UCLIBC_DIR)/.config
 
 uclibc-dirclean:
 	rm -rf $(UCLIBC_DIR)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20021105/f6ee9486/attachment.pgp 


More information about the uClibc mailing list