- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am using ModusToolbox build system in the IDE mode.
Is there a way in the Makefile to make the CFLAGS to be applied only to user (my) source code files, and not to all the framework source files ?
Regards
Nicolas
Solved! Go to Solution.
- Labels:
-
ModusToolbox General
- Tags:
- makefile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @nicolas,
You could try following the steps mentioned in this thread - Compile option settings for one file or follow the steps mentioned below -
Edit the application Makefile, by appending the following code snippet to the end of the Makefile (after the line with "include $(CY_TOOLS_DIR)/make/start.mk"):
define CY_MACRO_CUSTOM_CFLAGS
$(filter %$(
1
:%.c=%.o),$(CY_BUILD_ALL_OBJ_FILES)): $(filter %$(
1
),$(CY_SEARCH_APP_SOURCE) $(SOURCES))
$$(info $$(CY_INDENT)Compiling file $$(CY_COMPILE_PRINT) with $(
2
))
$$(CY_NOISE)$$(CY_BUILD_COMPILE_C) $$@ $$< $(
2
)
endef
ifneq ($(CY_SECONDSTAGE),)
$(eval $(call CY_MACRO_CUSTOM_CFLAGS,main.c,-Wextra -Werror))
endif
The snippet above defines the additional C compiler flags: "-Wextra -Werror" for a single file main.c
Please let me know if this works.
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @nicolas,
You could try following the steps mentioned in this thread - Compile option settings for one file or follow the steps mentioned below -
Edit the application Makefile, by appending the following code snippet to the end of the Makefile (after the line with "include $(CY_TOOLS_DIR)/make/start.mk"):
define CY_MACRO_CUSTOM_CFLAGS
$(filter %$(
1
:%.c=%.o),$(CY_BUILD_ALL_OBJ_FILES)): $(filter %$(
1
),$(CY_SEARCH_APP_SOURCE) $(SOURCES))
$$(info $$(CY_INDENT)Compiling file $$(CY_COMPILE_PRINT) with $(
2
))
$$(CY_NOISE)$$(CY_BUILD_COMPILE_C) $$@ $$< $(
2
)
endef
ifneq ($(CY_SECONDSTAGE),)
$(eval $(call CY_MACRO_CUSTOM_CFLAGS,main.c,-Wextra -Werror))
endif
The snippet above defines the additional C compiler flags: "-Wextra -Werror" for a single file main.c
Please let me know if this works.
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Rakshith,
Thanks for your help.
Unfortunately this is not working for me. Some of the variables seems to be empty (CY_COMPILE_PRINT), log from the build is"Compiling file with -Wextra -Werror".
Also added an echo of the CY_BUILD_COMPILE_C after the eval but it does not include the additionals CFLAGS. Checked also the main.c compilation line in the log but extra CFLAGS are not there.
I got a "sources" directory at the same level of the Makefile (I tried also "sources/main.c" instead of "main.c" in your proposal), I would need to be able to add extra flags to all the source files recursively in that folder.
Regards
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content