-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·65 lines (50 loc) · 1.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# --------------------------------------------------------------------
# Makefile de la tarea 1.
# Laboratorio del mejor grupo de P4.
# Define un conjunto de reglas.
# Cada regla tiene un objetivo, dependencias y comandos.
#objetivo: dependencia1 dependencia2...
# comando1
# comando2
# comando3
# (antes de cada comando hay un tabulador, no espacios en blanco).
# Se invoca con
#make objetivo
# para que se ejecuten los comandos.
#
# Si `objetivo` es un archivo los comandos se ejecutan solo si no está
# actualizado (esto es, si su fecha de actualización es anterior a la de alguna
# de sus dependencias.
# Previamente se aplica la regla de cada dependencia.
# --------------------------------------------------------------------
# Objetivo predeterminado (no se necesita especificarlo al invocar `make`).
all: principal
# Objetivos que no son archivos.
.PHONY: all clean_bin clean_test clean testing
# directorios
HDIR = include
CPPDIR = cpp
ODIR = obj
MODULOS = clase DtClase DtEntrenamiento DtSocio DtSpinning entrenamiento fecha inscripcion socio spinning turno
# lista de archivos, con directorio y extensión
HS = $(MODULOS:%=$(HDIR)/%.h)
CPPS = $(MODULOS:%=$(CPPDIR)/%.cpp)
OS = $(MODULOS:%=$(ODIR)/%.o)
PRINCIPAL=principal
EJECUTABLE=principal
# compilador
CC = g++
# opciones de compilación
CCFLAGS = -Wall -Werror -I$(HDIR) -g -frtti
# -DNDEBUG
# se agrega esta opción para que no las llamadas a assert no hagan nada.
$(ODIR)/$(PRINCIPAL).o:$(PRINCIPAL).cpp
$(CC) $(CCFLAGS) -c $< -o $@
# cada .o depende de su .cpp
# $@ se expande para tranformarse en el objetivo
# $< se expande para tranformarse en la primera dependencia
$(ODIR)/%.o: $(CPPDIR)/%.cpp $(HDIR)/%.h
$(CC) $(CCFLAGS) -c $< -o $@
# $^ se expande para tranformarse en todas las dependencias
$(EJECUTABLE): $(ODIR)/$(PRINCIPAL).o $(OS)
$(CC) $(CCFLAGS) $^ -o $@