# Integrating Nunavut with a Makefile based build process

**URL:** <https://forum.opencyphal.org/t/integrating-nunavut-with-a-makefile-based-build-process/2036>\
**Category:** Nunavut\
**Created:** [November 28, 2023, 12:12pm UTC](https://forum.opencyphal.org/t/integrating-nunavut-with-a-makefile-based-build-process/2036 "2023-11-28T12:12:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ych](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/ych/32/1510_2.png) [@ych](https://forum.opencyphal.org/u/ych)\
**Post date:** [November 28, 2023, 12:12pm UTC](https://forum.opencyphal.org/t/integrating-nunavut-with-a-makefile-based-build-process/2036/1 "2023-11-28T12:12:14Z")

</div>

I’m working on integrating `nnvg` from Nunavut into our build process, which is based on Makefile. The files generated by `nnvg` include a disclaimer about version control, suggesting they should be generated as part of the build process:

```auto
// Checking this file under version control is not recommended unless it is used as part of a high-SIL
// safety-critical codebase. The typical usage scenario is to generate it as part of the build process.

```

I’m looking for examples or recommendations on creating Makefile rules that trigger `nnvg` only when changes occur in either the source or the lookup DSDL files. While I’ve discovered the `--list-outputs` and `--list-inputs` options in `nnvg`, integrating their outputs into the Makefile-based build process isn’t straightforward.

Here are the development steps I aim to achieve:  
0. Install `nunavut`.

1. Clone the project and its subprojects without the committed DSDL-generated code.
2. Execute `make`:
  - The build process should detect the absence of DSDL-generated code and generate it from the configured DSDL directories before compiling the project code.

3. Make changes in the project code without modifying DSDL files.
4. Execute `make` again:
  - The build process should recognize that the DSDL-generated code exists and hasn’t changed, hence doing nothing before compiling the project code.

5. Make changes in the project code that affect DSDL files.
6. Execute `make` once more:
  - The build process should detect changes in the DSDL files and either regenerate the modified files optimally or regenerate all the code before compiling the project code.

Any guidance or examples on setting up these Makefile rules with the appropriate `nnvg` options would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [November 28, 2023, 2:42pm UTC](https://forum.opencyphal.org/t/integrating-nunavut-with-a-makefile-based-build-process/2036/2 "2023-11-28T14:42:54Z")

</div>

If you remove points 5 and 6 then a simple make build target for the nnvg output directory will do the trick. This is trivial and does not require the use of `--list-outputs` et al. Here’s one way to do it:

```make
public_regulated_data_types-master:
	wget https://github.com/UAVCAN/public_regulated_data_types/archive/refs/heads/master.zip -q
	unzip -n master.zip > /dev/null
	rm -f master.zip*

public_regulated_data_types: public_regulated_data_types-master
	mkdir -p public_regulated_data_types
	mv -v public_regulated_data_types-master/** public_regulated_data_types/
	rm -rf public_regulated_data_types-master

generated/nunavut_out: public_regulated_data_types
	nnvg public_regulated_data_types/reg -eh -O generated/nunavut_out -I public_regulated_data_types/uavcan
	nnvg public_regulated_data_types/uavcan -eh -O generated/nunavut_out

```

Recompiling on changes to DSDL files is a neat feature but is usually not a critical one because DSDL files are not modified often.
