###############################################################################
#                                                                             #
#                           ViPEC project makefile                            #
#              ViPEC is distributed under the GNU Public license              #
#                    (C) 1991-2001 J. Rossouw & E. Jansen                     #
#                EMAIL: vipec-developers@lists.sourceforge.net                #
#                                                                             #
###############################################################################

SUBDIRS = src
SOURCEPATH = `pwd`
VERSION = 3.2.0
INSTALLDIR = $(PREFIX)/opt/vipec
ICONFILE = vipec.gif

export VERSION

ALL: $(SUBDIRS) 

$(SUBDIRS):  FORCE
	@(echo Entering $@ ...; cd $@; $(MAKE))

all:
	@($(MAKE) release; $(MAKE))

clean:
	rm -f core filelist.txt codelist.ps `find . -name *~` spec/vipec.spec
	rm -f src/Makefile.tmp
	rm -f vipec
	(for i in $(SUBDIRS); do cd $$i; $(MAKE) clean; cd ..; done)

debug:
	@(echo Creating makefile for debug version ...; \
	  cd src; \
	  qmake "CONFIG+=debug" -o Makefile.tmp vipec.pro; \
	  cat Makefile.tmp | sed 's/no-exceptions/exceptions/g' > Makefile )

release:
	@(echo Creating makefile for release version ...; \
	  cd src; \
	  qmake -o Makefile.tmp vipec.pro; \
	  cat Makefile.tmp | sed 's/no-exceptions/exceptions/g' > Makefile )

ts:
	@(echo Updating message files ...; cd src; lupdate vipec.pro )

qm:
	@(echo Creating QM message files ...; cd src; lrelease vipec.pro )

filelist:
	find . -name *.h > filelist.txt
	find . -name *.cpp >> filelist.txt

codelist:
	$(MAKE) filelist
	a2ps -r --columns=1 -l120 -o codelist.ps  `cat filelist.txt`

install:
	strip $(SOURCEPATH)/vipec
	mkdir -p $(INSTALLDIR)
	mkdir -p $(INSTALLDIR)/help
	mkdir -p $(INSTALLDIR)/ckt
	mkdir -p $(INSTALLDIR)/messages
	cp $(SOURCEPATH)/vipec $(INSTALLDIR)
	cp -R $(SOURCEPATH)/help/* $(INSTALLDIR)/help
	cp -R $(SOURCEPATH)/ckt/* $(INSTALLDIR)/ckt
	cp -R $(SOURCEPATH)/messages/* $(INSTALLDIR)/messages
	cp $(SOURCEPATH)/CHANGES $(INSTALLDIR)
	cp $(SOURCEPATH)/COPYRIGHT $(INSTALLDIR)
	cp $(SOURCEPATH)/INTERNATIONALIZATION $(INSTALLDIR)
	cp $(SOURCEPATH)/README $(INSTALLDIR)
	cp $(SOURCEPATH)/COPYING $(INSTALLDIR)
	cp $(SOURCEPATH)/LICENSE $(INSTALLDIR)

rpm:
	$(MAKE) tar
	cp ../ViPEC-$(VERSION).tar.gz /usr/src/redhat/SOURCES/ViPEC-$(VERSION).tar.gz
	cp src/images/$(ICONFILE) /usr/src/redhat/SOURCES/
	cpp -P -DVERSION=$(VERSION) -DICONFILE=$(ICONFILE) spec/vipec.spec.source spec/vipec.spec
	rpmbuild -bs $(SOURCEPATH)/spec/vipec.spec

tar:
	$(MAKE) clean
	(cd ..; ln -s Vipec ViPEC-$(VERSION); tar cvzf ViPEC-$(VERSION).tar.gz ViPEC-$(VERSION)/*; rm -f ViPEC-$(VERSION); cd Vipec; )

FORCE:
