41 lines
1.5 KiB
Makefile
41 lines
1.5 KiB
Makefile
CC ?= gcc
|
|
CFLAGS ?= -O2 -Wall -Wextra -std=c11
|
|
PKGS = glfw3 glu
|
|
CPPFLAGS += $(shell pkg-config --cflags $(PKGS))
|
|
LDLIBS += $(shell pkg-config --libs $(PKGS)) -lGL -lm
|
|
|
|
TARGET = vectorgons
|
|
SRC = vectorgons.c
|
|
|
|
$(TARGET): $(SRC)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(SRC) $(LDLIBS)
|
|
|
|
run: $(TARGET)
|
|
./$(TARGET)
|
|
|
|
# --- Windows x64 cross-compile (MinGW-w64) ---------------------------------
|
|
# Produces a self-contained vectorgons.exe (statically links GLFW and the
|
|
# GCC/threads runtime; at run time it needs only Windows system DLLs:
|
|
# opengl32, glu32, gdi32, user32, shell32, kernel32). Override WINCC / GLFWDIR
|
|
# for your toolchain and GLFW (https://www.glfw.org/download, WIN64 binaries):
|
|
# make windows WINCC=x86_64-w64-mingw32-gcc GLFWDIR=/path/to/glfw-3.4.bin.WIN64
|
|
WINCC ?= x86_64-w64-mingw32-gcc
|
|
GLFWDIR ?= /tmp/glfw-3.4.bin.WIN64
|
|
WINFLAGS = -O2 -std=c11 -Wall -Wextra -mwindows -static -s
|
|
WINLIBS = -lglfw3 -lglu32 -lopengl32 -lgdi32 -luser32 -lshell32
|
|
|
|
windows: $(SRC)
|
|
$(WINCC) $(WINFLAGS) -I$(GLFWDIR)/include -o $(TARGET).exe $(SRC) \
|
|
-L$(GLFWDIR)/lib-mingw-w64 $(WINLIBS)
|
|
|
|
# Windows screensaver: same code with -DSCREENSAVER, output named .scr.
|
|
# Install by right-clicking the .scr in Windows -> Install (or drop it in
|
|
# C:\Windows\System32 and pick it in Settings > Lock screen > Screen saver).
|
|
screensaver: $(SRC)
|
|
$(WINCC) $(WINFLAGS) -DSCREENSAVER -I$(GLFWDIR)/include -o $(TARGET).scr $(SRC) \
|
|
-L$(GLFWDIR)/lib-mingw-w64 $(WINLIBS)
|
|
|
|
clean:
|
|
rm -f $(TARGET) $(TARGET).exe $(TARGET).scr
|
|
|
|
.PHONY: run windows screensaver clean
|