
include config 
#MAKE=gmake
export INSTALL=install -c
export CP=cp -f
ifneq ($(CONFIG_PLUGIN),y)
ifneq ($(filter disass.plug,$(LINKIN) $(LINKINDYN)),)
DISASS_USE=y
endif
endif
ifeq ($(CONFIG_PROGMAN),y)
all: $(CONFFILE) bed.menu
else
all: $(CONFFILE)
ifeq ($(BIOSDISK),y)
	$(MAKE) -C biosdisk 
endif
endif
	$(MAKE) -C utils
	$(MAKE) -C src bed
ifeq ($(CONFIG_PLUGIN),y)
	$(MAKE) -C plugins/examples  give
else
ifeq ($(DISASS_USE),y)
	$(MAKE) -C plugins/examples  disass-use
endif
endif


ifeq ($(CONFIG_XBED),y)
	$(MAKE) -C x11 $(XPROGRAM)
endif
	$(MAKE) -C doc

	
LSMFILE=$(PROGRAM)-$(VERSION).lsm
SPECFILE=$(PROGRAM)-$(VERSION).spec

REMOVE=rm 
RMDIR=rmdir 
#SORT=LC_ALL=C sort
SORT=sort
STRIP=strip -s -R .note -R .comment -R .note.ABI-tag
export MKDIR=mkdir -p
SYMLINK=$(LN_S)

install:  $(CONFFILE)  #$(LSMFILE)
ifeq ($(CYGWIN),yes)
	cd c:/
endif
	-$(MKDIR) $(ROOTDIR)$(BINDIR)
	-rm   $(ROOTDIR)/$(BINDIR)/$(EXEPROGRAM)
	-$(MKDIR) $(ROOTDIR)$(BINDIR)
	$(CP) src/$(EXEPROGRAM) $(ROOTDIR)$(BINDIR)
	$(STRIP)  $(ROOTDIR)$(BINDIR)/$(EXEPROGRAM)
	-rm   $(ROOTDIR)$(CONFDIRLINK)
	-mv  $(ROOTDIR)$(CONFDIRLINK) $(CONFDIRLINK).bak
	-$(MKDIR) $(ROOTDIR)$(CONFDIR)
ifneq ($(CYGWIN),yes)
	$(SYMLINK)  $(CONFLASTDIR) $(ROOTDIR)$(CONFDIRLINK)
	-mv  $(ROOTDIR)$(CONFDIR)/$(CONFFILE) $(ROOTDIR)$(CONFDIR)/~$(CONFFILE)
endif
	$(CP) $(CONFFILE) $(ROOTDIR)$(CONFDIR)
	chmod 0644 	$(ROOTDIR)$(CONFDIR)/$(CONFFILE)
	-$(RM) $(ROOTDIR)$(CONFDIR)/.neededbybed 
	$(CP) .neededbybed $(ROOTDIR)$(CONFDIR)
	chmod 0444 	$(ROOTDIR)$(CONFDIR)/.neededbybed
	$(MAKE) -C doc install
	$(MAKE) -C misc install
ifeq ($(CONFIG_XBED),y)
	$(MAKE) -C x11 install
endif
ifeq ($(CONFIG_PLUGIN),y)
	$(MAKE) -C utils install
	$(MAKE) -C plugins install
else
ifeq ($(DISASS_USE),y)
	$(CP) plugins/examples/disass-use*  $(ROOTDIR)$(CONFDIR)
endif
endif
ifneq ($(CYGWIN),yes)
ifeq ($(CONFIG_PLUGIN),y)
	-ln -s $(BINDIR)/$(PROGRAM) $(ROOTDIR)$(CONFDIR)/utils/keyconfig
else
	-ln -s $(BINDIR)/$(PROGRAM) $(ROOTDIR)$(CONFDIR)/keyconfig
endif
else
ifeq ($(BIOSDISK),y)
	$(MAKE) -C biosdisk install
