# -------------------------------------------------------------------- 
# 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
include ../../Makefile.modemlib

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

all: ../../bin/queue

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

uninstall:
	$(RM) $(BINDIR)/queue

test: test_queue test_write

clean:
	$(RM) *.o *.bak test_queue test_write ../../bin/queue

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

INCLUDE = -I.. -I../parser

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

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

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

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

driver:
	cd ../driver ; $(MAKE)

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

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

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

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

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

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

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

fread.o: fread.c 
	$(CC) $(CFLAGS) -c fread.c $(INCLUDE)

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

queue.o: queue.c ../common/common.h ../logfile/logfile.h npipe.h  version.h
	$(CC) $(CFLAGS) -c queue.c $(INCLUDE) -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMSMSDLOGLEVEL=3 -DMSMSDLOGFILE="\"$(MSMSDLOGFILE)\""

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

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

../../bin/queue: queue.o fread.o npipe.o process.o ../logfile/logfile.o ../common/common.o gs_parser gs_api resource lock driver comms ../../Makefile.modemlib
	$(CC) $(CFLAGS) queue.o fread.o npipe.o process.o -o ../../bin/queue ../logfile/logfile.o ../common/common.o ../resource/resource.a ../parser/gs_parser.a ../parser/gs_api/gs_api.a  ../lock/lock.a ../driver/sms_driver.a ../comms/comms.a $(MLIBS) $(XTRALIBS)

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

test_queue: test_queue.o npipe.o process.o ../common/common.h ../logfile/logfile.h npipe.h process.h
	$(CC) $(CFLAGS) test_queue.o npipe.o process.o -o test_queue 
	
test_write: test_write.o ../common/common.h ../logfile/logfile.h npipe.h
	$(CC) $(CFLAGS) test_write.o -o test_write
	
# --------------------------------------------------------------------

../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

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

