# Directorios de la aplicación
INCLUDEDIR = ../include
LIBDIR = ../lib
BINDIR = ../bin
# Programas estandar que se utilizan
# Archivador
AR = ar
AFLAGS = rs
# Compilador
CC = gcc
CFLAGS = -I$(INCLUDEDIR) -L$(LIBDIR)
# Biblioteca de usuario y ficheros que forman parte de la biblioteca
BIBLIOTECA = $(LIBDIR)/libgrep_rw.a
BIBLIOTECAB= $(LIBDIR)/libgrep_mmap.a
#Programa ejecutable y ficheros que forman parte del mismo
OBJETOS_PROGRAMA = grep.o
#Objetivo "all" que programa los ejecutables y ficheros que forman partes del mismo
all: $(BINDIR)/grep_mmap $(BINDIR)/grep_rw
$(BINDIR)/grep_mmap: $(OBJETOS_PROGRAMA) $(BIBLIOTECAB)
$(CC) $(OBJETOS_PROGRAMA) $(CFLAGS) -lgrep_mmap -Wall -o $(BINDIR)/grep_mmap
$(BINDIR)/grep_rw: $(OBJETOS_PROGRAMA) $(BIBLIOTECA)
$(CC) $(OBJETOS_PROGRAMA) $(CFLAGS) -lgrep_rw -Wall -o $(BINDIR)/grep_rw
#Biblioteca que se crea
$(BIBLIOTECA): grep_rw.o
$(AR) $(AFLAGS) $(BIBLIOTECA) grep_rw.o
$(BIBLIOTECAB): grep_mmap.o
$(AR) $(AFLAGS) $(BIBLIOTECAB) grep_mmap.o
$(OBJETOS_PROGRAMA) $(OBJETOS_BIBLIOTECA): $(INCLUDEDIR)/grep.h
#Objetivo "prueba" con la prueba de los dos ejecutables
prueba: $(BINDIR)/grep_mmap $(BINDIR)/grep_rw
../bin/grep_rw include ~/Grep/src/grep_rw.c
../bin/grep_mmap include ~/Grep/src/grep_mmap.c