From 57db69d2a49e98e3f467fd97bf935442206405ad Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 23 Mar 2025 08:52:19 +0100 Subject: [PATCH] actualitzat Makefile --- .gitignore | 4 +++- Makefile | 30 +++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a5a6f96..13e41e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.exe -*.dll \ No newline at end of file +*.dll +*.out +build/ \ No newline at end of file diff --git a/Makefile b/Makefile index a459fdc..2d2f3c3 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,31 @@ +# Variables comunes source := source/*.cpp executable_name := demo_pelotas1 +CXX := g++ # Cambiar a clang++ si prefieres +CXXFLAGS := -std=c++11 -Wall # Opciones comunes de compilación +LDFLAGS := -lSDL2 # Flags de enlace comunes +# Detectar plataforma +ifeq ($(OS),Windows_NT) + PLATFORM := windows + LDFLAGS += -lmingw32 -lws2_32 -lSDL2main + OUTPUT_EXT := .exe +else + PLATFORM := unix # Unificación para macOS y Linux + OUTPUT_EXT := .out +endif + +# Regla principal: compilar según la plataforma detectada +all: $(PLATFORM) + +# Compilación para Windows windows: - g++ $(source) -std=c++11 -Wall -lmingw32 -lws2_32 -lSDL2main -lSDL2 -o $(executable_name).exe + $(CXX) $(source) $(CXXFLAGS) $(LDFLAGS) -o $(executable_name)$(OUTPUT_EXT) -linux: - g++ $(source) -std=c++11 -Wall -lSDL2 -o $(executable_name) +# Compilación para Unix (Linux y macOS) +unix: + $(CXX) $(source) $(CXXFLAGS) $(LDFLAGS) -o $(executable_name)$(OUTPUT_EXT) -macos: - g++ $(source) -std=c++11 -Wall -lSDL2 -o $(executable_name) \ No newline at end of file +# Regla para limpiar archivos generados +clean: + rm -f $(executable_name)* \ No newline at end of file