Search code examples
cincludemakefile

Difference between "include" and "-include" in a makefile


In a makefile, what is the difference in meaning between include and -include?

Examples:

-include $(APPINCLUDES)

include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET)

Solution

  • The difference is that -include won't generate an error if the include file doesn't exist.

    The - prefix can be used many places in the Makefile to perform actions that you don't mind if they fail.