#######################################################
#	Add-on pour la traduction francaise de        #
#                  la doc d'allegro                   #
#                                                     #
#       traduction - Paul Pinault                     #
#                    Disk91 / TeKnO-BeDoUiNs /        #
#                    disk@infonie.fr                  #
#                                                     #
#       script     - Adam Hankiewicz                  #
#                    gradha@iname.com                 #
#                                                     #
#######################################################


# check that Allegro has a good directory structure
ifeq ($(wildcard src/makedoc.c),)
badalleg:
	@echo Erreur dans installation, la structure des repertoires est mauvaise
	@echo A la decompression utilisez l'option -d
endif

# Si tienes problemas con la extensin html, cmbiala a la corta.
HTML = html

RM = rm -f -v

OBJ = obj
EXE = .exe
FLAGS = -s -O3 -ffast-math -fomit-frame-pointer
MAKALL = obj/makedoc.exe
DOCDEST = $(DJDIR)/info/frallegr.inf

DOCS = txt/allegro.txt html/allegro.$(HTML) \
       obj/allegro.txi obj/frallegr.inf \
       txt/allegro.rtf \

docs : $(DOCS) $(DOCDEST)
	@echo
	@echo Creation de la documentation terminee
	@echo
	@echo tapez make clean pour supprimer les documents si besoin
	@echo lancez make pour les recreer

$(OBJ)/makedoc$(EXE) : src/makedoc.c
	gcc $(FLAGS) -o $(OBJ)/makedoc$(EXE) src/makedoc.c

$(DOCDEST): obj/frallegr.inf
    ifneq ($(wildcard $(DJDIR)/bin/makeinfo.exe),)
	copy obj\frallegr.inf $(subst /,\,$(DOCDEST))
    else
	@echo makeinfo non installe : la copie du fichier frallegr.inf est non faite
    endif

obj/%.inf: obj/allegro.txi
    ifneq ($(wildcard $(DJDIR)/bin/makeinfo.exe),)
	makeinfo --no-split -o $@ $<
    else
	@echo makeinfo non installe : la copie du fichier allegro.inf non faite
    endif

obj/%.txi: src/%._tx $(OBJ)/makedoc.exe
	$(OBJ)/makedoc$(EXE) -texinfo $@ $<

html/%.$(HTML): src/%._tx $(OBJ)/makedoc$(EXE)
	@echo ...creation archive *.html...
	$(OBJ)/makedoc$(EXE) -html $@ $<

txt/%.rtf: src/%._tx $(OBJ)/makedoc.exe
	$(OBJ)/makedoc$(EXE) -rtf $@ $<

txt/%.txt: src/%._tx $(OBJ)/makedoc$(EXE)
	@echo ...creation archive *.txt...
	$(OBJ)/makedoc$(EXE) -ascii $@ $<

clean :
	$(RM) $(DOCS) $(CONVALL) html/*.$(HTML)
	@echo Les documents sont supprimes
	@echo Tapez make pour relancer la creation

ultraclean :
	$(RM) $(DOCS) $(CONVALL) $(MAKALL) html/*.$(HTML)
	@echo Tout est detruit