2024-07-23 02:48:34 +02:00
|
|
|
# Variables
|
|
|
|
CC = gcc
|
2024-07-24 13:53:53 +02:00
|
|
|
# Probably this won't work on a mac using xcode.
|
|
|
|
# See https://stackoverflow.com/questions/3071321/how-to-use-pkg-config-for-setting-include-paths-in-xcode
|
|
|
|
# for possible workarounds?
|
|
|
|
# != is a GNU make extension, so may also not work on *BSD
|
|
|
|
SDL_CFLAGS!=pkg-config --cflags sdl2
|
|
|
|
SDL_LFLAGS!=pkg-config --libs sdl2
|
|
|
|
CFLAGS = -Wall -Wextra -std=c11 $(SDL_CFLAGS)
|
|
|
|
LDFLAGS = $(SDL_LFLAGS) -lm
|
2024-07-23 02:48:34 +02:00
|
|
|
SRC_DIR = src
|
|
|
|
SOURCES = $(wildcard $(SRC_DIR)/*.c)
|
|
|
|
OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=%.o)
|
|
|
|
TARGET = bsx
|
|
|
|
|
|
|
|
# Default target
|
2024-07-24 13:53:53 +02:00
|
|
|
all: $(TARGET) Makefile
|
2024-07-23 02:48:34 +02:00
|
|
|
|
|
|
|
# Linking
|
|
|
|
$(TARGET): $(OBJECTS)
|
2024-07-24 13:53:53 +02:00
|
|
|
$(CC) -o $@ $^ $(LDFLAGS)
|
2024-07-23 02:48:34 +02:00
|
|
|
|
|
|
|
# Compiling
|
|
|
|
%.o: $(SRC_DIR)/%.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
clean:
|
|
|
|
rm -f $(OBJECTS) $(TARGET)
|
|
|
|
|
|
|
|
# Phony targets
|
|
|
|
.PHONY: all clean
|