Adding ceilf() to libm in uClibc for OpenWrt
OpenWrt is an embedded linux for mipsel architecture which could be flashed on recent network devices, e.g., ADSL routers and home appliances. The most popular device is WRT54 series by LinkSys and the another series from Asus called WL-500g. This linux distribution is compiled by cross compiler set called toolchain. Actually, it is a fork of that with uClibc. By default, the pre-built SDK for OpenWrt comes with a small set of uClibc to maximize free space especially lots of math library cutted off, e.g., ceilf()
. It is not usual case that you would like to run application called ceilf()
in such a router but I would like to do that. Below is what I did.
If you would like to build a package (ipk) yourself, you need to have the match version of uClibc as you have in the firmware image. WhiteRussian has uClibc 0.9.28. However, the SDK has uClibc 0.9.27 instead so you may need to get the latest version from the development branch Kamikaze.
svn co https://svn.openwrt.org/openwrt/trunk/ openwrt_trunk
Then modify openwrt_trunk/toolchain/uClibc/patches/120-more_standard_math.patch
as follow.
diff -urN uClibc.old/libm/Makefile uClibc.dev/libm/Makefile
--- uClibc.old/libm/Makefile 2005-08-18 00:49:41.000000000 +0200
+++ uClibc.dev/libm/Makefile 2005-10-22 00:56:03.106683500 +0200
@@ -81,6 +81,8 @@
w_cosh.c w_exp.c s_fabs.c s_floor.c w_fmod.c s_frexp.c \
s_ldexp.c w_log.c w_log10.c s_modf.c w_pow.c s_sin.c \
w_sinh.c w_sqrt.c s_tan.c s_tanh.c
+# extra stuff required for some apps
+CSRC+= fpmacros.c nan.c s_rint.c e_hypot.c w_hypot.c s_floorf.c s_ceilf.c
CSRC+= s_expm1.c s_scalbn.c s_copysign.c e_acos.c e_asin.c e_atan2.c \
k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log10.c e_pow.c \
k_sin.c e_sinh.c e_sqrt.c k_tan.c e_rem_pio2.c k_rem_pio2.c \
Then remove existing output.
rm -rf staging_dir_mipsel toolchain_build_mipsel
And now we are ready to compile it again.
make
After successfully compilation, copy the staging_dir_mipsel
into SDK directory.
cp -Rp staging_dir_mipsel ../OpenWrt-SDK-Linux-x86_64-1/
Now you are ready to continue linking the program/library using ceilf()
.
- sugree's blog
- 647 reads
Post new comment