#
# $Id: //devel/tools/main/ygpm/makefile#3 $
#
# Written by :  Stephen J. Friedl
#               Software Consultant
#               Tustin, California USA
#               http://www.unixwiz.net
#               2002/05/21
#
#       NOTE: This code is in the public domain
#
#	This is the makefile for the YGPM program. Though it's mainly
#	targetted to the Windows platform, the code builds just fine on
#	UNIX and Linux platforms as well.
#
#	We do all our development at the command line, even on NT, and
#	this makefile requires GNU Make on all platforms. The microsoft
#	"NMAKE" is really crappy, and it's not portable besides.
#
#	Note that some of the stuff in the makefile here is *only* for
#	Steve Friedl's use - sorry if it gets in the way.
#

.PHONY : clean web lint bundle

# ------------------------------------------------------------------------
# OS DETERMINATION
#
# We need to know if this is an NT or a *ix build: we've found that
# "PROCESSOR_REVISION" is an NT thing (and 2000 as well).
#

ifdef PROCESSOR_REVISION
 OS=NT
 O=obj
else
 OS=unix
 O=o
endif

OBJS   = ygpm.$O imuser.$O utils.$O selectloop.$O notify.$O
CFLAGS =

CLEAN = 

SOURCE = makefile
SOURCE += $(OBJS:.$O=.cpp) winsock.cpp wintray.cpp
SOURCE += ygpmcommon.h
SOURCE += ygpm.h
SOURCE += ygpm.rc
SOURCE += ygpm.ico
SOURCE += local.lnt

# ------------------------------------------------------------------------
# WIN32 DEVELOPMENT
#
ifeq ($(OS),NT)

CFLAGS  =
CFLAGS += /YXygpmcommon.h	# precompiled headers
CFLAGS += /Gz			# use __stdcall
CFLAGS += /W3			# lots of warnings
CFLAGS += /WX			# warnings are really errors
CFLAGS += /MD                   # use the multithreaded MSVCRT.DLL
CFLAGS += /O1			# minimize space
CFLAGS += /GF			# enable readonly string pooling

OBJS   += winsock.$O		# only Win32
# OBJS   += wintray.$O		# only Win32 (not working yet)

LIBS	= wsock32.lib user32.lib

ygpm.exe : $(OBJS) ygpm.res
	$(strip link /nologo /out:$@ $^ $(LIBS))

%.obj : %.cpp
	$(strip cl /c /nologo $(CFLAGS) $*.cpp)

CLEAN += ygpm.exe *.pch ygpm.res

bundle : ygpm-source.zip

ygpm.res : ygpm.rc ygpm.ico
	rc /v ygpm.rc

# just for S. Friedl's developmenthere
web : ygpm.exe ygpm-source.zip
	../putwebtool.p --tool=ygpm --verquery=-V

else

# ------------------------------------------------------------------------
# UNIX DEVELOPMENT
#

CFLAGS += -Wall		# enable lots of warnings
CFLAGS += -W		# enable even more warnings
CFLAGS += --pedantic	# yet more warnings

ygpm : $(OBJS)
	$(CPP) -o $@ $^

bundle : ygpm.tgz

%.o : %.cpp
	$(strip $(CPP) -c $(CFLAGS) $*.cpp)

CLEAN += ygpm

endif

CLEAN += $(OBJS)

clean :
	-$(strip rm -f $(CLEAN))

# ------------------------------------------------------------------------
# SOURCE BUNDLES
#
# We often ship off our source code in a bundle to our web site, and we
# have a way to do it from DOS and from NT. This relies on the command-line
# version of PKZIP (pkzipc)  http://www.pkware.com 
#
# We just can't deal with a GUI for bundling stuff up
#

CLEAN += ygpm-source.zip ygpm-source.tgz

ygpm-source.zip : $(SOURCE)
	$(strip pkzipc -add $@ $^)

ygpm-source.tgz : $(SOURCE)
	$(strip gtar -czvf $@ $^)

# ------------------------------------------------------------------------
# PC-LINT
#
# We use the outstanding PC-Lint tool from Gimpel Software to make our
# code cleaner, and this is where we do that processing. You don't care
# about this if you've not purchased the product.
#
ifdef PCLINTDIR

CLEAN += lint.out

lint : 
	$(strip lint-nt local.lnt $(OBJS:.$O=.cpp) > lint.out)

endif
