How to cross compile external application

The OpenWrt building system is able to automatically download the source code, patch it, compile and install it in a second.

Consider the follow makefile under package/hotplug (read the comment):

# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 6372 2007-02-25 23:34:57Z nbd $
 
include $(TOPDIR)/rules.mk
 
#here we define the package name and version
PKG_NAME:=hotplug2
PKG_VERSION:=0.9
PKG_RELEASE:=2
 
#here the url were that file can be downloaded
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://isteve.bofh.cz/~isteve/hotplug2
#here we define the http://isteve.bofh.cz/~isteve/hotplug2/hotplug2-0.9.tar.gz md5sum for secure purpose (can be omitted)  
PKG_MD5SUM:=ea2c01d027b4002e4e6b0ff266f51a51
 
include $(INCLUDE_DIR)/package.mk
#after the include we define the package category and other useful information 
define Package/hotplug2
  SECTION:=base
  CATEGORY:=Base system
  VERSION:=0.9+r102-$(PKG_RELEASE)
  TITLE:=Dynamic device management subsystem for embedded systems
  URL:=http://isteve.bofh.cz/~isteve/hotplug2/
endef
 
#this is description
define Package/hotplug2/description
 Hotplug2 is a trivial replacement of some of the UDev functionality
 in a tiny pack, intended for Linux early userspace: Init RAM FS and InitRD.
endef
 
MAKE_FLAGS += CFLAGS="$(TARGET_CFLAGS) -DHAVE_RULES -I."
 
#here we define the list of files we need to package inside .ipk
define Package/hotplug2/install
	$(INSTALL_DIR) $(1)/etc
	$(INSTALL_DATA) ./files/hotplug2.rules $(1)/etc/
	$(INSTALL_DIR) $(1)/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/hotplug2 $(1)/sbin/
endef
 
$(eval $(call BuildPackage,hotplug2))

This simple makefile allow you to manage a complete cross-compilation without directly manage source code.

documentation/sdk/cross_compile_apps.txt · Last modified: 2010/02/06 11:02 (external edit)
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0