#####
# Paths
#####

# $Id: makefile.nt,v 1.5 1999/10/19 06:11:14 fgouget Exp $

# This path should point to where the icmp libraries are.
ICMP_INCLUDE=../icmp_dev-0.1.1
ICMP_LIB=../icmp_dev-0.1.1/i386

# This is where you want the compiler to put the binaries
# (including bing.exe).
BIN=bin

#####
# Macro definitions
#####

# General options
APPVER = 4.0
TARGETOS = BOTH
TARGETLANG = LANG_FRENCH
CPU=i386
!ifndef DEBUG
NODEBUG=1
!endif

!include <win32.mak>

# compilation
!ifdef BROWSER
cbrowser=-FR$(*D)/ 
!endif

!ifdef DEBUG
cdebug=-Od -Zi -Fd$(*D)/ -D_DEBUG -D_CRTDBG_MAP_ALLOC
!endif

!ifdef DLL
bing_cvars=$(cvarsdll)
!else
bing_cvars=$(cvars)
!endif

bing_cvars=-nologo $(bing_cvars) $(cdebug) $(cbrowser) -I$(ICMP_INCLUDE) -I. -Iwin32 -Iinclude -c -Fo$(*D)/ 

# linking
!ifdef DEBUG
ldebug=-debug
!endif

bing_lflags=-nologo -nodefaultlib $(ldebug) -out:$@

!ifdef DLL
bing_libs=$(conlibsdll)
!else
bing_libs=$(conlibs)
!endif

bing_libs=$(bing_libs) wsock32.lib $(ICMP_LIB)/icmp.lib 

######
# What to do
######

L_OBJS= \
	$(BIN)/bing.obj \
	$(BIN)/bing_misc.obj \
	$(BIN)/bing_probes.obj \
	$(BIN)/bing_stats.obj \
	$(BIN)/lin_reg.obj \
	$(BIN)/icmp_win32.obj \
	$(BIN)/getopt.obj \

L_EXE= \
	$(BIN)/bing.exe \

L_BSC= \
!ifdef BROWSER
	$(BIN)/bing.bsc \
!endif

all:	bin_dir $(L_EXE) $(L_BSC)

clean:
	if exist $(BIN)\*.obj del $(BIN)\*.obj
	if exist $(BIN)\*.exe del $(BIN)\*.exe
	if exist $(BIN)\*.ilk del $(BIN)\*.ilk
	if exist $(BIN)\*.pdb del $(BIN)\*.pdb
	if exist $(BIN)\*.sbr del $(BIN)\*.sbr
	if exist $(BIN)\*.bsc del $(BIN)\*.bsc
	if exist $(BIN)\nul rmdir $(BIN)

bin_dir:
	-if not exist $(BIN)\nul mkdir $(BIN)

######
# Commands
######

# compilation
$(L_OBJS):
	$(CC) $(bing_cvars) -o $*.obj $**

# link
$(L_EXE):
	$(link) $(bing_lflags) msvcrtd.lib $(bing_libs) $**

# browser
!ifdef BROWSER
$(L_BSC):
	bscmake -nologo -o $@ $**
!endif

#####
# Dependencies
#####

$(BIN)/bing.obj: bing.c
$(BIN)/bing_misc.obj: bing_misc.c
$(BIN)/bing_probes.obj: bing_probes.c
$(BIN)/bing_stats.obj: bing_stats.c
$(BIN)/lin_reg.obj: lin_reg.c
$(BIN)/icmp_win32.obj: win32/icmp_win32.c
$(BIN)/getopt.obj: win32/getopt.c

$(BIN)/bing.exe: \
	$(BIN)/bing.obj \
	$(BIN)/bing_misc.obj \
	$(BIN)/bing_probes.obj \
	$(BIN)/bing_stats.obj \
	$(BIN)/lin_reg.obj \
	$(BIN)/icmp_win32.obj \
	$(BIN)/getopt.obj \

!ifdef BROWSER
$(BIN)/bing.bsc: \
	$(BIN)/bing.sbr \
	$(BIN)/bing_misc.sbr \
	$(BIN)/bing_probes.sbr \
	$(BIN)/bing_stats.sbr \
	$(BIN)/lin_reg.sbr \
	$(BIN)/icmp_win32.sbr \
	$(BIN)/getopt.sbr \
!endif
