#
#   Makefile - build and install the comgt package
#   Copyright (C) 2005  Martin Gregorie
#   Copyright (C) 2006  Paul Hardwick
#
#   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
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#    martin@gregorie.org, paul@peck.org.uk
#
#    $Id: Makefile,v 1.2 2009-02-09 06:58:39 michael Exp $
#
#

CPROG	= comgt
CFLAGS  := -c $(CFLAGS)
LDFLAGS := $(LDFLAGS)

all: $(CPROG)

romfs:
	$(ROMFSINST) /bin/$(CPROG)
	$(ROMFSINST) scripts/devices /etc_ro/ppp/3g
	$(ROMFSINST) scripts/peers /etc_ro/ppp/peers
	$(ROMFSINST) scripts/command /etc_ro/ppp/3g
	$(ROMFSINST) scripts/dump /etc_ro/ppp/3g
	$(ROMFSINST) scripts/operator /etc_ro/ppp/3g
	$(ROMFSINST) scripts/sigmon /sbin
	$(ROMFSINST) scripts/read_sms /sbin
	$(ROMFSINST) scripts/send_sms /sbin
	rm -f ./../../romfs/dev/ttyUSB0
	rm -f ./../../romfs/dev/ttyUSB1
	rm -f ./../../romfs/dev/ttyUSB2
	rm -f ./../../romfs/dev/ttyUSB3
	rm -f ./../../romfs/dev/ttyUSB4
	mknod ./../../romfs/dev/ttyUSB0 c 188 0
	mknod ./../../romfs/dev/ttyUSB1 c 188 1
	mknod ./../../romfs/dev/ttyUSB2 c 188 2
	mknod ./../../romfs/dev/ttyUSB3 c 188 3
	mknod ./../../romfs/dev/ttyUSB4 c 188 4
	chmod 660 ./../../romfs/dev/ttyUSB0
	chmod 660 ./../../romfs/dev/ttyUSB1
	chmod 660 ./../../romfs/dev/ttyUSB2
	chmod 660 ./../../romfs/dev/ttyUSB3
	chmod 660 ./../../romfs/dev/ttyUSB4
	rm -f ./../../romfs/dev/ttyACM0
	rm -f ./../../romfs/dev/ttyACM1
	mknod ./../../romfs/dev/ttyACM0 c 166 0
	mknod ./../../romfs/dev/ttyACM1 c 166 1
	chmod 660 ./../../romfs/dev/ttyACM0
	chmod 660 ./../../romfs/dev/ttyACM1
ifeq ("$(CONFIG_USER_CHT_FW)", "y")
	rm $(ROMFSDIR)/etc_ro/ppp/peers/e220
	mv $(ROMFSDIR)/etc_ro/ppp/peers/e220_nodefault $(ROMFSDIR)/etc_ro/ppp/peers/e220
else
	rm $(ROMFSDIR)/etc_ro/ppp/peers/e220_nodefault
endif	

clean:
	-rm *.o 
	-rm $(CPROG) 
	-rm *~
	-rm $(SCRIPTSRC)*~


comgt: comgt.o
	$(CC) comgt.o $(LDFLAGS) -o comgt

comgt.o: comgt.c comgt.h
	$(CC) comgt.c $(CFLAGS) 

