| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- # Compiler and flags
- CC = gcc
- CFLAGS = -Wall -Wextra -Wpedantic -Werror -std=c99 \
- -O2 -Iexternal/raylib/src
- LDFLAGS = -Lexternal/raylib/ -lraylib -lm -lpthread
- # Directories
- SRC_DIR = src
- OBJ_DIR = .obj
- RAYLIB_SRC_DIR = external/raylib/src
- RAYLIB_LIB = external/raylib/libraylib.a
- # Target executable
- TARGET = vinora
- # Source and object files
- C_SOURCES = $(wildcard $(SRC_DIR)/*.c)
- OBJECTS = $(C_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
- # Default target
- all: $(TARGET)
- # Build Raylib library
- raylib: $(RAYLIB_LIB)
- $(RAYLIB_LIB):
- @echo
- @echo "BUILDING RAYLIB..."
- @echo
- $(MAKE) -C $(RAYLIB_SRC_DIR)
- # Goal to download raylib binary from Github
- fetch-raylib:
- @echo "Downloading Raylib from GitHub..."
- @mkdir -p external/raylib
- @cd external && \
- if [ "$$(uname -s)" = "Linux" ]; then \
- if [ "$$(uname -m)" = "x86_64" ]; then \
- wget https://github.com/raysan5/raylib/releases/download/5.5/raylib-5.5_linux_amd64.tar.gz && \
- tar -xzf raylib-5.5_linux_amd64.tar.gz && mv raylib-5.5_linux_amd64/lib/libraylib.a raylib/ && rm -rf raylib-5.5_linux_amd64 raylib-5.5_linux_amd64.tar.gz; \
- else \
- wget https://github.com/raysan5/raylib/releases/download/5.5/raylib-5.5_linux_i386.tar.gz && \
- tar -xzf raylib-5.5_linux_i386.tar.gz && mv raylib-5.5_linux_i386/lib/libraylib.a raylib/ && rm -rf raylib-5.5_linux_i386 raylib-5.5_linux_i386.tar.gz; \
- fi \
- else \
- if [ "$$(uname -s)" = "Darwin" ]; then \
- wget https://github.com/raysan5/raylib/releases/download/5.5/raylib-5.5_macos.tar.gz && \
- tar -xzf raylib-5.5_macos.tar.gz && mv raylib-5.5_macos/lib/libraylib.a raylib/ && rm -rf raylib-5.5_macos raylib-5.5_macos.tar.gz; \
- else \
- echo "Unsupported OS"; exit 1; \
- fi \
- fi
- # Link object files to create executable
- $(TARGET): $(OBJECTS) | $(RAYLIB_LIB) $(OBJ_DIR)
- $(CC) $(OBJECTS) -o $@ $(LDFLAGS)
- # Compile C source files
- $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
- $(CC) $(CFLAGS) -c $< -o $@
- # Create object directory if it doesn't exist
- $(OBJ_DIR):
- mkdir -p $(OBJ_DIR)
- run: $(TARGET)
- ./$(TARGET)
- # Clean up
- clean:
- rm -rf $(OBJ_DIR) $(TARGET)
- $(MAKE) -C $(RAYLIB_SRC_DIR) clean
- rm -f $(RAYLIB_LIB)
- # Phony targets
- .PHONY: all clean run raylib
|