endif
ifeq ($(PDCURSES),)
	echo "$(EXEPROGRAM) -k %1 %2 %3 %4 %5 %6 %7 %8 %9" > $(ROOTDIR)$(CONFDIR)/keyconfig.bat
endif
endif
ifeq ($(PDCURSES),)
	$(MKDIR) $(ROOTDIR)$(CONFDIR)/terminfo
	$(MKDIR) $(ROOTDIR)$(CONFDIR)/terminfo/r
	cp   terminfo/r/rxvt* $(ROOTDIR)$(CONFDIR)/terminfo/r
endif
	cp   $(LSMFILE) LICENSE $(ROOTDIR)$(CONFDIR)
	cp doc/datadir.txt $(ROOTDIR)$(CONFDIR)/README
	cp public.key $(ROOTDIR)$(CONFDIR)
ifeq ($(HAS_FILE),y)
	$(CP) testmarks.bedm bedmagic addmagic.sh $(ROOTDIR)$(CONFDIR)
	@bash ./addmagic.sh
endif
	 mkdir -p $(ROOTDIR)$(KDEMENU)/$(XBEDMENU);
	cp progman/x$(XMENUNAME).kdelnk $(ROOTDIR)$(KDEMENU)/$(XBEDMENU)/$(XMENUNAME).kdelnk;
	mkdir -p $(ROOTDIR)$(KDEMENU)/$(BEDMENU);
	cp progman/c$(MENUNAME).kdelnk $(ROOTDIR)$(KDEMENU)/$(BEDMENU)/$(MENUNAME).kdelnk; 

	mkdir -p $(ROOTDIR)$(GNOMEMENU)/$(XBEDMENU);
	cp progman/x$(XMENUNAME).desktop $(ROOTDIR)$(GNOMEMENU)/$(XBEDMENU)/$(XMENUNAME).desktop ; 
	mkdir -p $(ROOTDIR)$(GNOMEMENU)/$(BEDMENU);
	cp progman/c$(MENUNAME).desktop $(ROOTDIR)$(GNOMEMENU)/$(BEDMENU)/$(MENUNAME).desktop ;
ifeq ($(CONFIG_PROGMAN),y)
#	cp bed.xpm $(ROOTDIR)$(ICONPATH)
#	cp bedsmall.xpm $(ROOTDIR)$(ICONPATH)/mini/bed.xpm
	$(MKDIR) $(ROOTDIR)$(MENUPATH)
	cp bed.menu $(ROOTDIR)$(MENUPATH)/$(PROGRAM)
	chmod 0644 $(ROOTDIR)$(MENUPATH)/$(PROGRAM)

#	@rpm -q $(PROGRAM)|| echo Warning!! Desktop entries not created if no package $(PROGRAM) exists
	update-menus
endif
ifneq ($(CYGWIN),yes)
ifeq ($(ROOTDIR),)
	@cp uninstallhead $(ROOTDIR)$(CONFDIR)/uninstallbed.sh
	@FILES=`for afile in $(ROOTDIR)$(BINDIST); do  test -e $$afile&&echo $$afile ;done`; find  $$FILES ! -type d -print |xargs echo $(REMOVE) ' ' >> $(ROOTDIR)$(CONFDIR)/uninstallbed.sh ;find  $$FILES -type d  -a  -print |$(SORT) -r|xargs echo $(RMDIR) ' ' >> $(ROOTDIR)$(CONFDIR)/uninstallbed.sh
	@echo Uninstall with sh $(ROOTDIR)$(CONFDIR)/uninstallbed.sh
endif
endif
	@echo Binary: '$(ROOTDIR)$(BINDIR)/$(EXEPROGRAM)'
	@echo Support files: $(ROOTDIR)$(CONFDIR)

clean:
	$(MAKE) -C src clean
	$(MAKE) -C utils clean
	$(MAKE) -C plugins clean
	$(MAKE) -C x11 clean
ifeq ($(BIOSDISK),y)
	$(MAKE) -C biosdisk clean
endif


