# @(#)makefile	19.1 (ESO-IPG) 02/25/03 14:03:29
# .COPYRIGHT:	Copyright (c) 1988 European Southern Observatory,
#						all rights reserved
# .TYPE		make file
# .NAME		$MIDASHOME/$MIDVERS/*/help/makefile
# .LANGUAGE	makefile syntax
# .ENVIRONMENT	Unix Systems. 
# .COMMENT	Creates all *.hlc files from *.hlq.
# .REMARKS 
# .AUTHOR	Carlos Guirao
# .VERSION 1.1  910715:         Implementation
# .VERSION 2.1  911015:         Creating dependencies.
# .VERSION 3.1  920331:         OBJ are defined on the internal make.
# .VERSION 4.1  920708:         IFS is defined as NEWLINE.
# .VERSION 4.2  922308:         IFS is defined as blank. 
# .VERSION 3.0  930308:		Using default.mk file
# .VERSION 3.1  930630:		Generating tapede.alq from devices.sh
# .VERSION 3.2  930830:		Using find instead of ls. Some shells can not
#				handle such big argument list (PC/SCO).
# .VERSION 3.3  940606:		Silently

include ../../local/default.mk

CONTEXT= 

OBJ =
OUT =

all:   all.hlc tapede.alq

all.hlc:
	@(IFS=' '; for OUT in \
	`find . -name "*.hlq" -print | grep -v SCCS | \
	sed -e 's/.\///' -e 's/_.*//'  -e 's/\.hlq//' | \
	awk '{print substr(\$$1,1,6)}' | sort -u |awk '{printf "%s ",\$$1}'`;\
	do (eval $(MAKE) -s OBJ=\"`ls $$OUT*.hlq |awk '{printf "%s ",\$$1}'`\" \
	OUT=\"$$OUT\" one)\
	done)
	cp drs.hlq drs.hlc

one: $(OUT).hlc

$(OUT).hlc: $(OBJ)
	@ rm -f $@
	@(IFS=' '; for file in $(OBJ); \
	do sed -n '/SECTION./,/\\us/p' $$file | sed '/^\\/d' | sed '2d' >> $@;\
	done )
	@echo $@

make_alll:
	@(if [ -f alll.hlz ]; then mv alll.hlz alll.hlz~; fi)
	$(CREA_ALLL) > alll.hlz

make_hlq:
	$(CREA_HLQ) $(CONTEXT)
	
./gen_tapes: gen_tapes.sh
	rm -f $@
	cat $@.sh > $@
	chmod +x $@

tapede.alq: ./gen_tapes ../../monit/devices.sh
	rm -f $@
	./gen_tapes > tapede.alq

clean:
	rm -f *.hlc
	rm -f tapede.alq
