OpenWrt Add Package

Source: Internet
Author: User
Tags foreach eval parent directory prepare

variable name meaning

Section     //package Type
category    //display in Menuconfig which directory
submenu     //menuconfig subdirectory
TITLE       // Simple introduction
DESCRIPTION//package details URL/
/         Source of the network path maintainer//  maintainer
DEPENDS     //Dependency Package
Pkg_name        //package name, the
version number of pkg_version//     software version number
Pkg_release     //makefile will be visible in Menuconfig and ipkg
Pkg_source      //source code of the file name
pkg_md5sum      //source code file validation code. Used to check if the package is properly downloaded
pkg_cat/         /Source code file decompression method (Zcat, Bzcat, unzip)
Pkg_build_dir   //package compilation directory. Its parent directory is $ (build_dir). If not specified, the default is $ (build_dir)/$ (pkg_name) $ (pkg_version)

Package

Define package/$ (pkg_name)
    section:=utils
    category:=utilities
    title:=helloworld--Prints a snarky Message
Endef

Build/prepare
The compilation preparation method. All of your programs are placed in the SRC directory. General methods of Preparation:

Define Build/prepare
    Mkdir-p $ (pkg_build_dir)
    $ (CP)./src/* $ (pkg_build_dir)/
Endef

Build/compile
The compilation method. If not defined, the default compilation method Build/compile/default will be used. General method of Definition:

Define Build/compile
    $ (make)-C $ (pkg_build_dir) \
        $ (target_configure_opts) cflags= "$ (target_cflags)-i$ ( Linux_dir)/include "
endef

package/$ (pkg_name)/install
Installation method. Example:

Define package/$ (Pkg_name)/install
    $ (install_dir) $ (1)/etc/init.d/
    $ (install_bin) $ (pkg_build_dir)/hello $ (1)/etc/init.d/
    $ (install_data) $ (pkg_build_dir)/configs/hello.config $ (1)/etc/
    $ (install_conf) $ (PKG_ Build_dir)/configs/hello.config $ (1)/etc/
#   $ (CP) $ (pkg_build_dir)/tools/{xxx} $ (1)/usr/sbin///default permissions, And just a simple copy of
endef.

Install_xxx: Install to Pkg_build_dir and file system directory
CP: Only installed in the Pkg_build_dir directory

The INSTALL_XXX variable is defined in the $ (topdir)/rules.mk

install_bin:=install-m0755
install_dir:=install-d-m0755
install_data:=install-m0644
INSTALL_CONF:= install-m0600

Eval

$ (eval <text>)

Use text as part of the makefile file

Pager

$ (call buildpackage,$ (Pkg_name))

Reference the contents of the Buildpackage variable and replace the Buildpackage internal $ (1) with Pkg_name

Buildpackage
The buildpackage variable is defined in the $ (include_dir)/package.mk

Define Buildpackage
  $ (build/includeoverlay) $ (
  eval $ (package/default))
  $ (eval $ (package/$ (1)))

ifdef DESCRIPTION
$$ (Error description:= is obsolete, use package/pkg_name/description)
endif

ifndef package/$ (1)/description
define package/$ (1)/description
    $ (TITLE)
endef
endif

  $ (foreach FIELD, TITLE CATEGORY priority sections VERSION,
    ifeq ($ (FIELD)),
      $$ (Error package/$ (1) is missing the $ (FIEL D) field)
    endif
  )

  $ (call shexport,package/$ (1)/description)
  $ (call shexport,package/$ (1)/ Config)

  $ (if $ (DUMP), \
    $ (dumpinfo/package), \
    $ (foreach target, \
      $ (if $ (package/$ (1)/targets), $ (package/$ (1)/targets), \
        $ (if $ (pkg_targets), $ (pkg_targets), ipkg) \
      ), $ (buildtarget/$ (target)) \
    ) \
  )
  $ (if $ (pkg_host_only) $ (DUMP), $ (call build/defaulttargets,$ (1)))
Endef

the correct compilation process

# make Menuconfig
# make-j   //Automatically select the number of CPUs, general compilation will be wrong
# making
# making package/$ (Pkg_name)/install

You must make a success before you can execute the install, otherwise you will be prompted to rely on library warnings

Note
If you add a package that needs to be cross-compiled, remember to set the cross compiler in CMakeLists.txt

SET (Cmake_c_compiler "MIPSEL-OPENWRT-LINUX-UCLIBC-GCC")

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.