Sometimes in Opensource you have to wait until a package is contained in Distribution XYZ's repository. If you want to use a program, currently not contained in the repository, and it is released as open source, you can download the code and compile it using the BuildSystem.
Here are a few hints to get you started on cross compiling:
-
Have a cross compile toolchain compiled and ready - For example, my build environment has the following chain compiling and installed:
ls Openwrt/trunk/build_dir/
armeb host toolchain-armeb_gcc4.1.2
-
Determine what your --host is: gcc -v should tell you something like this:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-linux-gnu
- Know what dependencies your package needs - if so, then they will need to be cross compiled as well
-
Cross compile using static libraries first, if your programs work then try moving towards dynamically linked libraries next to reduce the size (if thats a concern) For example:
CONFIGURE_ARGS += \
--enable-static \
--enable-shared \
--disable-ipfw-module \
--disable-ipq-module \CONFIGURE_VARS +=
MAKE_VARS +=
MAKE_FLAGS +=define Build/Configure
$(CONFIGURE_VARS);
$(CONFIGURE_ARGS);
$(call Build/Configure/Default,)
endef
-
Modify your Makefiles for cross compiling ( --host=yourCurrentArch, --build=whereYourPackageWillRunArch)
For example:# Specify how to configure the program. Note that we run the libtoolize,
# aclocal, and autoconf utilities.This makes the build happen as expected
# and the Build/Prepare function has to run twice in order to patch correctly.
define Build/Configure
( cd $(PKG_BUILD_DIR); \
aclocal; \
libtoolize --force --copy --automake; \
autoconf; \
);
$(call Build/Prepare,Default)$(call Build/Configure/Default, \
--build=x86_64-linux-gnu \
--host=armeb-linux \
--prefix=/usr/local \
--disable-static-daq \
--with-daq-includes="$(STAGING_DIR)/usr/include" \
--with-daq-libraries="$(STAGING_DIR)/usr/lib" \
--enable-active-response \
--enable-reload \
--enable-flexresp3 \
--enable-pthread \
--enable-sourcefire \
--enable-decoder-preprocessor-rules \
--enable-dynamicplugin \
--enable-build-dynamic-examples \
--enable-zlib \
--without-mysql \
--without-oracle \
--without-postgresql \
--with-libnet-includes="$(STAGING_DIR)/usr/lib/libnet-1.0.x/include" \
--with-libnet-libraries="$(STAGING_DIR)/usr/lib/libnet-1.0.x/lib" \
--with-libpcap-includes="$(STAGING_DIR)/usr/include" \
--with-dnet-includes="$(STAGING_DIR)/usr/include" \
--with-dnet-libraries="$(STAGING_DIR)/usr/libraries" \
--with-libpcap-libraries="$(STAGING_DIR)/usr/lib" \
--with-libpcre-includes="$(STAGING_DIR)/usr/include" \
--with-libpcre-libraries="$(STAGING_DIR)/usr/lib" \
$(2) \
, \
CPPFLAGS="$$$$CPPFLAGS" \
LDFLAGS="$$$$LDFLAGS -static" \
PATH="$(STAGING_DIR)/usr/lib/libnet-1.0.x/bin:$$$$PATH" \
$(3) \
);
endef
-
Create patches for any cross compiling idiocracies (there are probably checks in the Makefiles) - Patches are applied by
$(call Build/Prepare,Default)
You define patches by creating a directory called patches in your packages root folder,
creating the patches using the command: diff -u originalFile editedFile > 001-patchUno.patchThen move that patch into the patches directory - note the numbering system.
References
- http://airs.com/ian/configure/configure_toc.html#TOC32
- http://wiki.openwrt.org/doc/devel/crosscompile
Add new comment