Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

Examples:

-include $(APPINCLUDES)  include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET) 
like image 250
Martin Stålberg Avatar asked Jun 07 '13 10:06

Martin Stålberg


People also ask

What is include in makefile?

The include directive tells make to suspend reading the current makefile and read one or more other makefiles before continuing. The directive is a line in the makefile that looks like this: include filenames ... filenames can contain shell file name patterns.

What does := mean in a makefile?

":=" is for defining simply expanded variable, which is expanded once and for all.

Can I have multiple makefiles?

If you use more than one ' -f ' or ' --file ' option, you can specify several makefiles. All the makefiles are effectively concatenated in the order specified. The default makefile names GNUmakefile , makefile and Makefile are not checked automatically if you specify ' -f ' or ' --file '.

What is Ldflags in makefile?

LDFLAGS: Extra flags to give to compilers when they are supposed to invoke the linker, 'ld', such as -L. Libraries (-lfoo) should be added to the LDLIBS variable instead. LDLIBS: Library flags or names given to compilers when they are supposed to invoke the linker, 'ld'.


Video Answer


1 Answers

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.

like image 102
trojanfoe Avatar answered Oct 03 '22 14:10

trojanfoe