realclean: 
	-rm $(CONFFILE)  config.cache config.bak config.log config.status  bedrc buildonce getsize
	$(MAKE) -C x11 clean
	$(MAKE) -C src realclean
	$(MAKE) -C doc realclean
	$(MAKE) -C utils realclean
	$(MAKE) -C plugins realclean
ifeq ($(BIOSDISK),y)
	$(MAKE) -C biosdisk realclean
endif


ifeq ($(CONFIG_XBED),y)
XBEDMAN=$(MANDIR)/xbed.1.gz $(BINDIR)/xbed
endif
ifeq ($(CONFIG_PROGMAN),y)
MENUBED=$(MENUPATH)/bed
PROGMANEXTRA= $(KDEMENU)/$(XBEDMENU)/$(XMENUNAME).kdelnk $(KDEMENU)/$(BEDMENU)/$(MENUNAME).kdelnk $(GNOMEMENU)/$(XBEDMENU)/$(XMENUNAME).desktop $(GNOMEMENU)/$(BEDMENU)/$(MENUNAME).desktop
endif
BINDIST=   $(CONFDIR) $(CONFDIRLINK) $(BINDIR)/bed $(MANDIR)/bed.1.gz   $(XBEDMAN) $(MENUBED) $(PROGMANEXTRA)
echo:
	echo $(BINDIST)
.PHONY: %.dist %.bindist %.srcdist %.html
HTMLPATH=../html
DISTPATH=$(HTMLPATH)

SRCBASE=$(PROGRAM)-$(VERSION).src
SRCARGFILE=$(SRCBASE).tar.gz
SRCLSMFILE=$(SRCBASE).lsm
SRCASCFILE=$(SRCBASE).asc

SOURCEFILE=$(DISTPATH)/download/$(PROGRAM)-$(VERSION).src.tar.gz 
ifeq ($(CONFIG_STATIC),y)
ELFBASE=$(PROGRAM)-$(VERSION).bin.ELF-static
else
ELFBASE=$(PROGRAM)-$(VERSION).bin.ELF
endif
ELFARGFILE=$(ELFBASE).tar.gz 
ELFLSMFILE=$(ELFBASE).lsm
ELFASCFILE=$(ELFBASE).asc
WIN32ARGFILE=$(PROGRAM)-$(VERSION).win32.zip
FREEBSDARGFILE=$(PROGRAM)-$(VERSION).FreeBSD.tar.gz
STATICARGFILE=$(PROGRAM)-$(VERSION).bin.ELF-static.tar.gz
NONSTATICARGFILE=$(PROGRAM)-$(VERSION).bin.ELF.tar.gz

#LSMFILE=$(PROGRAM)-$(VERSION).lsm
FULLELFFILE=$(DISTPATH)/download/$(ELFARGFILE)
//PGPSIGNPROG=gpg -s -a -b -u 0x94BA03AE 

PGPSIGNPROG= pgps -a -b -u 0x94BA03AE 


mkuninstall:
	@cp uninstallhead $(CONFDIR)/uninstallbed.sh
	@FILES=`for afile in $(BINDIST); do  test -e $$afile&&echo $$afile ;done`; find  $$FILES ! -type d|xargs echo $(REMOVE) ' ' >> $(CONFDIR)/uninstallbed.sh ;find  $$FILES -type d|$(SORT) -r|xargs echo $(RMDIR) ' ' >> $(CONFDIR)/uninstallbed.sh
#	find  $(BINDIST) -type f|xargs 'echo rm -f '
#	find  $(BINDIST) -type d|$(SORT) -r|xargs 'echo rmdir '

%.bindist: $(BINARIES)
	mkdir -p $*/download
	tar -z -cf $*/download/$(ELFARGFILE)   $(BINDIST) 
#	env VERSION=$(VERSION) ELFBASE=$(ELFBASE) SRCBASE=$(SRCBASE) DISTPATH=$*/download sh ./mklsmelf > $*/download/$(ELFLSMFILE)
%.srcdist:
	mkdir -p $*/download
	tar -z -cf  $*/download/$(PROGRAM)-$(VERSION).src.tar.gz  -C ../  $(PROGRAM)-$(VERSION) 
