@@ -463,3 +463,60 @@ You can also use it in your nerves project as `:github` dependency now.
463
463
# Update the `custom_rpi3` dep in your `deps/0` function.
464
464
{:custom_rpi3, github: "YourGitHubUserName/custom_rpi3", runtime: false, targets: :custom_rpi3}
465
465
```
466
+
467
+ ## Adding a custom Buildroot Package
468
+
469
+ If you have a non-Elixir program that' s too complicated to compile with
470
+ [elixir_make](https://github.com/elixir-lang/elixir_make) and not included in
471
+ Buildroot, you' ll need to add instructions for how to build it to your system.
472
+ This is called a "custom Buildroot package" and the process to add one in a
473
+ Nerves System is nearly the same as in Buildroot. This is documented in the
474
+ [Adding new package](http://nightly.buildroot.org/manual.html#adding-packages)
475
+ chapter of the Buildroot manual. The main difference with Nerves is the
476
+ directory.
477
+
478
+ As you go through this process, please consider whether it makes sense to
479
+ contributor your package upstream to Buildroot.
480
+
481
+ A Nerves System will need the following files in the root of the custom system
482
+ directory `src/<nerves_system_name>`:
483
+
484
+ 1. `Config.in` - Includes each package' s ` Config.in` file
485
+ 2. ` external.mk` - Includes each package' s `<package-name>.mk` file
486
+ 3. `packages` - Directory containing your custom package directories
487
+
488
+ Each directory _inside_ the `packages` directory should contain two things:
489
+
490
+ 1. `Config.in` - Defines package information
491
+ 2. `<package-name>.mk` - Defines how a package is built.
492
+
493
+ So if you wanted to build a package `libfoo`, first create the `Config.in` and
494
+ `external.mk` files at the base directory of your system.
495
+
496
+ `/Config.in`:
497
+
498
+ ```plain
499
+ menu "Custom Packages"
500
+
501
+ source "$NERVES_DEFCONFIG_DIR/packages/libfoo/Config.in"
502
+
503
+ endmenu
504
+ ```
505
+
506
+ `/external.mk`:
507
+
508
+ ```make
509
+ include $(sort $(wildcard $(NERVES_DEFCONFIG_DIR)/packages/*/*.mk))
510
+ ```
511
+
512
+ Then create the package directory and package files:
513
+
514
+ ```bash
515
+ mkdir -p packages/libfoo
516
+ touch packages/libfoo/Config.in
517
+ touch packages/libfoo/libfoo.mk
518
+ ```
519
+
520
+ At this point, you should follow the Official Buildroot documentation for what
521
+ should be added to these files. Often the easiest route is to find a similar
522
+ package in Buildroot and copy/paste the contains with appropriate renaming.
0 commit comments