OBJ= StartUp.o LibInit.o LibFuncs.o dispatcher.o util.o semantics_c.o semantics_lisp.o
NAME= smartindent.api

$(NAME):  $(OBJ)
	slink $(OBJ) LIB lib:sc.lib lib:amiga.lib NODEBUG to $(NAME)
	-delete $(NAME).info

dist:
	ed smartindent.h
	ed smartindent.readme sticky
	-delete LibInit.o
	-delete ram:makelha all
	makedir ram:makelha
	copy icons/\#? ram:makelha/ all
	copy presets/\#? ram:makelha/Smartindent/presets/ all
	copy \#?.[ch] test_input.\#? test_correct.\#? SCOPTIONS smakefile ram:makelha/Smartindent/Source/
	addicon ram:makelha/Smartindent/Source/\#?
	copy golded:tools/regedit/regedit ram:makelha/Smartindent/bin/
	copy Smartindent.readme Install Install_d.bat Install_e.bat COPYING ram:makelha/Smartindent/
	smake
	copy smartindent.api ram:makelha/Smartindent/api/smartindent.api
	-delete smartindent.lha
	lha a smartindent.lha ram:makelha/

clean:
	-delete \#?.o \#?.info $(NAME)

ci:
	ci -l Install\#? \#?.c \#?.h SCOPTIONS smakefile Smartindent.readme

test:
	@smake m=.c testfile
	@smake m=.lisp testfile

#
# Note: GoldED has to save test_xxx_correct.c as well (TAB saving en/disabled)...
#
testfile:
	@echo "Starting GoldED and indenting test text for mode "$(m)"..."
	@golded:ed
	@waitforport GOLDED.1
	@rx "mode='$(m)'; address GOLDED.1; 'OPEN SMART NEW 'pragma(d)'/test_input'mode; \
	     'SET TYPE 'mode; 'GOTO TOP'; \
	     'MARK HIDE'; 'MARK SET BEGIN'; 'GOTO BOTTOM'; 'MARK SET END'; \
	     'SMARTINDENT BLOCK'; 'SAVE ALL NAME t:test1'; 'SMARTINDENT BLOCK'; \
	     'SAVE ALL NAME t:test2'; 'SMARTINDENT BLOCK'; 'SAVE ALL NAME t:test3'; \
	     'OPEN SMART NEW 'pragma(d)'/test_correct'mode; 'SAVE ALL NAME t:correct'; \
	     'QUIT'; 'QUIT'"
	@echo ""
	@echo "Diffs between done and intented indention:"
	@echo ------------------------------------------
	-@diff -ct t:test1 t:correct
	@echo ------------------------------------------
	@echo ""
	@echo "Diffs between first and second indention try:"
	@echo ------------------------------------------
	-@diff -ct t:test1 t:test2
	@echo ------------------------------------------
	@echo ""
	@echo "Diffs between second and third indention try:"
	@echo ------------------------------------------
	-@diff -ct t:test2 t:test3
	@echo ------------------------------------------
	@echo ""
	@echo "Solved bugs, that are still marked in the test text:"
	@search >t:test.st from t:test3 search "!!!BUG!!!"
	@search >t:test.sc from t:correct search "!!!BUG!!!"
	-@diff "--old-line-format=" "--new-line-format=" "--unchanged-line-format=%L" t:test.st t:test.sc
	@delete quiet t:test1 t:test2 t:test3 t:correct t:test.st t:test.sc

