I have a makefile:
SOURCES= helloworld.c
ifeq ($(OSNAME), linux)
# Object files needed to create library
OBJECTS=$(SOURCES:%.c=%.o)
endif
# Windows Microsoft C/C++ Optimizing Compiler Version 12
ifeq ($(OSNAME), win32)
OBJECTS=$(SOURCES:%.c=%.obj)
endif
#OBJECTS=$(SOURCES:%.c=%.o) #without this line print won't output anything
print:
@echo $(OBJECTS)
When I call make print (on linux and macOS), it prints empty line unless I uncomment the #OBJECTS=$(SOURCES:%.c=%.o) line.
Why is this happening? Arn't all variables global?