#=======================================================================
#  Makefile for V Icon Editor 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++

#	default arch is intel
ARCH	= intel
#ARCH	= sun4
#ARCH	= mips

Arch = $(ARCH)

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


# Platform dependencies

HOMEV	=	..

#-----------------------------------------------------------------
# Linux
ifeq ($(Arch),intel)
X11INC	=	/usr/X11/include
X11LIB	=	/usr/X11R6/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11 -lm
#LIBS	=	-lVm /usr/lib/libXm.a -lXmu -lXt -lXext -lX11 -lm
endif

#-----------------------------------------------------------------
# Linux elf shared lib
ifeq ($(Arch),linuxelf)
X11INC	=	/usr/X11/include
X11LIB	=	/usr/X11R6/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11 -lm -lstdc++
endif

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

#-----------------------------------------------------------------
# sgi - unm
ifeq ($(Arch),sgi)
X11INC	=	/usr/include
X11LIB	=	/usr/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11 -lm
TARCMD	=	cvf v.tar
endif

#-----------------------------------------------------------------
# mips - unm
ifeq ($(Arch),mips)
X11INC	=	/usr/local/X11/include
X11LIB	=	/usr/local/X11/lib
LIBS	=	-lV -lXaw -lXmu -lXt -lXext -lX11 -lm
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
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
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
endif

VPATH	=	../include

# Architecture dependent

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

oDir	=	../obj/$(Arch)

LibDir	=	../lib/$(Arch)

Bin	=	../bin/$(Arch)


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

# Flags for includes and libraries

CFLAGS	=	-O -I$(X11INC) -I$(HOMEV)/includex
#CFLAGS	=	-g -I$(X11INC) -I$(HOMEV)/includex

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

EXOBJS	=	$(oDir)/viedapp.o \
		$(oDir)/viedcnv.o \
		$(oDir)/viedcmdw.o \
		$(oDir)/coldlg.o \
		$(oDir)/brshdlg.o \
		$(oDir)/imageio.o


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

objs:	$(EXOBJS)

clean:
	rm -f $(EXOBJS)
	rm $(Bin)/vdraw
	rm *.bak

tar:
	-rm *.bak
	tar cvfz iconed.tgz *.cpp *.h makefile *.vbm

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

$(oDir)/viedcnv.o:	viedcnv.cpp v_defs.h viedcnv.h viedcmdw.h \
	vpsdc.h vprinter.h brshdlg.h coldlg.h paldecla.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/viedcmdw.o:	viedcmdw.cpp v_defs.h viedcmdw.h viedcnv.h \
	coldlg.h brshdlg.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/viedapp.o:	viedapp.cpp v_defs.h viedapp.h viedcmdw.h viedcnv.h \
	coldlg.h brshdlg.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/coldlg.o:	coldlg.cpp v_defs.h coldlg.h viedcmdw.h viedcnv.h palclrs.h
	$(CC) -c $(CFLAGS) -o $@ $<                     

$(oDir)/brshdlg.o:	brshdlg.cpp v_defs.h brshdlg.h viedcmdw.h viedcnv.h
	$(CC) -c $(CFLAGS) -o $@ $<                     
