# Debug logging example makefile
#
# See http://hdrlab.org.nz/debug-logging/ for more
#
# written by Hans de Ruiter
#
# License:
# This is provided as-is and can be used and distributed by anyone
# without restrictions.

TARGET = DebugLoggingTest

CC     = gcc
CP	   = copy
RM     = delete
STRIP  = strip

OPTIMIZE = -O3
DEBUG =

# ----- UNCOMMENT DIFFERENT CFLAG LINES TO CHANGE THE LOGGING BEHAVIOUR -----
# CFLAGS for logging all debug messages
CFLAGS = -DDEBUG -DTARGET="$(TARGET)" -mcrt=newlib $(OPTIMIZE) -Wall -gstabs

# CFLAGS for static debug level
#CFLAGS = -DDEBUG -DDEBUG_LOGLEVEL=DBG_WARNING -DTARGET="$(TARGET)" -mcrt=newlib $(OPTIMIZE) -Wall -gstabs

# CFLAGS for user settable logging level
#CFLAGS = -DVARLEVEL_DEBUG -DTARGET="$(TARGET)" -mcrt=newlib $(OPTIMIZE) -Wall -gstabs

# The source files
SRCS = DebugLoggingTest.c Debug.c

# Flags passed to gcc during linking
LINK =

# Additional linker libraries
LIBS = 

# -------------------------------------------------------------
# Nothing should need changing below this line

OBJS = $(SRCS:.c=.o)

# Rules for building
all: $(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(CFLAGS) -o $@.debug $(OBJS) $(LIBS) $(LINK)
	$(STRIP) $@.debug -o $@

.PHONY: clean
clean:
	$(RM) $(TARGET) $(TARGET).debug $(OBJS)
