# **************************************************************************
# Fichero makefile.
# --------------------------------------------------------------------------
# Licencia GPL. Juan Gonzalez Gomez
# --------------------------------------------------------------------------
#
#***************************************************************************

# Edited for Debian GNU/Linux.
DESTDIR =

# ¿Dónde poner los binarios en el 'make install'?
BIN  = $(DESTDIR)/usr/local/bin

#-- Donde instalar las paginas man?
MAN  = $(DESTDIR)/usr/local/man

#-- Librerias para la compilacion
LIB = -lcts

#---- Compilador
CC = gcc
CFLAGS = -Wall

all: cttools

#-- Construccion de los ejemplos de prueba
cttools: mcboot ct294 ctdetect ctdialog cteeprom ctload ctmap ctreset \
         cts19toc downmcu downmcu_e

#--------------------------
#  Herramientas que componen las cttools
#--------------------------
NAME1= mcboot
DEP1= $(NAME1).o io.o

$(NAME1): $(DEP1)
	    $(CC) -o $(NAME1) $(DEP1) $(LIB) -lncurses

clean::
	  rm -f $(NAME1) $(DEP1)
    
#---------------------------
NAME2= ct294
DEP2= $(NAME2).o io.o

$(NAME2): $(DEP2)
	    $(CC) -o $(NAME2) $(DEP2) $(LIB) -lncurses

clean::
	  rm -f $(NAME2) $(DEP2)
    
#---------------------------
NAME3= ctdetect
DEP3= $(NAME3).o io.o termansi.o

$(NAME3): $(DEP3)
	    $(CC) -o $(NAME3) $(DEP3) $(LIB)

clean::
	  rm -f $(NAME3) $(DEP3)    
    
#---------------------------
NAME4= ctdialog
DEP4= $(NAME4).o io.o termansi.o comandos.o dasm.o

$(NAME4): $(DEP4)
	    $(CC) -o $(NAME4) $(DEP4) $(LIB)

clean::
	  rm -f $(NAME4) $(DEP4)        
    
#---------------------------
NAME5= cteeprom
DEP5= $(NAME5).o io.o termansi.o

$(NAME5): $(DEP5)
	    $(CC) -o $(NAME5) $(DEP5) $(LIB)

clean::
	  rm -f $(NAME5) $(DEP5)       

#---------------------------
NAME6= ctload
DEP6= $(NAME6).o io.o termansi.o

$(NAME6): $(DEP6)
	    $(CC) -o $(NAME6) $(DEP6) $(LIB)

clean::
	  rm -f $(NAME6) $(DEP6)     
    
#---------------------------
NAME7= ctmap
DEP7= $(NAME7).o io.o termansi.o

$(NAME7): $(DEP7)
	    $(CC) -o $(NAME7) $(DEP7) $(LIB)

clean::
	  rm -f $(NAME7) $(DEP7)        
    
#---------------------------
NAME8= ctreset
DEP8= $(NAME8).o io.o termansi.o

$(NAME8): $(DEP8)
	    $(CC) -o $(NAME8) $(DEP8) $(LIB)

clean::
	  rm -f $(NAME8) $(DEP8)     

#---------------------------
NAME9= cts19toc
DEP9= $(NAME9).o io.o termansi.o

$(NAME9): $(DEP9)
	    $(CC) -o $(NAME9) $(DEP9) $(LIB)

clean::
	  rm -f $(NAME9) $(DEP9)   
    
#---------------------------
NAME10= downmcu
DEP10= $(NAME10).o io.o termansi.o

$(NAME10): $(DEP10)
	    $(CC) -o $(NAME10) $(DEP10) $(LIB)

clean::
	  rm -f $(NAME10) $(DEP10)       
    
#---------------------------
NAME11= downmcu_e
DEP11= $(NAME11).o io.o termansi.o

$(NAME11): $(DEP11)
	    $(CC) -o $(NAME11) $(DEP11) $(LIB)

clean::
	  rm -f $(NAME11) $(DEP11)         
    
#-----------------------------
#--- Dependencias
#-----------------------------
#serie.o    : serie.h

#---------------------------
#-- INSTALACION
#---------------------------
install: cttools
	     install -d $(BIN) $(MAN) 
	     install ct294 $(BIN)
	     install ctdetect $(BIN)
	     install ctdialog $(BIN)
	     install cteeprom $(BIN)
	     install ctload $(BIN)
	     install ctmap $(BIN)
	     install ctreset  $(BIN)
	     install cts19toc $(BIN)
	     install mcboot   $(BIN)
	     install downmcu $(BIN)
	     install downmcu_e $(BIN)
	     install ../man/*.1  $(MAN)/man1
                       

#---------------------------
#-- DESINSTALACION
#---------------------------
uninstall:
	   rm -f $(BIN)/ct294  $(BIN)/ctdetect $(BIN)/ctdialog $(BIN)/cteeprom \
           $(BIN)/ctload $(BIN)/ctmap    $(BIN)/ctreset  $(BIN)/cts19toc   \
           $(BIN)/downmcu $(BIN)/downmcu_e $(BIN)/mcboot
	   rm -f $(MAN)/man1/ct294.1 $(MAN)/man1/cteeprom.1 \
           $(MAN)/man1/ctmap.1 $(MAN)/man1/cts19toc.1 \
           $(MAN)/man1/downmcu.1  $(MAN)/man1/mcboot.1 \
           $(MAN)/man1/ctdetect.1 $(MAN)/main1/ctload.1  \
           $(MAN)/man1/ctreset.1  $(MAN)/man1/cttools.1  \
           $(MAN)/man1/downmcu_e.1
      
#--------------------------
#  REGLAS GENERICAS
#--------------------------
.c.o:		
		$(CC) $(CFLAGS) -c $<
