From 0292dd3e04d5d9b3f185720ab2ea79dc186db0fb Mon Sep 17 00:00:00 2001 From: Olavo Nascimento Date: Sat, 7 Sep 2019 19:33:26 -0300 Subject: [PATCH] Atualizar a Makefile para uso no Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Permite que a Makefile seja utiliza para a criação de um executável independente no Windows. Para isso é necessário a pasta do Allegro estar localizada no diretório de compilação. --- makefile | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index 9aca485..85e5b6f 100644 --- a/makefile +++ b/makefile @@ -7,6 +7,12 @@ OBJ_DIR = obj SRC_DIR = src INC_DIR = include +# Windows Only +# Path to Allegro headers +ALLEGRO_INCLUDE_PATH = allegro/include +# Path to Allegro monolith library +ALLEGRO_MONOLITH_PATH = $(ALLEGRO_INCLUDE_PATH:include=lib/liballegro-5.0.10-monolith-mt.a) + EXE = GalaxyDefenders SRC = $(wildcard $(SRC_DIR)/*.c) OBJ = $(subst $(SRC_DIR), $(OBJ_DIR), $(SRC:.c=.o)) @@ -14,13 +20,23 @@ OBJ = $(subst $(SRC_DIR), $(OBJ_DIR), $(SRC:.c=.o)) all: $(EXE) $(EXE): $(OBJ) +ifeq ($(OS),Windows_NT) + @if not exist "$(BIN_DIR)" mkdir $(BIN_DIR) + $(CC) -mwindows -o $(BIN_DIR)/$@ $(OBJ) $(ALLEGRO_MONOLITH_PATH) +else mkdir -p $(BIN_DIR) - $(CC) -I$(INC_DIR) -o $(BIN_DIR)/$@ $(OBJ) $(LDFLAGS) + $(CC) -I$(INC_DIR) $(LDFLAGS) -o $(BIN_DIR)/$@ $(OBJ) +endif $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c +ifeq ($(OS),Windows_NT) + @if not exist "$(OBJ_DIR)" mkdir $(OBJ_DIR) + $(CC) -I$(INC_DIR) -I $(ALLEGRO_INCLUDE_PATH) $(CFLAGS) -c $< -o $@ +else mkdir -p $(OBJ_DIR) $(CC) -I$(INC_DIR) $(CFLAGS) -c $< -o $@ - +endif + clean: $(RM) $(OBJ)