#----------------------------------------------------------------------------
#Copyright (C) 2003  Sam Vaughan <yamaneko@centurytel.net>
# 
#  File: Makefile
#  This file is part of Vrcon
# 
#  Vrcon
#  VaughanTech's  remote control for Cstrike and other Half-Life MODS
#  (rcon from a terminal)
#  
#  Written by Sam "Jack Bauer" Vaughan
# 
#
#  Licensed under the GNU General Public License
# 
#  Vrcon 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
#  any later version.
# 
#  Vrcon 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
#  along with Vrcon; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# 
#----------------------------------------------------------------------------

# Set the install prefix for the executables here
INSTALL_PREFIX	 =/usr/local
WIN32	=./win32/vrcon
INSTALL          = /usr/bin/install

#CFLAGS	= -Wall -g -O2
CFLAGS		= -O2
CC 		= gcc
COMMON_OBJS	= procldgram.o strlcpy.o strlcat.o split.o load_config.o \
		  moh.o bf1942.o ut2k4.o quake3.o cod.o source.o
VRCON_OBJS	= wmain.o rcon.o 
ZAURUS_VRCON_OBJS	= zmain.o rcon.o 
VLOG_OBJS	= vlog.o rcon.o
#LIBS		= -lc -lm -lcurses -lsocket
LIBS		= -lcurses
VRCON_EXE	= vrcon
ZVRCON_EXE	= zvrcon
VLOG_EXE	= vlog

.PHONY: install
.PHONY: win32

all:
	@make vrcon
	@make vlog

vrcon: $(VRCON_OBJS) $(COMMON_OBJS)
	$(CC) -o $(VRCON_EXE) $(VRCON_OBJS) $(COMMON_OBJS) $(LIBS)	

vlog: $(VLOG_OBJS) $(COMMON_OBJS)
	$(CC) -o $(VLOG_EXE) $(VLOG_OBJS) $(COMMON_OBJS) $(LIBS)	

zvrcon: $(ZAURUS_VRCON_OBJS) $(COMMON_OBJS)
	$(CC) -o $(ZVRCON_EXE) $(ZAURUS_VRCON_OBJS) $(COMMON_OBJS) $(LIBS)	
install:
	${INSTALL} -d  $(INSTALL_PREFIX)/bin
	${INSTALL} -d  $(INSTALL_PREFIX)/man
	${INSTALL} -d  $(INSTALL_PREFIX)/man/man1
	${INSTALL} -d  $(INSTALL_PREFIX)/share/vrcon
	${INSTALL} -c -s -b $(VLOG_EXE) $(INSTALL_PREFIX)/bin
	${INSTALL} -c -s  -b $(VRCON_EXE) $(INSTALL_PREFIX)/bin
	${INSTALL} -c -b vrcon.1 $(INSTALL_PREFIX)/man/man1
	${INSTALL} -c -b vlog.1 $(INSTALL_PREFIX)/man/man1
	${INSTALL} -c -b vrcon_sample_config $(INSTALL_PREFIX)/share/vrcon

	@echo
	@echo "--------------------------------------------------------"
	@echo "           ** vrcon is now installed **"
	@echo
	@echo "Please be sure to edit your config file, .vrcon"
	@echo "If upgrading, check to see if you need to update it"
	@echo "--------------------------------------------------------"
	@echo
	
win32:
	${INSTALL} -d  $(WIN32)
	${INSTALL} -c -s -b $(VLOG_EXE) $(WIN32)
	${INSTALL} -c -s  -b $(VRCON_EXE) $(WIN32)
	${INSTALL} -c -b win32/rxvtsh $(WIN32)
	${INSTALL} -c -b win32/r_vlog $(WIN32)
	${INSTALL} -c -b win32/cyginstall $(WIN32)
	${INSTALL} -c -b vrcon.1 $(WIN32)
	${INSTALL} -c -b vlog.1 $(WIN32)
	${INSTALL} -c -b vrcon_sample_config $(WIN32)
	cd $(WIN32); tar czvf vrcon_package.tgz vrcon.exe vlog.exe rxvtsh r_vlog vrcon.1 vlog.1 vrcon_sample_config
	cd $(WIN32); rm vrcon.exe vlog.exe rxvtsh r_vlog vrcon.1 vlog.1 vrcon_sample_config
	cd win32; zip -r vrcon_win32.zip vrcon


clean:
	rm -f $(COMMON_OBJS) $(VRCON_OBJS) $(ZVRCON_EXE) $(ZAURUS_VRCON_OBJS) $(VRCON_EXE) $(VLOG_OBJS) $(VLOG_EXE) core 
###########################################################
