I am unable to understand the following piece of code from Contiki-os' native platform's makefile.
NM ?= nm
OBJCOPY ?= objcopy
STRIP ?= strip
ifdef WERROR
CFLAGSWERROR=-Werror -pedantic -std=c99 -Werror
endif
CFLAGSNO = -Wall -g -I/usr/local/include $(CFLAGSWERROR)
CFLAGS += $(CFLAGSNO) -O
Source: https://github.com/contiki-os/contiki/blob/master/cpu/native/Makefile.native#L13-20
It is not the variable assignments that i do not understand, my questions is what is 'WERROR' and how is it related to 'CFLAGS' and what is NM refer to? CC refers to compiler, LD to linker.
It would be great if someone could help me.
If WERROR is defined, the make file add options to the compilation, so that warnings are treated as errors. Presumably, something at some point will define WERROR=1 triggering this stricter build. CFLAGS will be used in the rule that compiles source code into object code.
From: http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_7.html
Compiling C programs:
n.o is made automatically from n.c with a recipe of the form ‘$(CC) $(CPPFLAGS) $(CFLAGS) -c’.