[uClibc] Interesting buildroot problem

Robin Gilks robin.gilks at tait.co.nz
Thu Jul 10 04:50:00 UTC 2003


Greetings

An interesting problem has arisen with the building of a cross target 
gdb (i.e. hosted on i386 to debug a powerpc) in that whenever I try to 
make gdb with the -C switch to make, the readline library doesn't work. 
I get an executable that runs but doesn't accept user input!!

Building gdb by hand and copying the libreadline.a file across and it 
links OK so its definitely within the readline sub-tree!!

I've appended the make file gdbhost.mk that fails and also another 
makefile that creates a simple initrd root file system - a bit easier 
than cramfs etc when first starting out!!


========================= gdbhost.mk ======================
#############################################################
#
# gdbhost - gdb running on the host but aimed at target!!
#
#############################################################

# Use other GDB values from gdb.mk

GDBHOST_DIR:=$(TOOL_BUILD_DIR)/gdb-5.3

# make a new directory in our toolchain tree
$(GDBHOST_DIR):
	mkdir -p $(GDBHOST_DIR)


$(DL_DIR)/$(GDB_SOURCE):
	$(WGET) -P $(DL_DIR) $(GDB_SITE)/$(GDB_SOURCE)

$(GDBHOST_DIR)/.unpacked: $(DL_DIR)/$(GDB_SOURCE) $(GDB_PATCH)
	gunzip -c $(DL_DIR)/$(GDB_SOURCE) | tar -C $(TOOL_BUILD_DIR) -xvf -
	cat $(GDB_PATCH) | patch -p1 -d $(GDBHOST_DIR)
	touch  $(GDBHOST_DIR)/.unpacked

$(GDBHOST_DIR)/.configured: $(GDBHOST_DIR)/.unpacked
	(cd $(GDBHOST_DIR); rm -rf config.cache; \
		CC=$(HOSTCC) \
		./configure \
		--target=$(GNU_TARGET_NAME) \
		--host=$(GNU_HOST_NAME) \
		--prefix=$(STAGING_DIR) \
		--enable-readline \
	);
	touch  $(GDBHOST_DIR)/.configured

# note the hack with the cd to gdb directory due to a bug in readline 
Makefile
$(GDBHOST_DIR)/gdb/gdb: $(GDBHOST_DIR)/.configured
	cd $(GDBHOST_DIR); $(MAKE) CC=$(HOSTCC)
	
$(STAGING_DIR)/$(GNU_TARGET_NAME)/bin/gdb: $(GDBHOST_DIR)/gdb/gdb
	cd $(GDBHOST_DIR); $(MAKE) CC=$(HOSTCC) install
	rm -rf $(GDBHOST_DIR)/info $(GDBHOST_DIR)/man $(GDBHOST_DIR)/share/doc \
		$(GDBHOST_DIR)/share/locale
	mkdir -p $(STAGING_DIR)/usr/bin;
	set -e; \
	if [ -x $(STAGING_DIR)/bin/$(ARCH)-linux-gdb ] ; then \
	    (cd $(STAGING_DIR)/$(GNU_TARGET_NAME)/bin; \
		ln -fs ../../bin/$(ARCH)-linux-gdb gdb; \
	    ); \
	    (cd $(STAGING_DIR)/usr/bin; \
		ln -fs ../../bin/$(ARCH)-linux-gdb gdb; \
	    ); \
	fi; \

gdbhost: $(STAGING_DIR)/$(GNU_TARGET_NAME)/bin/gdb

gdbhost-clean:
	$(MAKE) -C $(GDBHOST_DIR) clean

gdbhost-dirclean:
	rm -rf $(GDBHOST_DIR)

========================= gdbhost.mk ======================


========================= initrd.mk =======================
#############################################################
#
# make an initrd image - assumes all the tools are available
#
#############################################################

# this comes from the u-boot project!!
MKIMAGE=/usr/local/bin/mkimage
MNTPOINT:=$(STAGING_DIR)/mnt

$(MNTPOINT):
	mkdir -p $(MNTPOINT)


#############################################################
#
# Build the ramfs root filesystem image
#
#############################################################



initrd.gz: $(TARGET_DIR) $(MNTPOINT)
	dd if=/dev/zero of=initrd bs=1024 count=2048
	/sbin/mkfs.ext2 -F -m0 -b 1024 initrd
	sudo mount -o loop initrd $(MNTPOINT)
	echo cp -R $(TARGET_DIR)/root $(MNTPOINT)
	cp -R $(TARGET_DIR)/* $(MNTPOINT)
	sudo umount $(MNTPOINT)
	gzip -9 -c initrd > initrd.gz
	rm -f initrd



initrd:	initrd.u-boot initrd.gz
	$(MKIMAGE) -n 'Simple Ramdisk Image' \
	 -A ppc -O linux -T ramdisk -C gzip \
	 -d initrd.gz initrd.u-boot
	 rm -f initrd.gz

========================= initrd.mk =======================


-- 
Robin Gilks
Senior Design Engineer              Phone: (+64)(3) 357 1569
Tait Electronics                          Fax  :  (+64)(3) 359 4632
PO Box 1645 Christchurch        Email : robin.gilks at tait.co.nz
New Zealand




More information about the uClibc mailing list