# -------------------------------------------------------------------- 
# SMS Client, send messages to mobile phones and pagers		
#									
# Makefile								
#									
#  Copyright (C) 1997,1998,1999 Angelo Masci					
#									
#  This library is free software; you can redistribute it and/or	
#  modify it under the terms of the GNU Library General Public		
#  License as published by the Free Software Foundation; either	
#  version 2 of the License, or (at your option) any later version.	
#									
#  This library 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	
#  Library General Public License for more details.			
#									
#  You should have received a copy of the GNU Library General Public	
#  License along with this library; if not, write to the Free		
#  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.	
#									
#  You can contact the author at this e-mail address:			
#									
#  angelo@styx.demon.co.uk						
#									
# -------------------------------------------------------------------- 
# $Id$
# -------------------------------------------------------------------- 

include ../../Makefile.config

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

all: ../../bin/smsd ../../bin/snppd

install: ../../bin/smsd ../../bin/snppd
	$(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(BINDIR)
	$(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -s ../../bin/smsd $(BINDIR)
	$(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -s ../../bin/snppd $(BINDIR)

uninstall:
	$(RM) $(BINDIR)/smsd
	$(RM) $(BINDIR)/snppd

clean:
	$(RM) *.o *.bak ../../bin/smsd ../../bin/snppd

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

INCLUDE = -I..

gs_parser:
	cd ../parser ; $(MAKE) gs_parser.a

lock:
	cd ../lock ; $(MAKE) lock.a

resource:
	cd ../resource ; $(MAKE) resource.a

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

version.h: ../../.version
	echo "#define MVERSION \"`awk '{ print $1 }' ../../.version`\"" >version.h

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

server.o: server.c ../common/common.h ../logfile/logfile.h server.h
	$(CC) $(CFLAGS) -c server.c $(INCLUDE)

snppd.o: snppd.c ../logfile/logfile.h server.h ../common/common.h ../../Makefile.config version.h
	$(CC) $(CFLAGS) -c snppd.c -DMSNPPDLOGLEVEL=3 -DMSNPPDLOGFILE="\"$(MSNPPDLOGFILE)\"" $(INCLUDE)

smsd.o: smsd.c ../logfile/logfile.h server.h ../common/common.h ../../Makefile.config ../resource/resource.h version.h
	$(CC) $(CFLAGS) -c smsd.c -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMSMSDLOGLEVEL=3 -DMSMSDLOGFILE="\"$(MSMSDLOGFILE)\"" $(INCLUDE) 

../../bin/smsd: smsd.o server.o ../logfile/logfile.o ../common/common.o resource gs_parser lock
	$(CC) $(CFLAGS) -o ../../bin/smsd smsd.o server.o ../logfile/logfile.o ../common/common.o $(XTRALIBS) ../resource/resource.a ../lock/lock.a ../parser/gs_parser.a 

../../bin/snppd: snppd.o server.o ../logfile/logfile.o ../common/common.o lock
	$(CC) $(CFLAGS) -o ../../bin/snppd snppd.o server.o ../logfile/logfile.o ../common/common.o ../lock/lock.a $(XTRALIBS)

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

../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h
	cd ../logfile ; $(MAKE) logfile.o

../common/common.o: ../common/common.c ../common/common.h
	cd ../common ; $(MAKE) common.o

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


