Openwrt கற்றல் பாதை - (5-Openwrt தொகுப்பு Makefile)

Openwrt Learning Path



3482555-4fcb6bd769f2e41b.jpgதலைப்பு: இலவசம்

Openwrt தொகுப்பு Makefile

'Openwrt main Makefile' பிரிவில், முக்கிய Makefile கடந்து செல்லும் என்று ஒரு பழமொழி உள்ளது. include package/Makefile தொகுப்பின் கீழ் Makefile ஐ அழைக்கவும், தொகுப்பின் கீழ் உள்ள Makefile மீண்டும் அழைப்பை அழைக்கும். $(call subdir,package) தொகுப்பு துணை அடைவில் Makefile. தொகுப்பின் கீழ் உள்ள மேக்ஃபைல் மூலக் குறியீட்டில் வழங்கப்பட்டுள்ளது, அது மாற்றப்படாது, ஆனால் தொகுப்பு துணை அடைவில் உள்ள மேக்ஃபைல் என்பது நாம் அடிக்கடி சமாளிக்க வேண்டியதுதான். இந்த அத்தியாயம் அதை விளக்கும்.

தொகுப்பின் கீழ் துணை அடைவை திறந்து பொதுவாக சில விஷயங்களைக் கண்டுபிடிப்போம்:



  • தொகுப்பு / $ (PKG_NAME) / Makefile [தேவை]
  • தொகுப்பு / $ (PKG_NAME) / src / [விரும்பினால்]
  • தொகுப்பு / $ (PKG_NAME) / திட்டுகள் / [விரும்பினால்]
  • தொகுப்பு / $ (PKG_NAME) / கோப்புகள் / [விரும்பினால்]

Src அடைவு, திட்டுகள் அடைவு மற்றும் கோப்புகள் அடைவு அனைத்தும் விருப்பத்தேர்வு. Src கோப்பகம் செயல்பாட்டு தொகுதியின் மூல குறியீட்டை சேமிக்கிறது. ஒப்பந்தங்கள் கோப்பகத்தில் பொதுவாக பிழைத் திருத்தங்கள் மற்றும் இயங்கக்கூடிய கோப்பு அளவை மேம்படுத்தல் ஆகியவை அடங்கும். கோப்புகள் அடைவு பொதுவாக உள்ளமைவு கோப்புகள் உள்ளிட்ட ஸ்கிரிப்ட்களை இயக்குகிறது. காத்திரு. மேக்ஃபைலில் குறிப்பிடப்பட்டுள்ள வரை கோப்பகத்தின் பெயர் விருப்பமாக இருப்பதால், பிற கோப்பகங்களையும் நீங்கள் காணலாம்.



மேக்ஃபைல் மிகவும் முக்கியமானதாகும், பொதுவாக இது தொகுப்பை பதிவிறக்கம் செய்ய, தொகுக்க மற்றும் நிறுவுவதற்கான படிகளை வழங்குகிறது.



தொகுப்பு துணை அடைவின் மேக்ஃபைலை நாம் திறக்கும்போது, ​​இது ஒரு மேக்ஃபைல் என்பதை அங்கீகரிப்பது கடினம். அதன் வடிவம் சாதாரண மேக்ஃபைலிலிருந்து வேறுபட்டது, ஏனெனில் அதன் செயல்பாடு சாதாரண மேக்ஃபைலிலிருந்து வேறுபட்டது, இது எழுத வசதியான வார்ப்புரு.

இங்கே, தொகுப்பு / பிரிட்ஜ் / மேக்ஃபைலை உதாரணமாக எடுத்துக் கொள்ளுங்கள்:

include $(TOPDIR)/rules.mk PKG_NAME:=bridge PKG_VERSION:=1.0.6 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/bridge-utils-$(PKG_VERSION) PKG_SOURCE:=bridge-utils-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:root@xxxxx/bridge PKG_MD5SUM:=9b7dc52656f5cbec846a7ba3299f73bd PKG_CAT:=zcat include $(INCLUDE_DIR)/package.mk define Package/bridge SECTION:=base CATEGORY:=Network DEFAULT:=y TITLE:=Ethernet bridging configuration utility DESCRIPTION:=Ethernet bridging configuration utility\ Manage ethernet bridging a way to connect networks together to\ form a larger network. URL:=http://bridge.sourceforge.net/ endef define Build/Configure $(call Build/Configure/Default,--with-linux-headers=$(LINUX_DIR)) endef define Package/bridge/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/brctl/brctl $(1)/usr/sbin/ endef $(eval $(call BuildPackage,bridge))

1. உலகளாவிய மாறிகள் உள்ளன


முதலாவதாக, மேக்ஃபைலில் உள்ள முதல் வரியில் பின்வரும் கட்டளை இருக்க வேண்டும், இது மேக்ஃபைலின் சில உலகளாவிய மாறிகளின் வரையறையாகும்.
include (TOPDIR) /rules.mk அடங்கும்



