So far a compile for latest quagga and also iproute2 worked after problems 4 days long.
I still have some problems getting them fully to run, but hey, I'm one step further.
It's very surprisingly for me, that really noone did give me any feedback on this too advanced topics for me(I guess basic topics for a linux guru).
These are the real problems for people, so they probably don't think ever on using OpenWRT.
If you as a group can not write simple enough Compiling Howto's or even reply on such basic questions, then please don't expect that there will be many people focusing on such products.
What helps a running OpenWRT on WRT (my congratulations to the very simple buildroot make process btw), when you can't get programs compiled for it/on it.
The feature of package installations help here not much, when most packages are not available yet
The slogan "Newbies do not have to apply" seems to come here very true even when you (not really a newbie) got openWRT running very fine.
Why do you people make that lots of work for coding that wonderful firmware when people probably have to refuse working with it, just because of problems like I had ?
Anyway I have to say, the support which I got on IRC channel #wrt54g on irc.freenode.net so far is really overwhelming, also mostly short questions is the key.
I want to thank you all (you know who you are!) for the support and help and ideas. Also for your patience.
I know, it's all the complicated stuff that I have to get working all time
Comming back to my own solutions....
1.0 Common
What would I have to change in source's Makefile (maybe there is not only one Makefile, but more Makefiles in different directories when multiple binaries and also multiple .so files have to be created).
How can I point the progs Makefile to uclibc-gcc (crosscompile for WRT) ?
Do I have to change anything ?
If they refer already ${GCC}, will it work without any change ?
One way which works quite good, is to call make <target> in buildroot directly. So make in fact make calls normal Makefile, which also sets some stuff for crosscompile (e.g TARGET_CC, TARGET_CROSS, STRIP, TARGET_CONFIGURE_OPTS for PATH to AR, AS, LD, NM, CC, GCC, RANLIB).
The Makefile does include make/*.mk, so if you have created a quagga.mk, it will be included.
1. Zebra
I want to compile that in buildroot, so my thought was, just to copy some already existing .mk file and creating a zebra.mk.
I changed the names, path's, binary targets, etc.
How can I pass the zebra configure script some options like --enable-multipath and also disabling RIP, OSPFv3, etc. ?
Do I have to create my own .config file and also how can I pass this to zebra configure script ?
I left out zebra 0.94 and instead of switched to quagga zebra fork now.
If there is any bugfix, then it is in quagga instead of zebra.
Configuration (configure, make, also zebra.conf, ospfd.conf) is the same as in zebra.
Normally calling from buildroot directory make quagga probably works.
Just make sure, you have set in quagga.mk all GCC, LD, RANLIB, STRIP stuff. If you haven't, compile will probably abort with very weird errors,
e.g wrong index on xxx.a (which is wrong ranlib used) or any other stuff
which is an indicator that Makefiles from quagga (there is more than one in each directory!) is directly refering CC=gcc, LD=ld, STRIP=strip etc.
For quagga this was no problem. If you are compiling iproute2 you would have to deleted from iproute2/Makefile line CC=gcc and edit iproute2/lib/Makefile and change some line with ar xxxxx .... to $(AR).
Here is my quagga.mk from buildroot/make:
#############################################################
#
# Quagga 0.96.4
#
#############################################################
QUAGGA_SOURCE=quagga-0.96.4.tar.gz
QUAGGA_SITE=ftp://ftp.quagga.net/download
QUAGGA_DIR=$(BUILD_DIR)/packages/quagga-0.96.4
QUAGGA_BINARY=zebra
QUAGGA_BINARY2=ospfd
QUAGGA_TARGET_BINARY=usr/sbin/zebra
QUAGGA_TARGET_BINARY2=usr/sbin/ospfd
$(DL_DIR)/$(QUAGGA_SOURCE):
$(WGET) -P $(DL_DIR) $(QUAGGA_SITE)/$(QUAGGA_SOURCE)
$(QUAGGA_DIR)/.source: $(DL_DIR)/$(QUAGGA_SOURCE)
zcat $(DL_DIR)/$(QUAGGA_SOURCE) | tar -C $(BUILD_DIR)/packages -xvf -
$(SOURCE_DIR)/patch-kernel.sh $(QUAGGA_DIR) $(SOURCE_DIR) quagga-*.patch
touch $(QUAGGA_DIR)/.source
$(QUAGGA_DIR)/.configured: $(QUAGGA_DIR)/.source
(cd $(QUAGGA_DIR); rm -rf config.cache;
$(TARGET_CONFIGURE_OPTS)
./configure
--host=mipsel-unknown-linux-gnu
--bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib
--datadir=/usr/share --sysconfdir=/etc --libdir=/usr/lib
--disable-ipv6 --disable-bgpd --disable-ripd
--disable-ripngd --disable-ospf6d --disable-bgp-announce
--disable-ospfapi --disable-ospfclient --disable-ospf-te
--disable-rtadv --disable-vtysh --disable-snmp --disable-nssa
--disable-opaque-lsa
--enable-multipath=0
--enable-user=root --enable-group=root
);
touch $(QUAGGA_DIR)/.configured
$(QUAGGA_DIR)/$(QUAGGA_BINARY): $(QUAGGA_DIR)/.configured
$(MAKE) CC=$(TARGET_CC) CFLAGS="$(TARGET_CFLAGS)"
AR=$(TARGET_CROSS)ar AS=$(TARGET_CROSS)as LD=$(TARGET_CROSS)ld
NM=$(TARGET_CROSS)nm RANLIB=$(TARGET_CROSS)ranlib
CPP=$(TARGET_CROSS)cpp STRIP=$(TARGET_CROSS)strip
BINDIR=/usr/sbin MANDIR=/usr/man -C $(QUAGGA_DIR)
$(TARGET_DIR)/$(QUAGGA_TARGET_BINARY): $(QUAGGA_DIR)/$(QUAGGA_BINARY)
$(MAKE) BINDIR=/usr/sbin MANDIR=/usr/man
DESTDIR=$(TARGET_DIR) -C $(QUAGGA_DIR) install
$(STRIP) $(TARGET_DIR)/$(QUAGGA_TARGET_BINARY)
$(STRIP) $(TARGET_DIR)/$(QUAGGA_TARGET_BINARY2)
rm -Rf $(TARGET_DIR)/usr/man
quagga: uclibc $(TARGET_DIR)/$(QUAGGA_TARGET_BINARY)
quagga-source: $(DL_DIR)/$(QUAGGA_SOURCE)
quagga-clean:
#$(MAKE) prefix=$(TARGET_DIR)/usr -C $(QUAGGA_DIR) uninstall
-$(MAKE) -C $(QUAGGA_DIR) clean
quagga-dirclean:
rm -rf $(QUAGGA_DIR)
Important notes:
1. You have to call configure for quagga. As you can see I already call configure will all crosscompiler references like GCC, LD.
This is very sweet, since all quagga Makefiles have then the right references.
2. Note, there exists a problem cd $(QUAGGA_DIR) and configure.
To get calling configure from quagga.mk working, you have exactly to follow this:
(cd $(QUAGGA_DIR); $(TARGET_CONFIGURE_OPTS) ./configure --options );
If you don't use (cd; configure ); the configure command won't be found.
If you choose to use instead of $(QUAGGA_DIR)/configure all Makefiles won't be created in $(QUAGGA_DIR) but instead of in buildroot !!!!
3. Don't forget to strip the compiled binaries zebra and ospfd in my case.
I forgot to add $(STRIP) $(TARGET_DIR)/usr/sbin/ospfd and so the file was 2,3MB! Thanx to coder for this tip!
4. Don't forget that also zebra.conf.sample and ospfd.conf.sample will be copied to buildroot/build_mipsel/root/etc
5. It took me more than 1 day to find out, how to get configure working with crosscompile.
You really have to set --host for crosscompile, otherwise quagga/zebra won't let you pass GCC, LD, RANLIB crosscompiler stuff.
It actively complains about this then!
On my redhat 9 system I had quite big problems, passing not all crosscompiler options to configure, so configure was actually trying to compile one file on my system, and this wasn't working.
Also it took me about 1-2 days to find out, what host type I have to pass in.
I tried with --host=mipsel.
Wonder if this had worked in any kind! NO!
The damn configure script then thought I was compile for a FreeBSD system so it included rt_socket.c instead of linux netlink, so it was complaining all the time for unknown constants like RTM_ADD, RTM_DELETE which just are not in zebra, but seem to be in kernel header files for FreeBSD.
As I found out, that there is in zebra directory a config.sub which can find you the right hostname according to INSTALL (first of course I just looked in the file directly , but I had no chance to find out the logic; yes, damn newbies, they think complex even it can be done easily!).
[root@agelinux quagga-0.96.4]# ./config.sub mipsel
mipsel-unknown-elf
[root@agelinux quagga-0.96.4]# ./config.sub mipsel-linux
mipsel-unknown-linux-gnu
[root@agelinux quagga-0.96.4]#
So mipsel-linux found me the right mipsel-unknown-linux-gnu crosscompiler.
2. Iproute2
There is a tc in ./build_mipsel/WRT54GS/release/src/linux/linux/drivers/tc
. How to exlude this from openwrt-code.bin ?
I have not done this yet.
iproute2.mk creates tc in buildroot/build_mipsel/root/usr/sbin. Just copy tc from that directory to your WRT.
How to include iproute2 (htb3.6 patched) tc ?
I would have to change the Makefiles in iproute2 , that only tc get's compiled ?
I finally have sources for iproute2 and htb3.6 patch.
Probably by adding the target in buildroot/Makefile or was it buildroot/Makefile-OpenWRT ?
Just comment out this line :
#TARGETS+=iproute2
Then at least iproute2 will be compiled when a normal make for openwrt is running.
I guess this does not already include it into openwrt-code.bin.
Don't forget for iproute2 to change the Makefiles (especially lib/Makefile) to poing to all crosscompiler stuff, e.g ar.
So it should be not ar, but instead of $(AR).
Here is my iproute2.mk, there where several bugs in.
################################################
# iproute2
#
###############################################
IPROUTE2_DIR=$(BUILD_DIR)/packages/iproute2
LINUX_DIR=/home/blackvel/buildroot/build_mipsel/linux
IPROUTE2_SOURCE_URL=ftp://ftp.inr.ac.ru/ip-routing/
IPROUTE2_SOURCE=iproute2-2.4.7-now-ss010824.tar.gz
#Use the debian source for now, as the .ru site has availability problems
#IPROUTE2_SOURCE_URL=http://ftp.debian.org/debian/pool/main/i/iproute/
#IPROUTE2_SOURCE=iproute_20010824.orig.tar.gz
#IPROUTE2_PATCH=iproute_20010824-13.diff.gz
IPROUTE2_PATCH=htb3.6_tc.patch
$(DL_DIR)/$(IPROUTE2_SOURCE):
$(WGET) -P $(DL_DIR) $(IPROUTE2_SOURCE_URL)$(IPROUTE2_SOURCE)
iproute2-source: $(DL_DIR)/$(IPROUTE2_SOURCE) #$(DL_DIR)/$(IPROUTE2_PATCH)
$(IPROUTE2_DIR)/.unpacked: $(DL_DIR)/$(IPROUTE2_SOURCE) #$(DL_DIR)/$(IPROUTE2_PATCH)
rm -rf $(IPROUTE2_DIR).orig $(IPROUTE2_DIR)
zcat $(DL_DIR)/$(IPROUTE2_SOURCE) | tar -C $(BUILD_DIR)/packages -xvf -
#zcat $(DL_DIR)/$(IPROUTE2_PATCH) | patch -p1 -d $(IPROUTE2_DIR)
touch $(IPROUTE2_DIR)/.unpacked
$(IPROUTE2_DIR)/.patched : $(IPROUTE2_DIR)/.unpacked
$(SOURCE_DIR)/patch-kernel.sh $(IPROUTE2_DIR) $(SOURCE_DIR) $(IPROUTE2_PATCH)
touch $(IPROUTE2_DIR)/.patched
$(IPROUTE2_DIR)/.configured: $(IPROUTE2_DIR)/.patched
$(SED) "s,-I/usr/include/db3,," $(IPROUTE2_DIR)/Makefile
$(SED) "s,^KERNEL_INCLUDE.*,KERNEL_INCLUDE=$(LINUX_DIR)/include,"
$(IPROUTE2_DIR)/Makefile
$(SED) "s,^LIBC_INCLUDE.*,LIBC_INCLUDE=$(STAGING_DIR)/include,"
$(IPROUTE2_DIR)/Makefile
# For now disable compiling of the misc directory because it seems to fail
rm -rf $(IPROUTE2_DIR)/misc
$(SED) "s, misc,," $(IPROUTE2_DIR)/Makefile
# set configured mode
touch $(IPROUTE2_DIR)/.configured
# end of configured mode
$(IPROUTE2_DIR)/tc/tc: $(IPROUTE2_DIR)/.configured
# Entering make of tc
$(MAKE) CC=$(TARGET_CC)
AR=$(TARGET_CROSS)ar AS=$(TARGET_CROSS)as LD=$(TARGET_CROSS)ld
NM=$(TARGET_CROSS)nm RANLIB=$(TARGET_CROSS)ranlib
CPP=$(TARGET_CROSS)cpp STRIP=$(TARGET_CROSS)strip
KERNEL_INCLUDE=$(LINUX_DIR)/include -C $(IPROUTE2_DIR)
$(TARGET_DIR)/usr/sbin/tc: $(IPROUTE2_DIR)/tc/tc
# Copy The tc binary
cp -af $(IPROUTE2_DIR)/tc/tc $(TARGET_DIR)/usr/sbin/
$(STRIP) $(TARGET_DIR)/usr/sbin/tc
iproute2: $(TARGET_DIR)/usr/sbin/tc
iproute2-clean:
$(MAKE) -C $(IPROUTE2_DIR) clean
iproute2-dirclean:
rm -rf $(IPROUTE2_DIR)
Note: for iproute2-clean there is no uninstall target in iproute2 package, only clean!
This Makefile does not only build tc, but also all other iproute2 stuff.
in buildroot/build_mipsel/iproute2/Makefile there is no special tc target yet!
Be sure to have a clean iproute2.mk, this means, do not use normal spaces in vi before commands like $(MAKE) in target $(IPROUTE2_DIR)/tc/tc: .
I had this problem (tab use is very okay!) and my make just didn't run.
3. iptables-p2p
There is no binary for IPTABLES-P2P_BINARY, IPTABLES-P2P_BINARY_TARGET which I could change buildroot/make/iptables-p2p.mk to, because there are only created some .so files.
One libipt_p2p.so for /usr/lib/iptables and one ipt_p2p.o for /lib/kernel/2.4.20.
They get created by make process from different directories with multiple Makefiles.
Do I have to care for my iptables-p2p.mk to these or is this just straightforward like compiling normal programs ?
Haven't compiled iptables-p2p yet.
But from my 4 days experience now, the TARGET and BINARY_TARGET are just an identifier for the makefile with what target part should be started or what part has to come before that special part.
So I would suggest to point the TARGET1 and TARGET2 binaries to libipt_p2p.so and ipt_p2p.o with the correct path directions to buildroot/build_mipsel/packages/iptables-p2p/xxxxx.
Then you can modify the TARGET_BINARY target to copy the files to $(TARGET_DIR) and the appropriate directories which are /usr/lib/iptables and /lib/kernel/2.4.20.
Before this make sure, Makefiles are not using any ar, strip, ranlib stuff directly. Replace in Makefiles by $(AR), $(STRIP), $(RANLIB), etc.
Don't worry for the multiple pathes in iptables-p2p, so multiple files from multiple directories have to be created.
iptables-p2p/Makefile handles this automatically by calling $(MAKE) -c <directories>.
This was also quite good working for quagga
For all package.mk files the slogan is :
Copy the file first into buildroot/sources/dl
Hope this helps the other people with that advanced openwrt topics
To create a package with ipkg-build, having all the binaries already compiled, shouldn't be a problem anymore really.
Feel free to ask if you have any problems.
Blackvel