#	env  ELFBASE=$(ELFBASE) SRCBASE=$(SRCBASE) VERSION=$(VERSION) DISTPATH=$*/download bash ./mklsm > $*/download/$(SRCLSMFILE)
%.html: mkbed 
	mkdir -p $*
	env CONFDIRLINK=$(CONFDIRLINK) LSMFILE=$(LSMFILE) ELFBASE=$(ELFBASE) SRCBASE=$(SRCBASE) VERSION=$(VERSION) DISTPATH=$*/download bash ./mkbed > $*/download.html
	env  LSMFILE=$(LSMFILE)  ELFBASE=$(ELFBASE) SRCBASE=$(SRCBASE) VERSION=$(VERSION) DISTPATH=$*/download bash ./mktripod.sh > $*/tripodindex.html
	env   LSMFILE=$(LSMFILE) ELFBASE=$(ELFBASE) SRCBASE=$(SRCBASE) VERSION=$(VERSION) DISTPATH=$*/download bash ./mkmedia.sh > $*/mediaindex.html
	$(MAKE) -C doc bed.html
	cp doc/bed.html $*/bed.1.html
	$(MAKE) -C doc menu.html
	cp doc/menu.html $*/menu.html
%.dist: %.srcdist %.bindist %.sign
	echo $*
%.sign: %.html
	$(PGPSIGNPROG)  $*/download/$(NONSTATICARGFILE)
	$(PGPSIGNPROG)  $*/download/$(SRCARGFILE)
	$(PGPSIGNPROG)  $*/download/$(WIN32ARGFILE)
	$(PGPSIGNPROG)  $*/download/$(FREEBSDARGFILE)
	$(PGPSIGNPROG)  $*/download/$(STATICARGFILE)
	env  WIN32ARGFILE=$(WIN32ARGFILE)  FREEBSDARGFILE=$(FREEBSDARGFILE) NONSTATICARGFILE=$(NONSTATICARGFILE) STATICARGFILE=$(STATICARGFILE) ELFBASE=$(ELFBASE) SRCBASE=$(SRCBASE) VERSION=$(VERSION) DISTPATH=$*/download bash ./mknewlsm > $*/download/$(LSMFILE)

%.lsm: ./settings
	env  WIN32ARGFILE=$(WIN32ARGFILE)  FREEBSDARGFILE=$(FREEBSDARGFILE) NONSTATICARGFILE=$(NONSTATICARGFILE)  STATICARGFILE=$(STATICARGFILE) ELFBASE=$(ELFBASE) SRCBASE=$(SRCBASE) VERSION=$(VERSION) DISTPATH=../html/download bash ./mknewlsm > $(LSMFILE)
	echo did
.PHONY: lsm

lsm: 	
	-rm $(LSMFILE)
	$(MAKE) $(LSMFILE)



BEDTMP=c:/tmp/bed-$(VERSION)

winbindist:
	zip -r bed-$(VERSION).win32.zip   $(CONFDIR) $(BINDIR)/$(EXEPROGRAM) 'c:/windows/Start Menu/bed.lnk'

nwinbindist:
	zip -r bed-$(VERSION).win32.zip  $(BINDIR)/$(EXEPROGRAM)  $(BINDIR)/bedn.exe $(CONFDIR)

#	-mkdir $(BEDTMP)
#	cp  $(BINDIR)/$(EXEPROGRAM) $(BEDTMP)
#	cp  $(CONFDIR)/misc/*.bedda $(BEDTMP)
#	cp  $(CONFDIR)/doc/bed* $(BEDTMP)
#	cp  $(CONFDIR)/* $(BEDTMP)
#	cd $(BEDTMP); pkzip  -r bedzip *.*

