# -------------------------------------------------------------------- 
# 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: Makefile,v 5.1 1998/02/01 07:10:39 root Exp root $
# -------------------------------------------------------------------- 

include ../../Makefile.config
include ../../Makefile.modemlib

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

all: ../../bin/sms_client ../../bin/sms_address 

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

uninstall:
	$(RM) $(BINDIR)/sms_client
	$(RM) $(BINDIR)/sms_address
	
clean:
	$(RM) *.o *.bak core 
	$(RM) ../../bin/sms_client 
	$(RM) ../../bin/sms_address 
	$(RM) version.h

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

INCLUDE=-I.. -I../driver

# --------------------------------------------------------------------
	
driver_lib:
	cd ../driver ; $(MAKE)

parser_lib:
	cd ../parser ; $(MAKE)

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

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

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

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

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

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

sms_client.o: sms_client.c expand.h sms_list.h ../driver/driver.h ../logfile/logfile.h ../error.h ../../Makefile.config version.h
	$(CC) $(CFLAGS) -c sms_client.c -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMLOGLEVEL=3 -DMLOGFILE="\"$(MLOGFILE)\"" $(INCLUDE)

sms_address.o: sms_address.c expand.h sms_list.h ../../Makefile.config version.h
	$(CC) $(CFLAGS) -c sms_address.c -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMLOGLEVEL=3 -DMLOGFILE="\"$(MLOGFILE)\"" $(INCLUDE)

sms_list.o: sms_list.c sms_list.h ../error.h ../logfile/logfile.h
	$(CC) $(CFLAGS) -c sms_list.c $(INCLUDE)

expand.o: ../logfile/logfile.h expand.h expand.c ../error.h sms_list.h ../driver/driver.h ../../Makefile.config
	$(CC) $(CFLAGS) -c expand.c -DMLOCALSMSRC="\"$(MLOCALSMSRC)\"" -DMGLOBALSMSRC="\"$(MGLOBALSMSRC)\"" $(INCLUDE)

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

../../bin/sms_client: sms_client.o expand.o ../logfile/logfile.o sms_list.o driver_lib lock ../common/common.o parser_lib comms resource ../../Makefile.modemlib
	$(CC) $(CFLAGS) -o ../../bin/sms_client sms_client.o expand.o $(MOBJS) ../logfile/logfile.o sms_list.o ../driver/sms_driver.a $(MLIBS) ../common/common.o $(XTRALIBS) ../parser/gs_parser.a ../comms/comms.a ../lock/lock.a ../resource/resource.a $(MLIBS)

../../bin/sms_address: sms_address.o expand.o sms_list.o driver_lib ../common/common.o parser_lib lock comms ../../Makefile.modemlib
	$(CC) $(CFLAGS) -o ../../bin/sms_address sms_address.o expand.o sms_list.o ../logfile/logfile.o $(MOBJS) ../driver/sms_driver.a $(MLIBS) ../common/common.o $(XTRALIBS) ../parser/gs_parser.a ../comms/comms.a ../lock/lock.a ../resource/resource.a $(MLIBS)

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

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

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

