##########################################################################
#	         The root makefile for wp2latex package			 #	
#									 #	
# Available targets are: make 		make selected modules		 #	
#                        make all	Make all + all selected modules	 #
#			 make clean	Remove all temporary files 	 #
#			 make distclean Thourough cleanup          	 #
#			 make install	Perform automatic installation   #
#                        make package   Statical build for package       #
#                        make testconv	Execute conversion test.         #
#                        make testltx	Execute conv followed by LaTeX   #
#                        make wp2latex	Make only WordPerfect modules    #
#                        make x2latex	Make all conversion modules 	 #
##########################################################################

@SET_MAKE@
ifeq ($(MAKE),)
MAKE=make
endif

all: cplib
	export OSTYPE && $(MAKE) -C ./sources.cc/ @SET_OSTYPE@
	$(MAKE) -C ./doc/ all

default: cplib
	export OSTYPE && $(MAKE) -C ./sources.cc/ @SET_OSTYPE@

wp2latex: cplib
	export OSTYPE && $(MAKE) -C ./sources.cc/ TG_WP @SET_OSTYPE@

x2latex: cplib
	export OSTYPE && $(MAKE) -C ./sources.cc/ TG_ALL @SET_OSTYPE@

cplib:
	export OSTYPE && $(MAKE) -C ./sources.cc/cp_lib/ @SET_OSTYPE@

package:
	export OSTYPE && $(MAKE) -C ./sources.cc/ static @SET_OSTYPE@

static:
	export OSTYPE && $(MAKE) -C ./sources.cc/ static @SET_OSTYPE@
	$(MAKE) -C ./doc/ all

distclean: 
	$(MAKE) -C ./sources.cc/ distclean
	$(MAKE) -C ./instaler/ clean
#	$(MAKE) -C ./sources.pas/ clean
	$(MAKE) -C ./doc/ distclean
	$(MAKE) -C ./test/ clean
	rm -f *.exe *.OBJ *.obj *.o *.bak core *.gpr *.gdt *.dvi *.aux *.log *.ent *.toc
	rm -f config.status config.h out.txt
	$(MAKE) -k -C ./msvc/ clean
	rm makefile
	cp makefile.gen makefile

generic:
	$(MAKE) -C ./sources.cc/ generic
	$(MAKE) -C ./instaler/ generic
	rm makefile
	cp makefile.gen makefile

clean:
	$(MAKE) -C ./sources.cc/ clean
	$(MAKE) -C ./instaler/ clean
#	$(MAKE) -C ./sources.pas/ clean
	$(MAKE) -C ./doc/ clean
	$(MAKE) -C ./test/ clean
	rm -f *.exe *.OBJ *.obj *.o *.bak core *.gpr *.gdt *.dvi *.aux *.log *.ent *.toc *.idx
	$(MAKE) -C ./msvc/ clean
	rm -f config.status config.h
	rm -f autom4te.cache/*

install:
	instaler/install

doc:
	$(MAKE) -C ./doc/ all

test:	default
	$(MAKE) -C ./test @TEST_LTX@

bigtest:	default
	$(MAKE) -C ./test bigtest

testltx: default
	$(MAKE) -C ./test testltx

testconv: default
	$(MAKE) -C ./test testconv


menuconfig:	instaler/menucfg.exe
	instaler/menucfg.exe sources.cc/modules.mak


#internal stuff
instaler/menucfg.exe:	instaler/menucfg.cc
	export OSTYPE && $(MAKE) -C ./instaler/ menucfg.exe


configure: configure.in
	autoconf