#	pkzip  -r bedzip $(BINDIR)/$(EXEPROGRAM) $(CONFDIR)
#	find $(CONFDIR) ! -type f -a -printf "\"%p\" " -a


#	tar -cf bedtar $(BINDIR)/$(EXEPROGRAM) $(CONFDIR)
#	gzip  bedtar
#	mv bedtar.gz bed-$(VERSION).win32.tar.gz

#	tar -cf bedtar $(BINDIR)/$(EXEPROGRAM) $(CONFDIR)
#	gzip  bedtar
#	mv bedtar.gz bed-$(VERSION).win32.tar.gz

#	mv bedwin32.zip bed-$(VERSION).win32.zip
#	zip -9 -r bedwin32.zip  $(BINDIR)/$(EXEPROGRAM) $(CONFDIR)
#	mv bedwin32.zip bed-$(VERSION).win32.zip




sign: $(DISTPATH).sign 
dist: $(DISTPATH).dist
srcdist: $(DISTPATH).srcdist
bindist: $(DISTPATH).bindist
html:$(DISTPATH).html
files:
	tar -z -tf $(FULLELFFILE)|sed -e 's/^/\//'> files
spec:  files
	PROGMANEXTRA="$(PROGMANEXTRA)" ICONPATH=$(ICONPATH) MENUPATH=$(MENUPATH) KDEMENU=$(KDEMENU) GNOMEMENU=$(GNOMEMENU) XBEDMENU=$(XBEDMENU) BEDMENU=$(BEDMENU) VERSION=$(VERSION) DISTPATH=$(HTMLPATH)/download bash ./mkspec > $(PROGRAM)-$(VERSION).spec
.PHONY: control
control:
	ICONPATH=$(ICONPATH) MENUPATH=$(MENUPATH) KDEMENU=$(KDEMENU) GNOMEMENU=$(GNOMEMENU) XBEDMENU=$(XBEDMENU) BEDMENU=$(BEDMENU) VERSION=$(VERSION) DISTPATH=$(HTMLPATH)/download bash debian/control.sh > debian/control
	CONFDIR=$(CONFDIR) ICONPATH=$(ICONPATH) MENUPATH=$(MENUPATH) KDEMENU=$(KDEMENU) GNOMEMENU=$(GNOMEMENU) XBEDMENU=$(XBEDMENU) BEDMENU=$(BEDMENU) VERSION=$(VERSION) DISTPATH=$(HTMLPATH)/download bash debian/postinst.sh > debian/postinst
mount:
	-mount /mnt/floppy
flop: mount /mnt/floppy.dist


RPMROOT=/usr/src/redhat
#RPMROOT=/usr/src/RPM
RPM = rpm
RPMFLAGS =  --sign -ba

rpm: spec
	cp $(SOURCEFILE) $(RPMROOT)/SOURCES/$(PROGRAM)-$(VERSION).src.tar.gz
	cp  $(PROGRAM)-$(VERSION).spec $(RPMROOT)/SPECS/$(PROGRAM)-$(VERSION).spec 
	$(RPM) $(RPMFLAGS) $(PROGRAM)-$(VERSION).spec 

package: Makefile
	$(RPM) --short-circuit $(RPMFLAGS) $(PROGRAM)-$(VERSION).spec 

installrpm:
	$(RPM) --short-circuit  --sign  -bi $(PROGRAM)-$(VERSION).spec 


ifneq ($(CYGWIN),yes)
CONFFILESH=mkbedrc.sh
else
CONFFILESH=mkbedrc95.sh
endif
$(CONFFILE):$(CONFFILESH) plugins/examples/Makefile config
	$(MAKE) -C plugins/examples ingive
	env HAS_X=$(HAS_X) CONFIG_PLUGIN=$(CONFIG_PLUGIN) CONFIG_THREADS=$(CONFIG_THREADS) PDCURSES="$(PDCURSES)" CONFDIRLINK=$(CONFDIRLINK) CONFDIR=$(CONFDIR) bash $(CONFFILESH)> $(CONFFILE)
