#=======================================================================
#  Makefile for V Shell App Generator program
#  Copyright (C) 1995  Bruce E. Wampler
#
#  This program is part of the V C++ GUI Framework example programs.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  (see COPYING) along with this program; if not, write to the Free
#  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=======================================================================

CC	=	g++

# These are the platforms that V has been extensively tested with.
# If you have one of these platforms, you can comment out the others
# and make yours the default platform. You can also use "ARCH=x"
# on the make command line. There is also a section below called
# "Platform notes" that contains various feedback I've gotten about
# ports to other platforms. These notes may help you on your platform.

#       default arch is intel (Linux, really)
ARCH	= intel
#ARCH	= sun4
#ARCH	= mips
#ARCH	= sgi

# User contributed definitions:
#ARCH	= hpux


Arch = $(ARCH)

ifeq ($(Arch),i586)
Arch = intel
endif
ifeq ($(Arch),i486)
Arch = intel
endif

# Platform notes
#
# I've received the following feedback from various V users. Because
# of machine access limitations, I haven't been able to test all these
# myself, but the information is still likely to be helpful.
# If you have any additions to this section, please send me e-mail, and
# I will add a note to this file. Thanks.
#
# All platforms --
#
#   HOMEV: change the defintion of HOMEV to correspond to wherever
#      you are keeping V. Normally, .. works.

HOMEV	=	..

#
#   The locations of the various libraries and include
#   files it the greatest variable from platform to platform.
#   Follow the pattern estabalished here to define the
#   dependencies for your platform. Eventually, I'd like
#   have to learn imake, and I'd rather work on an OS/2 port...
#
#   Not all platforms need ranlib (sgi, solaris). For those
#   platforms, define RANLIB = true to avoid make error.
#
#
# Linux --
#   some Linux setups also need -I/usr/lib/g++-include
#
# Solaris --
#
#   Define RANLIB = true
#   Add socket library (known for Solaris 2.4):
#   LIBS  =  -lV -lXaw -lXmu -lXt -lXext -lX11 -lsocket
#
# UnixWare 2.02 (i386/sysvR4)
#   LIBS  =   -lXaw -lXext -lXmu -lXt -lX11 -lm -lsocket -lnsl -lgen 

# Platform specific definitions

#---------------------------------------------------------------------
# Linux
ifeq ($(Arch),intel)
X11INC	=	/usr/X11/include
X11LIB	=	/usr/X11R6/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11
TARZ	=	z
RANLIB	=	ranlib
VGPATH	=	LINUX
endif

#---------------------------------------------------------------------
# Linuxelf
ifeq ($(Arch),linuxelf)
X11INC	=	/usr/X11/include
X11LIB	=	/usr/X11R6/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11 -lstdc++
TARZ	=	z
RANLIB	=	ranlib
VGPATH	=	LINUX
endif

#---------------------------------------------------------------------
# Sun4 - unm
ifeq ($(Arch),sun4)
X11INC	=	/usr/local/X11/include
X11LIB	=	/usr/local/X11/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11
TARZ	=
RANLIB	=	ranlib
VGPATH	=	UNIX
endif

#---------------------------------------------------------------------
# mips - unm
ifeq ($(Arch),mips)
X11INC	=	/usr/local/X11/include
X11LIB	=	/usr/local/X11/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11
TARZ	=
RANLIB	=	ranlib
VGPATH	=	UNIX
endif

#---------------------------------------------------------------------
# sgi - unm
ifeq ($(Arch),sgi)
X11INC	=	/usr/include
X11LIB	=	/usr/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11
TARZ	=
RANLIB	=	true
VGPATH	=	UNIX
endif

#---------------------------------------------------------------------
# for hpux9.05 with gcc-2.7.2 Contributed by: Neal Becker <Neal.Becker@comsat.com>
#                             corrected by Jan Peter de Ruiter <janpeter@mpi.nl>
ifeq ($(Arch),hpux)
X11INC	=	/usr/include/X11R5
X11LIB	=	/usr/lib/X11R5
#the order of specification matters here!
LIBS    =       -lV -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11
# old version - works on some systems
#LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11
TARZ	=
RANLIB	=       true
VGPATH	=	UNIX
endif

#-----------------------------------------------------------------
# solaris - unm
ifeq ($(Arch),solaris)
X11INC	=	/usr/local/X11/include
X11LIB	=	/usr/local/X11/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11 -lnsl -lsocket
TARZ	=
RANLIB	=	true
VGPATH	=	UNIX
endif

#-----------------------------------------------------------------

# FreeBSD with gcc
ifeq ($(Arch),bsd)
HOMEV   =       /home/wes/src
X11INC  =       /usr/X11R6/include
X11LIB  =       /usr/X11R6/lib
LIBS    =       -lV -lXaw -lXmu -lXt -lXext -lX11
TARZ    =
RANLIB  =       ranlib
VGPATH	=	UNIX
endif

# Architecture dependent

VLibDir	=	$(HOMEV)/lib/$(Arch)

oDir	=	../obj/$(Arch)

LibDir	=	../lib/$(Arch)

Bin	=	../bin/$(Arch)

# Location of sources and inputs


# Flags for includes and libraries

CFLAGS	=	-O -I$(X11INC) -I$(HOMEV)/includex -D$(VGPATH)

#Debug version
#CFLAGS	=	-g -I$(X11INC) -I$(HOMEV)/includex -D$(VGPATH)

# Use this define for NO 3D on Athena Widgets
# Change the Lib3dObjs definition later, too.

#CFLAGS	=	-O -I$(X11INC) -I$(HOMEV)/includex -DNO_V_3D -D$(VGPATH)

LFLAGS	=	-L$(X11LIB) -L$(VLibDir)

VPATH	=	$(HOMEV)/includex/v

#--------------------------------------------------------------
# Architecture dependent

# Flags for includes and libraries

EXOBJS	=	$(oDir)/vgapp.o \
		$(oDir)/vgcmdw.o \
		$(oDir)/vgcode.o \
		$(oDir)/vgmdlg.o \
		$(oDir)/vgdlmdlg.o \
		$(oDir)/vgtnmdlg.o \
		$(oDir)/vgcnv.o

#		$(oDir)/mydlg.o \
#		$(oDir)/mymdlg.o \

all:	$(Bin)/vgen


$(Bin)/vgen:	$(EXOBJS)
	$(CC) -o $@ $(LFLAGS) $(EXOBJS) $(LIBS)

objs:	$(EXOBJS)

$(oDir)/vgcnv.o:	vgcnv.cpp v_defs.h vgcnv.h vgdefs.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/vgcode.o:	vgcode.cpp v_defs.h vgcode.h vgdefs.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

#$(oDir)/mydlg.o:	mydlg.cpp v_defs.h mydlg.h vgdefs.h
#	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/vgmdlg.o:	vgmdlg.cpp v_defs.h vgmdlg.h vgdefs.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/vgdlmdlg.o:	vgdlmdlg.cpp v_defs.h vgdlmdlg.h vgdefs.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/vgtnmdlg.o:	vgtnmdlg.cpp v_defs.h vgtnmdlg.h vgdefs.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/vgcmdw.o:	vgcmdw.cpp v_defs.h vgcmdw.h vgdefs.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/vgapp.o:	vgapp.cpp v_defs.h vgapp.h vgcmdw.h vgdefs.h
	$(CC) -c $(CFLAGS) -o $@ $<
