#------------------------------------------------------------------------------#
# This makefile was generated by 'cbp2make' tool rev.147                       #
#------------------------------------------------------------------------------#
# Optimized manually!
# cbp2make.exe -in dnsforwarder.cbp -out mk -windows -targets Release,Debug --flat-objects --wrap-objects --with-deps

# Builtin variables' default value: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
ifeq "$(CC)" "cc"
	CC = gcc.exe
endif
ifeq "$(LD)" "ld"
	LD = g++.exe
endif

WINDRES ?= windres.exe

INC = 
CFLAGS ?= -Wall -DWIN32_LEAN_AND_MEAN
RESINC = 
LIBDIR = 
LIB = -lws2_32 -lwininet -lshlwapi -luser32
LDFLAGS = -static-libgcc

INC_DEBUG = $(INC)
CFLAGS_DEBUG = $(CFLAGS) -g
RESINC_DEBUG = $(RESINC)
RCFLAGS_DEBUG = $(RCFLAGS)
LIBDIR_DEBUG = $(LIBDIR)
LIB_DEBUG = $(LIB)
LDFLAGS_DEBUG = $(LDFLAGS)
OBJDIR_DEBUG = .\\obj\\Debug$(ARCH_EXT)
BINDIR_DEBUG = .\\bin\\Debug$(ARCH_EXT)
OUT_DEBUG = $(BINDIR_DEBUG)\\dnsforwarder.exe

INC_RELEASE = $(INC)
CFLAGS_RELEASE = $(CFLAGS) -O3 -Os
RESINC_RELEASE = $(RESINC)
RCFLAGS_RELEASE = $(RCFLAGS)
LIBDIR_RELEASE = $(LIBDIR)
LIB_RELEASE = $(LIB)
LDFLAGS_RELEASE = $(LDFLAGS) -s
OBJDIR_RELEASE = .\\obj\\Release$(ARCH_EXT)
BINDIR_RELEASE = .\\bin\\Release$(ARCH_EXT)
OUT_RELEASE = $(BINDIR_RELEASE)\\dnsforwarder.exe

SOURCES = \
	addresslist.c \
	addresslist.h \
	array.c \
	array.h \
	bst.c \
	bst.h \
	cacheht.c \
	cacheht.h \
	cachettlcrtl.c \
	cachettlcrtl.h \
	common.h \
	dnscache.c \
	dnscache.h \
	dnsgenerator.c \
	dnsgenerator.h \
	dnsparser.c \
	dnsparser.h \
	dnsrelated.c \
	dnsrelated.h \
	domainstatistic.c \
	domainstatistic.h \
	downloader.c \
	downloader.h \
	dynamichosts.c \
	dynamichosts.h \
	filter.c \
	filter.h \
	goodiplist.c \
	goodiplist.h \
	hosts.c \
	hosts.h \
	hostscontainer.c \
	hostscontainer.h \
	hostsutils.c \
	hostsutils.h \
	iheader.c \
	iheader.h \
	ipchunk.c \
	ipchunk.h \
	ipmisc.c \
	ipmisc.h \
	linkedqueue.c \
	linkedqueue.h \
	logs.c \
	logs.h \
	main.c \
	mcontext.c \
	mcontext.h \
	mmgr.c \
	mmgr.h \
	oo.h \
	pipes.c \
	pipes.h \
	ptimer.c \
	ptimer.h \
	readconfig.c \
	readconfig.h \
	readline.c \
	readline.h \
	rwlock.h \
	simpleht.c \
	simpleht.h \
	socketpool.c \
	socketpool.h \
	socketpuller.c \
	socketpuller.h \
	stablebuffer.c \
	stablebuffer.h \
	statichosts.c \
	statichosts.h \
	stringchunk.c \
	stringchunk.h \
	stringlist.c \
	stringlist.h \
	tcpfrontend.c \
	tcpfrontend.h \
	tcpm.c \
	tcpm.h \
	timedtask.c \
	timedtask.h \
	udpfrontend.c \
	udpfrontend.h \
	udpm.c \
	udpm.h \
	utils.c \
	utils.h \
	winmsgque.c \
	winmsgque.h

OBJECTS = $(patsubst %.c,%.o,$(filter %.c,$(SOURCES)))

OBJ_DEBUG = $(patsubst %.o,$(OBJDIR_DEBUG)\\%.o,$(OBJECTS))

OBJ_RELEASE = $(patsubst %.o,$(OBJDIR_RELEASE)\\%.o,$(OBJECTS))

### MSYS convert `/c` to `C:/`
ifneq "$(MSYSTEM)" ""
	CMD_OPT = //C
else
	CMD_OPT = /C
endif

###
.PHONY: before_debug clean_debug before_release clean_release

###
release: before_release $(OUT_RELEASE)

before_release: 
	cmd.exe $(CMD_OPT) "if not exist $(BINDIR_RELEASE) md $(BINDIR_RELEASE)"
	cmd.exe $(CMD_OPT) "if not exist $(OBJDIR_RELEASE) md $(OBJDIR_RELEASE)"

$(OUT_RELEASE): $(OBJ_RELEASE)
	$(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE)

$(OBJDIR_RELEASE)\\%.o: ..\\%.c
	$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@

clean_release: 
	cmd.exe $(CMD_OPT) "if exist $(OUT_RELEASE) del /f $(OUT_RELEASE)"
	cmd.exe $(CMD_OPT) "if exist $(OBJDIR_RELEASE) rd /s /q $(OBJDIR_RELEASE)"

###
debug: before_debug $(OUT_DEBUG)

before_debug: 
	cmd.exe $(CMD_OPT) "if not exist $(BINDIR_DEBUG) md $(BINDIR_DEBUG)"
	cmd.exe $(CMD_OPT) "if not exist $(OBJDIR_DEBUG) md $(OBJDIR_DEBUG)"

$(OUT_DEBUG): $(OBJ_DEBUG)
	$(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG)

$(OBJDIR_DEBUG)\\%.o: ..\\%.c
	$(CC) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -o $@

clean_debug: 
	cmd.exe $(CMD_OPT) "if exist $(OUT_DEBUG) del /f $(OUT_DEBUG)"
	cmd.exe $(CMD_OPT) "if exist $(OBJDIR_DEBUG) rd /s /q $(OBJDIR_DEBUG)"

###
all: debug release

clean: clean_debug clean_release

