# Simple Makefile for demonstration

# List of object files needed to build executable
OBJS=main.o func1.o func2.o

# Name of program executable (and target for make command line)
TGT=myMain

# Compliler to use - can be overridden on command line 'make CC=gcc myMain'
CC = gcc
CCOPTS = -g 

# Backtick example
DATE = ` date `

# Main build - MACRO defines program name and target name
$(TGT):  $(OBJS)
	$(CC) $(CCOPTS) -o $(TGT) $(OBJS)


# Individual .o file generation
main.o: defs.h main.c
	$(CC) $(CCOPTS) -c main.c
func1.o: defs.h func1.c
	$(CC) $(CCOPTS) -c func1.c
func2.o: defs.h func2.c
	$(CC) $(CCOPTS) -c func2.c


# Install new binary to useful place
install: $(TGT)
	cp $(TGT) ../


# Remove .o temp files
clean:
	rm -f *.o


# Remove *all* generated files
vclean:
	rm -f *.o $(TGT)


# target: help - Display callable targets.
help:
	@echo "To build $(TGT), run 'make $(TGT)'"
	@echo "To install $(TGT), run 'make install'"
	@echo "To clean temporary files use 'make clean' and 'make vclean'"


# Today's date
today:
	@echo "Today's date is: $(DATE)"
