forked from rebecca/BSX
Makefile made more generic
Uses pkg-config to source locations of libSDL. As commented in Makefile, *may* cause issues with builds on Mac, but there are known Mac-isms to make this work. Also needs the math library for round() as referenced by video.o This causes builds to start working on Ubuntu 24.04 with the default SDL2 libraries installed using apt. Arch is known to need pkg-config to use SDL libs too, but I'm not sitting at my arch machine at the moment, so no idea if this is complete for that platform. A meta-build system *may* be a good idea?
This commit is contained in:
parent
cafbf52f2f
commit
e03ceb1871
14
Makefile
14
Makefile
|
@ -1,18 +1,24 @@
|
||||||
# Variables
|
# Variables
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra -std=c11 -I/usr/local/include/SDL2
|
# Probably this won't work on a mac using xcode.
|
||||||
LDFLAGS = -L/usr/local/lib -lSDL2
|
# 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
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
SOURCES = $(wildcard $(SRC_DIR)/*.c)
|
SOURCES = $(wildcard $(SRC_DIR)/*.c)
|
||||||
OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=%.o)
|
OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=%.o)
|
||||||
TARGET = bsx
|
TARGET = bsx
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: $(TARGET)
|
all: $(TARGET) Makefile
|
||||||
|
|
||||||
# Linking
|
# Linking
|
||||||
$(TARGET): $(OBJECTS)
|
$(TARGET): $(OBJECTS)
|
||||||
$(CC) $(LDFLAGS) -o $@ $^
|
$(CC) -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
# Compiling
|
# Compiling
|
||||||
%.o: $(SRC_DIR)/%.c
|
%.o: $(SRC_DIR)/%.c
|
||||||
|
|
Loading…
Reference in New Issue