Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| docs:guide-developer:helloworld:chapter6 [2018/12/05 04:52] – [Modifying the package manifest, and testing the build] gth | docs:guide-developer:helloworld:chapter6 [2024/12/16 21:27] (current) – syntax highligting stokito | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| * 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 | ||
| - | * Configured the PATH environment variable | + | * Configured the '' |
| * Created a simple “Hello, world!” application using native compilation tools | * Created a simple “Hello, world!” application using native compilation tools | ||
| * Created a local package feed for your application | * Created a local package feed for your application | ||
| Line 20: | Line 20: | ||
| Our test application is still quite simple, containing only a single source file. As a result, it is quite straightforward to compile and link it, although the syntax to do so is somewhat obscure in the package manifest: | Our test application is still quite simple, containing only a single source file. As a result, it is quite straightforward to compile and link it, although the syntax to do so is somewhat obscure in the package manifest: | ||
| - | < | + | < |
| # Package build instructions; | # Package build instructions; | ||
| define Build/ | define Build/ | ||
| Line 33: | Line 33: | ||
| Using GNU make is one approach to solving some of these problems. | Using GNU make is one approach to solving some of these problems. | ||
| - | ===== Creating a makefile | + | ===== Creating a Makefile |
| - | In order to use GNU make, it is necessary to create a makefile | + | In order to use GNU make, it is necessary to create a Makefile |
| - | Let's change to the source directory of the application and create the makefile: | + | Let's change to the source directory of the application and create the Makefile: |
| - | < | + | < |
| cd / | cd / | ||
| touch Makefile | touch Makefile | ||
| </ | </ | ||
| - | Using a text editor, paste the following content into the file. Note that similar to the package manifest, the makefile | + | Using a text editor, paste the following content into the file. Note that similar to the package manifest, the Makefile |
| - | <code make makefile> | + | <code make Makefile> |
| # Global target; when ' | # Global target; when ' | ||
| all: helloworld | all: helloworld | ||
| Line 81: | Line 81: | ||
| </ | </ | ||
| - | ===== Testing the makefile | + | ===== Testing the Makefile |
| Before modifying our package manifest, it is important that we test the makefile-based build process. To build the ' | Before modifying our package manifest, it is important that we test the makefile-based build process. To build the ' | ||
| Line 90: | Line 90: | ||
| If you get the message '' | If you get the message '' | ||
| - | < | + | < |
| touch helloworld.c | touch helloworld.c | ||
| make | make | ||
| Line 97: | Line 97: | ||
| This will build the application using the native compilation tools. | This will build the application using the native compilation tools. | ||
| - | You'll see that GNU '' | + | You'll see that GNU '' |
| ===== Modifying the package manifest, and testing the build ===== | ===== Modifying the package manifest, and testing the build ===== | ||
| - | Now that our package' | + | Now that our package' |
| When migrating to use the GNU make tool, you might not need to use hard tabs anymore. However, I find it good practise to use a hard tab at the start of each command row. When using the multi-line separator ' | When migrating to use the GNU make tool, you might not need to use hard tabs anymore. However, I find it good practise to use a hard tab at the start of each command row. When using the multi-line separator ' | ||
| - | < | + | < |
| # Package build instructions; | # Package build instructions; | ||
| define Build/ | define Build/ | ||
| Line 115: | Line 115: | ||
| After modifying your package manifest, test the package build process again from the OpenWrt build system' | After modifying your package manifest, test the package build process again from the OpenWrt build system' | ||
| - | < | + | < |
| cd / | cd / | ||
| make package/ | make package/ | ||
| Line 122: | Line 122: | ||
| If you encounter errors when building it using GNU make, it is sometimes necessary to manually update and install the feeds. Perform the same steps that we did in chapter 4: | If you encounter errors when building it using GNU make, it is sometimes necessary to manually update and install the feeds. Perform the same steps that we did in chapter 4: | ||
| - | < | + | < |
| cd / | cd / | ||
| ./ | ./ | ||
| Line 128: | Line 128: | ||
| </ | </ | ||
| - | If still having issues, ensure your source directory (/ | + | If still having issues, ensure your source directory (/ |
| ===== Conclusion ===== | ===== Conclusion ===== | ||
| In this lengthy chapter, we modified our original application to use GNU make instead of direct compilation commands. We wrote a simple makefile to evaluate all source code files in the directory, compile them, and link the generated object files into an executable. We then tested the makefile using native compilation tools to ensure it runs properly, and finally modified our package manifest to use the GNU make build process instead of the hard-coded compilation commands. | In this lengthy chapter, we modified our original application to use GNU make instead of direct compilation commands. We wrote a simple makefile to evaluate all source code files in the directory, compile them, and link the generated object files into an executable. We then tested the makefile using native compilation tools to ensure it runs properly, and finally modified our package manifest to use the GNU make build process instead of the hard-coded compilation commands. | ||