# How to setup a Legato Application project that can be built for different hardware setups

**URL:** <https://forum.legato.io/t/how-to-setup-a-legato-application-project-that-can-be-built-for-different-hardware-setups/3517>\
**Category:** Legato Application Framework\
**Created:** [August 3, 2018, 8:54am UTC](https://forum.legato.io/t/how-to-setup-a-legato-application-project-that-can-be-built-for-different-hardware-setups/3517 "2018-08-03T08:54:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![annaertd](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@annaertd](https://forum.legato.io/u/annaertd)\
**Post date:** [August 3, 2018, 8:54am UTC](https://forum.legato.io/t/how-to-setup-a-legato-application-project-that-can-be-built-for-different-hardware-setups/3517/1 "2018-08-03T08:54:43Z")

</div>

Hi,

I use Developer Studio 5.3.1 to create Legato projects which should run on both mangOH Green and customer boards.  
I would like to build for these different hardware boards using the same project source stack.  
At this moment, I use a preprocessor _#define_ in my C sources, and I use an environment variable in my .adef file.  
So, this means that I always have to change my configuration at 2 different places.

Is there a way to use 1 type of configuration/variable/definition/symbol which can be used in both C sources and .adef files?

Example:

**C source**

#define HW\_BOARD CUSTOMER\_BOARD

#if HW\_BOARD == MANGOH\_GREEN  
le\_tty\_Open(“/dev/ttyHSL1”, O\_RDWR | O\_NOCTTY | O\_NDELAY);  
#else  
le\_tty\_Open(“/dev/ttyUSB4”, O\_RDWR | O\_NOCTTY | O\_NDELAY);  
#endif

**adef file**

requires:  
{  
device:  
{  
#if ${ENVIRONMENT\_VAR\_HW\_BOARD} = mangoh\_green  
[rw] /dev/ttyHSL1 /dev/ttyHSL1  
#else  
[rw] /dev/ttyUSB4 /dev/ttyUSB4  
#endif  
}  
}

Greetings,  
annaertd

---

<div class="post-metadata">

**Author:** ![ktanikel](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@ktanikel](https://forum.legato.io/u/ktanikel)\
**Post date:** [August 3, 2018, 10:49pm UTC](https://forum.legato.io/t/how-to-setup-a-legato-application-project-that-can-be-built-for-different-hardware-setups/3517/2 "2018-08-03T22:49:30Z")

</div>

Maybe have a cflags section in your definition files and pass the preprocessor your board specific defines with the -D option?

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [August 6, 2018, 8:57am UTC](https://forum.legato.io/t/how-to-setup-a-legato-application-project-that-can-be-built-for-different-hardware-setups/3517/3 "2018-08-06T08:57:12Z")

</div>

Hi @annaertd,  
same suggestion than @ktanikel: you should be able to use a **`cflags`** section with a different content according to your **`ENVIRONMENT_VAR_HW_BOARD`** value, specifying different -D options.

---

<div class="post-metadata">

**Author:** ![annaertd](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@annaertd](https://forum.legato.io/u/annaertd)\
**Post date:** [August 6, 2018, 10:32am UTC](https://forum.legato.io/t/how-to-setup-a-legato-application-project-that-can-be-built-for-different-hardware-setups/3517/4 "2018-08-06T10:32:01Z")

</div>

This solves my issue.  
Thanks a lot!
