diff options
author | Loïc Hoguin <[email protected]> | 2017-10-03 13:39:41 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-10-03 13:39:41 +0200 |
commit | b5d4cb91f80c833795a2d87050c3674bb7aecdc5 (patch) | |
tree | 62bf0ad8326006fcd3407fcb7c34c844c0dc0874 /docs/en/erlang.mk/1/guide/ports.asciidoc | |
parent | 1f8d51dd2692fc3978080419987bbe4d49a41a90 (diff) | |
download | ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.tar.gz ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.tar.bz2 ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.zip |
Update Hugo, docs
Diffstat (limited to 'docs/en/erlang.mk/1/guide/ports.asciidoc')
-rw-r--r-- | docs/en/erlang.mk/1/guide/ports.asciidoc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/docs/en/erlang.mk/1/guide/ports.asciidoc b/docs/en/erlang.mk/1/guide/ports.asciidoc index 02c636fd..907ee366 100644 --- a/docs/en/erlang.mk/1/guide/ports.asciidoc +++ b/docs/en/erlang.mk/1/guide/ports.asciidoc @@ -98,3 +98,37 @@ 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. + +=== 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: + +[source,make] +---- +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: + +[source,make] +---- +app-c_src: export CFLAGS = -O3 +---- |