From ded13c27c6e9b88eb088677e031c5d86dff289ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 17 Sep 2017 18:36:53 +0200 Subject: Update user guide --- guide/ports.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'guide/ports.html') diff --git a/guide/ports.html b/guide/ports.html index 718b833..a741cba 100644 --- a/guide/ports.html +++ b/guide/ports.html @@ -95,7 +95,21 @@ be overriden.

The source files are automatically gathered from the contents of $(C_SRC_DIR). Erlang.mk looks for .c, .C, .cc and .cpp source files. You can define the variable SOURCES to manually -list the files to compile.

+list the files to compile.

8.4. Propagating compile and linker flags to sub-Makefiles

In some cases it might be necessary to propagate the flags +you just defined to the sub-Makefiles of your local project. +You generally can’t just export those as this could impact +the building of dependencies.

Makefiles allow you to export variables for specific targets. +When doing this, the variables will be exported only when +this target runs, and not for other targets. It is therefore +possible to export them when building the C code without +impacting other build steps.

By adding this to your Makefile all five variables will be +made available to sub-Makefiles when building C code:

app-c_src: export CC +=
+app-c_src: export CFLAGS +=
+app-c_src: export CPPFLAGS +=
+app-c_src: export LDFLAGS +=
+app-c_src: export LDLIBS +=

Appending an empty string to the existing value is necessary +because Makefiles expect an assignment for target-specific +exports. Alternatively you can set a new value:

app-c_src: export CFLAGS = -O3
-- cgit v1.2.3