-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.windows
More file actions
69 lines (57 loc) · 2.71 KB
/
Copy pathMakefile.windows
File metadata and controls
69 lines (57 loc) · 2.71 KB
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
66
67
68
69
# Makefile para Windows (MSYS2/MingW)
# Space Invaders en C con Allegro 5
# Autor: RGiskard7
CC=gcc
CPLUS=g++
CFLAGS=-g -Wall -pedantic
EXECUTABLE=SpaceInvaders.exe
# Detectar librerías de Allegro con pkg-config
ALLEGRO_LIBS=$(shell pkg-config --libs allegro-5 allegro_main-5 allegro_image-5 allegro_font-5 allegro_ttf-5 allegro_primitives-5 allegro_audio-5 allegro_acodec-5)
ALLEGRO_CFLAGS=$(shell pkg-config --cflags allegro-5)
# Directorios
SRC_DIR=src
INCLUDE_DIR=include
RESOURCES_DIR=resources
# Archivos fuente y objetos
SRCS=$(SRC_DIR)/main.c $(SRC_DIR)/game.c $(SRC_DIR)/bullet.c $(SRC_DIR)/ship.c $(SRC_DIR)/martian.c $(SRC_DIR)/object.c $(SRC_DIR)/bunker.c
OBJS=main.o game.o bullet.o ship.o martian.o object.o bunker.o
# Colores para output (opcional)
COLOR_RESET=\033[0m
COLOR_GREEN=\033[32m
COLOR_BLUE=\033[34m
COLOR_YELLOW=\033[33m
# Regla por defecto
all: $(EXECUTABLE)
@echo "$(COLOR_GREEN)✅ Compilación exitosa$(COLOR_RESET)"
@echo "$(COLOR_BLUE)🎮 Ejecuta con: $(EXECUTABLE)$(COLOR_RESET)"
# Regla para compilar el ejecutable
$(EXECUTABLE): $(OBJS)
@echo "$(COLOR_YELLOW)🔗 Enlazando Space Invaders...$(COLOR_RESET)"
$(CC) $(CFLAGS) -o $(EXECUTABLE) $(OBJS) $(ALLEGRO_LIBS)
# Regla genérica para compilar archivos .c a .o
%.o: $(SRC_DIR)/%.c
@echo "$(COLOR_YELLOW)🔨 Compilando $<...$(COLOR_RESET)"
$(CC) $(ALLEGRO_CFLAGS) -I $(INCLUDE_DIR) $(CFLAGS) -c $< -o $@
# Regla para limpiar archivos generados
clean:
@echo "$(COLOR_YELLOW)🧹 Limpiando archivos temporales...$(COLOR_RESET)"
rm -f *.o $(EXECUTABLE)
@echo "$(COLOR_GREEN)✅ Limpieza completada$(COLOR_RESET)"
# Regla para ejecutar el juego después de compilar
run: all
@echo "$(COLOR_GREEN)🚀 Iniciando Space Invaders...$(COLOR_RESET)"
./$(EXECUTABLE)
# Regla de ayuda
help:
@echo "$(COLOR_BLUE)═══════════════════════════════════════════════════$(COLOR_RESET)"
@echo "$(COLOR_GREEN) Space Invaders - Makefile para Windows$(COLOR_RESET)"
@echo "$(COLOR_BLUE)═══════════════════════════════════════════════════$(COLOR_RESET)"
@echo ""
@echo "$(COLOR_YELLOW)Comandos disponibles:$(COLOR_RESET)"
@echo " $(COLOR_GREEN)make -f Makefile.windows$(COLOR_RESET) - Compila el juego"
@echo " $(COLOR_GREEN)make -f Makefile.windows run$(COLOR_RESET) - Compila y ejecuta el juego"
@echo " $(COLOR_GREEN)make -f Makefile.windows clean$(COLOR_RESET) - Elimina archivos compilados"
@echo " $(COLOR_GREEN)make -f Makefile.windows help$(COLOR_RESET) - Muestra esta ayuda"
@echo ""
# Declarar targets que no son archivos
.PHONY: all clean run help