#
# used by all makefiles
#
CC       ?= gcc
CXX      ?= g++
AR       ?= ar

# path to gdm2s3m sources
GDM2S3M   = contrib/gdm2s3m/src
MODPLUG   = contrib/libmodplug/src

# default target name
TARGET   ?= mzx281g
VERSION  ?= 2.81g

# base includes for SDL, override as necessary
INCLUDES ?= `sdl-config --cflags`
LIBS     ?= `sdl-config --libs`

ifneq ("${DATE}", "0")
VERSTRING = ${VERSION}\ \(`date +%Y%m%d`\)
else
VERSTRING = ${VERSION}
endif

ifdef DEBUG
CFLAGS    = -g -Wall -DDEBUG
CXXFLAGS  = -g -Wall -DDEBUG
o         = dbg.o
else
CFLAGS   += -O2 -Wall
CXXFLAGS += -O2 -Wall
o         = o
endif

.SUFFIXES: .cpp .c .rc

ifdef ICON
%.o %.dbg.o: %.rc
	${WINDRES} -i $< -o $@
endif

%.o %.dbg.o: %.cpp
	${CXX} ${CXXFLAGS} ${INCLUDES} -c $< -o $@

%.o %.dbg.o: %.c
	${CC} ${CFLAGS} ${INCLUDES} -c $< -o $@
