Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:guide-developer:helloworld:chapter3 [2017/10/20 14:54] – [Creating the package manifest file] zhenkyledocs:guide-developer:helloworld:chapter3 [2023/04/11 09:24] (current) – Add warning about code editors converting tab to spaces in Makefile. Changed the previous sentence as I have changed the Makefile to use hard tabs itself and reader doesn't need to edit it anymore astro
Line 3: Line 3:
 ====== Creating a package from your application ====== ====== Creating a package from your application ======
  
-This is the third chapter in the "Hello, world!" for LEDE article series. At this point, you should've already accomplished the following tasks:+This is the third chapter in the "Hello, world!" for OpenWrt article series. At this point, you should've already accomplished the following tasks:
   * Commissioned your development environment   * Commissioned your development environment
   * Prepared, configured and built the tools and the cross-compilation toolchain   * Prepared, configured and built the tools and the cross-compilation toolchain
Line 13: Line 13:
 ===== Creating a package feed for your packages ===== ===== Creating a package feed for your packages =====
  
-The LEDE build system revolves heavily around the concept of packages. They are the bread and butter of the system. No matter the software, there's almost always a package for it. This applies to nearly everything in the system, be it the target-independent tools, the cross-compilation toolchain, the Linux kernel of the target firmware, the additional modules that are bundled with the kernel or the various applications that will be installed onto the root file system of the target firmware.+The OpenWrt build system revolves heavily around the concept of packages. They are the bread and butter of the system. No matter the software, there's almost always a package for it. This applies to nearly everything in the system, be it the target-independent tools, the cross-compilation toolchain, the Linux kernel of the target firmware, the additional modules that are bundled with the kernel or the various applications that will be installed onto the root file system of the target firmware.
  
 Due to this package-oriented nature, it is only logical to utilize the same approach for the "Hello, World! -application as well. Due to this package-oriented nature, it is only logical to utilize the same approach for the "Hello, World! -application as well.
Line 27: Line 27:
 ===== Creating the package manifest file ===== ===== Creating the package manifest file =====
  
-Each package in the LEDE build system is described by a package manifest file. The manifest file is responsible for describing the package, what it does, and must at least provide instructions on where to obtain the source code, how to build it and which files should be contained in the final installable package. A package manifest may additionally contain options for optional configuration scripts, specify dependencies between packages and so on.+Each package in the OpenWrt build system is described by a package manifest file. The manifest file is responsible for describing the package, what it does, and must at least provide instructions on where to obtain the source code, how to build it and which files should be contained in the final installable package. A package manifest may additionally contain options for optional configuration scripts, specify dependencies between packages and so on.
  
 In order for the source code of our application to become a package, and become a part of the package repository that we previously created, we will need to create a package manifest for it: In order for the source code of our application to become a package, and become a part of the package repository that we previously created, we will need to create a package manifest for it:
Line 35: Line 35:
 </code> </code>
  
-Using your favorite text editor, enter the following text as the content of the package manifest. Note that several sections of this file are used by the build system's own GNU make tool, and for this reason, there are **both shorter and longer whitespace indentations** in the file. Shorter ones are simple space characters, while the longer ones should be replaced by hard tabs when editing the file:+Using your favorite text editor, enter the following text as the content of the package manifest. Note that several sections of this file are used by the build system's own GNU make tool, and for this reason, there are **both shorter and longer whitespace indentations** in the file. Shorter ones are simple space characters, while the longer ones are hard tabs. Note that some code editors may convert the tab character to space characters but [[https://beebo.org/haycorn/2015-04-20_tabs-and-makefiles.html|GNU make does not accept spaces]].
 <code - makefile> <code - makefile>
 include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
Line 66: Line 66:
 # The last command is necessary to ensure our preparation instructions remain compatible with the patching system. # The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
 define Build/Prepare define Build/Prepare
-        mkdir -p $(PKG_BUILD_DIR) + mkdir -p $(PKG_BUILD_DIR) 
-        cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR) + cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR) 
-        $(Build/Patch)+ $(Build/Patch)
 endef endef
  
 # Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable # Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
 define Build/Compile define Build/Compile
-        $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c + $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c 
-        $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o+ $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o
 endef endef
  
 # Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder # Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
 define Package/helloworld/install define Package/helloworld/install
-        $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/bin 
-        $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
 endef endef
  
  • Last modified: 2017/10/20 14:54
  • by zhenkyle