DATE=`date +"%M-%H-%d-%m-%Y"`

backup: 
	date > ../backup/backupfile.start
	tar -zcf ../backup/$(PROGRAM)-$(VERSION).backup.tgz-$(DATE) -N "`cat ../backup/backupfile`" `find . ! -name "*.o*" -a ! -name "core" -a ! -name "*.plug" -a ! -type d -a ! -path ./src/$(PROGRAM) -a -printf "%p "`
	move  ../backup/backupfile.start ../backup/backupfile
fullbackup: 
	date > ../backup/backupfile.start
	tar -zcf ../backup/$(PROGRAM)-$(VERSION).backup.tgz-$(DATE) `find . ! -name "*.o*" -a ! -name "core" -a ! -name "*.plug" -a ! -type d -a ! -path ./src/$(PROGRAM) -a -printf "%p "`
	move  ../backup/backupfile.start ../backup/backupfile
try:
	 echo $(TESTVAR)

./configure:./configure.in src/defines.h.in
	autoconf


uninstall:
	-rm -i $(BINDIR)/$(EXEPROGRAM)
ifeq ($(CONFIG_XBED),y)
	-rm -i $(BINDIR)/$(XPROGRAM)
endif
	-rm  -i $(CONFDIRLINK)
	-rm  -i $(MANDIR)/$(PROGRAM).1.gz
	-rm  -i $(MANDIR)/$(XPROGRAM).1.gz
	-rm -fr $(CONFDIR)
ifeq ($(CONFIG_PROGMAN),y)
	-rm -i $(ICONPATH)/mini/bed.xpm $(ICONPATH)/bed.xpm $(MENUPATH)/$(PROGRAM) $(KDEMENU)/$(XBEDMENU)/XBed.kdelnk $(KDEMENU)/$(BEDMENU)/Bed.kdelnk $(GNOMEMENU)/$(XBEDMENU)/XBed.desktop $(GNOMEMENU)/$(BEDMENU)/Bed.desktop
endif

bed.menu:mkmenu.sh config
	CONDIRLINK=$(CONFDIRLINK) MENUNAME=$(MENUNAME) XMENUNAME=$(XMENUNAME) BEDMENU=$(BEDMENU) XBEDMENU=$(XBEDMENU) BINDIR=$(BINDIR) PROGRAM=$(PROGRAM)  XPROGRAM=$(XPROGRAM) bash ./mkmenu.sh > bed.menu

cprpm:
	cp /usr/src/redhat/RPMS/i386/bed-$(VERSION)*.rpm ../html/download
	cp /usr/src/redhat/SRPMS/bed-$(VERSION)*src*.rpm ../html/download


CONFDIRLINKER=$(shell echo '$(CONFDIRLINK)'| sed -e 's/\//\\\//g' )
README: .start.txt .common.txt
	cat .start.txt > README
	sed 's/CONFDIRLINK/$(CONFDIRLINKER)/g' < .common.txt >>README
	

pkg/pkg-plist:
	-rm $@
	@FILES=`for afile in $(BINDIST); do  test -e $$afile&&echo $$afile ;done`;PREFIXX=`echo $(prefix)|sed -e 's/\\//\\\\\\//g' `;find  $$FILES ! -type d ! -name "*bed.1.gz" -print | sed -e s/$$PREFIXX'\///g' >> $@  ;find  $$FILES -type d  -a  -print |$(SORT) -r|sed -e s/$$PREFIXX'\//\@dirrm\ /g' >> $@ 
	echo '@unexec rm %D/share/bed' >> $@
#;echo $(CONFDIRLINK) |sed -e s/$$PREFIXX'\///g'>>$@
#sed -e 's/$$PREFIXX/\@dirrm/g'

dep:
	$(MAKE) -C src mainprocedures.h
	$(MAKE) -C plugins/examples dep
	$(MAKE) -C src dep

undos:
	file `find .	 -type f`|grep CRLF|cut -d : -f 1|xargs d2u

