<p>I'm experimenting with an updated build system at work; currently, I'm trying to find a good way to set compiler &amp; flags depending on the target platform. </p>

<p>What I would like to do is something like</p>

<pre><code>switch $(PLATFORM)_$(BUILD_TYPE)
  case "Linux_x86_release"
     CFLAGS = -O3
  case "Linux_x86_debug"
     CFLAGS = -O0 -g
  case "ARM_release"
     CC = armcc
     AR = armlink
     CFLAGS = -O2 -fx
     ...
</code></pre>

<p>which is not supported by GNU Make. Now, my first thought was to just do</p>

<pre><code>-include $(PLATFORM)_$(BUILD_TYPE)
</code></pre>

<p>which is a pretty decent solution, however, it makes it hard to get an overview of what differs between files, not to mention that I'm looking forward to writing &amp; maintaining a good 60-80 files, each containing a set of variable definitions.</p>

<p>Does anyone happen to know a better way to accomplish this? I.e. setting a set of flags and other options based on another variable?</p>

Configuring such parameters would be the task of a
```
configure
```
script.
That being said, you can look into the syntax for
conditionals
and
conditional functions
. For example, you could try the following:
```
```
ifeq ($(PLATFORM)_$(BUILD_TYPE),Linux_x86_release)
    CFLAGS = -O3
endif
ifeq ($(PLATFORM)_$(BUILD_TYPE),Linux_x86_debug)
    CFLAGS = -O0 -g
endif
```
```