2. தொகுப்பு மாறிகள்


ஒரு தொகுப்பை உருவாக்குவதற்கு அதிக வேலை தேவையில்லை, பெரும்பாலான வேலைகள் பிற மேக்ஃபைல்களில் மறைக்கப்பட்டுள்ளன, மேலும் படைப்பு வேலை பல மாறிகள் குறித்த பணிகளாக சுருக்கப்பட்டுள்ளது.

PKG_NAME : the name of the package, displayed in menuconfig and ipkg PKG_VERSION : The version of the package, the version of the trunk branch is exactly what we want to download. PKG_RELEASE : the erased version of this makefile PKG_BUILD_DIR : the directory where the package is compiled PKG_SOURCE : The name of the package to be downloaded, usually composed of PKG_NAME and PKG_VERSION PKG_SOURCE_URL : Download a link to this package PKG_MD5SUM : MD5 value of the package PKG_CAT: How to extract the package (zcat, bzcat, unzip) PKG_BUILD_DEPENDS : A pre-built package is required, but only when building this package, not when it is running. Its syntax is the same as DEPENDS below.

3.பில்ட் பேக்கேஜ் தொடர்பான மேக்ரோ வரையறைகள்


1. மெனுகான்ஃபிக் மற்றும் ஐபிகிஜி ஆகியவற்றில் தொகுப்பு தகவலை விவரிக்கவும், பின்வரும் மாறிகளை நீங்கள் வரையறுக்கலாம்:

define Package/ SECTION : Package Type CATEGORY : The location of the package in menuconfig, such as Network, Utilities SUBMENU : The secondary directory to which the package belongs in menuconfig, such as dial-in/up DEFAULT: default compilation mode, m=compile to module, y=compile to image, n or no compilation, [dependency The package is separated by a space. The front + plus is the default display. Lai package does not add + is not displayed by default. Select the dependent package to display] TITLE : Package title DESCRIPTION : Detailed description of the package, due to bugs, has now given up URL : The original location of the software, usually the home page of the software author MAINTAINER : (optional) package maintainer DEPENDS : (optional) dependencies, running other packages that the software depends on endif

2. கட்டமைப்பு வழிமுறைகள்

Define Build/Configure (optional) The ./configure is required in Automake, so this configuration method is mainly for software that needs to be configured. Package-designed, generally self-developed software packages can not be described here. endif

3. தொகுப்பு நிறுவல்

define Package/install The installation method of the package, including a series of copies of the compiled file to the specified location. Bring one when calling The parameter is the image file system directory embedded in the system, so $(1) indicates the image of the embedded system. record. Generally, the following methods can be used: $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/bin/ endif

4. பிற பில்ட் பேக்கேஜ் தொடர்பான மேக்ரோ வரையறைகள்

மேலே பட்டியலிடப்பட்ட மூன்று பாலம் தொகுதியின் கீழ் பயன்படுத்தப்படும் மேக்ரோ வரையறைகள். இன்னும் பல வரையறைகள் உள்ளன. அவற்றை நாம் புரிந்து கொள்ளலாம், மற்ற சூழ்நிலைகளும் பயன்படுத்தப்படலாம்.

1. தயாரிப்பை தொகுத்தல்