linuxconfig: 
	bash ./configure
	mv ./config ./config.bak
	sed -e '{s/^CONFIG_DEBUG=.*/CONFIG_DEBUG=n/g;s/^CONFIG_MMAP=.*/CONFIG_MMAP=y/g;s/^prefix=.*/prefix=\/usr/g;}' < ./config.bak > ./config
	echo '#define DLDEFAULTCOLORS 1' >> src/defines.h
	echo '#define NCURSESLIB "libncurses.so.5"' >> src/defines.h
staticconfig: 
	bash ./configure
	mv ./config ./config.bak
	sed -e '{s/^CONFIG_STATIC=.*/CONFIG_STATIC=y/g;s/^CONFIG_DEBUG=.*/CONFIG_DEBUG=n/g;s/^CONFIG_MMAP=.*/CONFIG_MMAP=y/g;s/^prefix=.*/prefix=\/usr/g;}' < ./config.bak > ./config

nwinconfig: 
	echo 'CURSESLIB=ncurses' >> settings
	bash ./configure
	mv ./config ./config.bak
	sed -e 's/^CONFIG_DEBUG=.*/CONFIG_DEBUG=n/g' < ./config.bak > ./config

winconfig: 
	echo 'CURSESLIB=pdcurses' >> settings
	bash ./configure
	mv ./config ./config.bak
	sed -e '{s/^CONFIG_DEBUG=.*/CONFIG_DEBUG=n/g;s/LINKINDYN.*file.plug/#&/g;}' < ./config.bak > ./config
src/defines.h.in: configure.in	
	echo '#ifndef DEFINES_H' >src/defines.h.in
	echo '#define DEFINES_H' >>src/defines.h.in
	sed -f mkdefs.sed < configure.in|grep '^#undef'|sort|uniq>> src/defines.h.in
	echo '#endif' >>src/defines.h.in
show:
	echo $(PROGMANEXTRA)


left:
	find . -name "*.o*" -o -name "*.i" -o -name "*.ii*" -o -name "*core*" -o -name "*.exe" -o -name "*.bak" -o -name "*~" 
	-ls pkg/work 
	-ls debian/tmp

linuxall: linuxconfig dep all 

DEBPACKAGE=$(DISTPATH)/download/bed_$(VERSION)_i386.deb
DEBPATCH=$(DISTPATH)/download/bed_$(VERSION)_i386.deb.patch

patch: 	$(DEBPACKAGE)
	binpatch $(FULLELFFILE) $(DEBPACKAGE) $(DEBPATCH) -c -l -O

deb: 	$(DEBPACKAGE)

debstart:
	cat debhead > $@
	./getsize $(FULLELFFILE) >>$@
$(DEBPACKAGE):debstart $(FULLELFFILE)
	cat debstart $(FULLELFFILE) >>$@
getprog: $(PROGMANEXTRA)
	cp  $(PROGMANEXTRA) progman


dubwindist:
		make realclean
		make winconfig;make dep;make
		make install
		mv c:/windows/bed.exe c:/windows/bedp.exe
		make realclean
		make nwinconfig;make dep;make
		make install
		mv c:/windows/bed.exe c:/windows/bedn.exe
		cp c:/usr/bin/binpatchg.exe 'c:/Program Files/bed/binpatch.exe'
		binpatch c:/windows/bedp.exe c:/windows/bedn.exe 'c:/Program Files/bed/bedpatch' -c -l -O -u5
		cp c:/windows/bedp.exe c:/windows/bed.exe

	
dubrest:
		make install
		mv c:/windows/bed.exe c:/windows/bedp.exe
		make realclean
		make nwinconfig;make dep;make
		make install
		mv c:/windows/bed.exe c:/windows/bedn.exe
		cp c:/usr/bin/binpatchg.exe 'c:/Program Files/bed/binpatch.exe'
		binpatch c:/windows/bedp.exe c:/windows/bedn.exe 'c:/Program Files/bed/bedpatch' -c -l -O -u5