Define Build/Prepare (optional) Packages downloaded from the Internet do not need to be described, for non-online downloads or self-developed packages. The compilation preparation method must be explained as follows: mkdir -p $(PKG_BUILD_DIR) Create a build directory, which is $(TOPDIR)/build_dir/target-*/$(PKG_NAME)-%(PKG_VERSION) $(CP) ./src/* $(PKG_BUILD_DIR)/ Copy the source code of the package src to the build directory. endif

2. மூல குறியீட்டை தொகுக்கவும்

Define Build/Compile (optional) The default is to compile the Makefile inside the source, if you want to pass some parameters such as the ring What is the environment variable, then you can define, compile methods, can not be defined without special instructions. if not The definition will use the default compilation method Build/Compile/Default Self-developed packages can consider the following definitions. $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS) CFLAGS='$(TARGET_CFLAGS) -I$(LINUX_DIR)/include' endif

3. நிறுவலுக்கு முன் ஸ்கிரிப்ட்கள் செயல்படுத்தப்படுகின்றன

Define Package/ $(PKG_NAME)/ preinst (optional) The script that was executed before the software installation, don't forget to add #!/bin/sh in the first sentence. If the script is finished, cancel the installation process and let it return false. #!/bin/sh ......... exit 0 endif

4. நிறுவலுக்குப் பிறகு ஸ்கிரிப்ட்கள் செயல்படுத்தப்படுகின்றன

Define Package/ $(PKG_NAME)/ postinst (optional) The script that was executed after the software was installed, don't forget to add #!/bin/sh in the first sentence. #!/bin/sh ......... exit 0 endif

5. முன்பு செயல்படுத்தப்பட்ட ஸ்கிரிப்டை நீக்கு

Define Package/ $(PKG_NAME)/ prerm (optional) The software removes the script that was executed before, and don't forget to add #!/bin/sh to the first sentence. If the script is finished executing to cancel the deletion process, just let it return false. #!/bin/sh ......... exit 0 endif

6. நீக்கப்பட்ட பிறகு செயல்படுத்தப்பட்ட ஸ்கிரிப்ட்

Define Package/ $(PKG_NAME)/ postrm (optional) The script that was executed after the software was deleted, don't forget to add #!/bin/sh to the first sentence. #!/bin/sh ......... exit 0 endif

சில வரையறைகள் 'தொகுப்பு /' முன்னொட்டுகள் மற்றும் பிறவை 'கட்டமைத்தல்' முன்னொட்டுகளாக ஏன் வரையறுக்கப்படுகின்றன? ஏனென்றால் ஓப்பன்வர்ட் ஒரு அம்சத்தை ஆதரிக்கிறது: ஒரு மூலத்திலிருந்து பல தொகுப்புகளை உருவாக்குதல். மேக்ஃபைல் ஒரு மூலக் குறியீட்டிற்கு ஒத்திருக்கிறது என்ற அனுமானத்தில் OpenWrt செயல்படுகிறது, ஆனால் தொகுக்கப்பட்ட நிரலை எத்தனை தொகுப்புகளாகப் பிரிக்கலாம். தொகுப்பு ஒரே ஒரு முறை என்பதால், உலகளாவிய 'பில்ட்' வரையறையைப் பயன்படுத்துவது மிகவும் பொருத்தமானது. நீங்கள் நிறைய 'தொகுப்பு /' வரையறைகளைச் சேர்க்கலாம், ஒவ்வொரு தொகுப்புக்கும் நிறுவல் முறையைக் குறிப்பிடவும்.

5. மென்பொருள் தொகுப்பை செயல்படுத்துதல்


முந்தைய வரையறையை முடித்த பிறகு, பல்வேறு வரையறைகளை செயல்படுத்த நீங்கள் எவால் செயல்பாட்டைப் பயன்படுத்த வேண்டும். இது மிக முக்கியமான பில்ட் பேக்கேஜ் மேக்ரோ ஆகும், இது $ (INCLUDE_DIR) /package.mk கோப்பில் வரையறுக்கப்பட்டுள்ளது. பில்ட் பேக்கேஜ் மேக்ரோவுக்கு ஒரே ஒரு அளவுரு தேவைப்படுகிறது, தொகுக்க தொகுப்பின் பெயர், இந்த விஷயத்தில் 'பிரிட்ஜ்'.

பொதுவான தொகுப்புகளுக்கு $(eval $(call Package,$(PKG_NAME)))

கர்னல் தொகுதிகளுக்கு $(eval $(call KernelPackage,$(PKG_NAME)))

ஒரு தொகுப்பில் பல நிரல்கள் இருந்தால், பல தொகுப்புகளைக் கையாள எவால் செயல்பாட்டை வடிவமைக்க முடியும்.

மேக்ஃபைலைத் திருத்தி குறிப்பிட்ட கோப்பகத்தில் வைத்த பிறகு, இந்த புதிய தொகுப்பு அடுத்த முறை செயல்படுத்தப்படும். make menuconfig நீங்கள் தோன்றும்போது, ​​இந்த தொகுப்பைத் தேர்வுசெய்து, சேமித்து வெளியேறலாம், தொகுக்கலாம் மற்றும் ஒரு தொகுப்பை வெற்றிகரமாக ஓப்பன்வர்ட்டில் போர்ட் செய்யலாம். குறிப்பிட்ட உதாரணம் 'Openwrt add function module to package' பிரிவில் விளக்கப்படும்.

Openwrt தொகுப்பு Makefile இன் பகுப்பாய்வு இங்கே உள்ளது, அதை நீங்கள் உணரும்போது தொடர்ந்து புதுப்பிக்கப்படும்.

குறிப்பு: மேற்கண்ட உள்ளடக்கங்கள் கற்றல் செயல்பாட்டின் போது நான் குவித்த சில அனுபவங்கள். மற்ற கட்டுரைகளைப் பற்றி கொஞ்சம் அறிவு இருப்பது தவிர்க்க முடியாதது. ஏதேனும் மீறல் இருந்தால், தயவுசெய்து எனக்கு அறிவிக்கவும், உள்ளடக்கத்தின் மூலத்தை சரியான நேரத்தில் நீக்குவேன் அல்லது குறிப்பேன், ஏதேனும் பிழை இருந்தால், தயவுசெய்து ஒரு விவாதத்தை நடத்துவதற்கு சுட்டிக்காட்டவும். கட்டுரை ஒரு வழிகாட்டும் பாத்திரம் மட்டுமே, விரிவான தரவு பகுப்பாய்விற்கு Openwrt தொடர்பான டுடோரியலை சரிபார்க்கவும். உங்கள் மதிப்பாய்வுக்கு நன்றி.