mirror of
https://github.com/yquake2/xatrix.git
synced 2024-11-12 23:54:30 +00:00
Modernize the Makefile and port it to Windows
This commit is contained in:
parent
68d43b4bc5
commit
b94269cbdb
2 changed files with 69 additions and 23 deletions
90
Makefile
90
Makefile
|
@ -2,7 +2,7 @@
|
||||||
# Makefile for the xatrix game module for Quake II #
|
# Makefile for the xatrix game module for Quake II #
|
||||||
# #
|
# #
|
||||||
# Just type "make" to compile the #
|
# Just type "make" to compile the #
|
||||||
# - The Reckoning Game (game.so) #
|
# - The Reckoning Game (game.so / game.dll) #
|
||||||
# #
|
# #
|
||||||
# Dependencies: #
|
# Dependencies: #
|
||||||
# - None, but you need a Quake II to play. #
|
# - None, but you need a Quake II to play. #
|
||||||
|
@ -10,28 +10,32 @@
|
||||||
# Yamagi Quake II ist recommended. #
|
# Yamagi Quake II ist recommended. #
|
||||||
# #
|
# #
|
||||||
# Platforms: #
|
# Platforms: #
|
||||||
# - Linux #
|
|
||||||
# - FreeBSD #
|
# - FreeBSD #
|
||||||
|
# - Linux #
|
||||||
|
# - Windows #
|
||||||
# ----------------------------------------------------- #
|
# ----------------------------------------------------- #
|
||||||
|
|
||||||
# Check the OS type
|
# Detect the OS
|
||||||
|
ifdef SystemRoot
|
||||||
|
OSTYPE := Windows
|
||||||
|
else
|
||||||
OSTYPE := $(shell uname -s)
|
OSTYPE := $(shell uname -s)
|
||||||
|
endif
|
||||||
|
|
||||||
# Some plattforms call it "amd64" and some "x86_64"
|
# Detect the architecture
|
||||||
|
ifeq ($(OSTYPE), Windows)
|
||||||
|
# At this time only i386 is supported on Windows
|
||||||
|
ARCH := i386
|
||||||
|
else
|
||||||
|
# Some platforms call it "amd64" and some "x86_64"
|
||||||
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
|
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
|
||||||
|
endif
|
||||||
|
|
||||||
# Refuse all other plattforms as a firewall against PEBKAC
|
# Refuse all other platforms as a firewall against PEBKAC
|
||||||
# (You'll need some #ifdef for your unsupported plattform!)
|
# (You'll need some #ifdef for your unsupported plattform!)
|
||||||
ifneq ($(ARCH),i386)
|
ifeq ($(findstring $(ARCH), i386 x86_64 sparc64),)
|
||||||
ifneq ($(ARCH),x86_64)
|
|
||||||
$(error arch $(ARCH) is currently not supported)
|
$(error arch $(ARCH) is currently not supported)
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
# ----------
|
|
||||||
|
|
||||||
# The compiler
|
|
||||||
#CC := gcc
|
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
@ -54,7 +58,7 @@ endif
|
||||||
#
|
#
|
||||||
# -MMD to generate header dependencies.
|
# -MMD to generate header dependencies.
|
||||||
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
||||||
-fPIC -Wall -pipe -g -MMD
|
-Wall -pipe -g -MMD
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
@ -68,23 +72,59 @@ all: xatrix
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
# When make is invoked by "make VERBOSE=1" print
|
||||||
|
# the compiler and linker commands.
|
||||||
|
|
||||||
|
ifdef VERBOSE
|
||||||
|
Q :=
|
||||||
|
else
|
||||||
|
Q := @
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
# Phony targets
|
||||||
|
.PHONY : all clean xatrix
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
ifeq ($(OSTYPE), Windows)
|
||||||
clean:
|
clean:
|
||||||
@echo "===> CLEAN"
|
@echo "===> CLEAN"
|
||||||
@rm -Rf build release
|
@-rmdir /S /Q release build
|
||||||
|
else
|
||||||
|
clean:
|
||||||
|
@echo "===> CLEAN"
|
||||||
|
${Q}rm -Rf build release
|
||||||
|
endif
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
# The xatrix game
|
# The xatrix game
|
||||||
|
ifeq ($(OSTYPE), Windows)
|
||||||
xatrix:
|
xatrix:
|
||||||
@echo '===> Building game.so'
|
@echo "===> Building game.dll"
|
||||||
@mkdir -p release/
|
${Q}tools/mkdir.exe -p release
|
||||||
|
${MAKE} release/game.dll
|
||||||
|
|
||||||
|
build/%.o: %.c
|
||||||
|
@echo "===> CC $<"
|
||||||
|
${Q}tools/mkdir.exe -p $(@D)
|
||||||
|
${Q}$(CC) -c $(CFLAGS) -o $@ $<
|
||||||
|
else
|
||||||
|
xatrix:
|
||||||
|
@echo "===> Building game.so"
|
||||||
|
${Q}mkdir -p release
|
||||||
$(MAKE) release/game.so
|
$(MAKE) release/game.so
|
||||||
|
|
||||||
build/%.o: %.c
|
build/%.o: %.c
|
||||||
@echo '===> CC $<'
|
@echo "===> CC $<"
|
||||||
@mkdir -p $(@D)
|
${Q}mkdir -p $(@D)
|
||||||
@$(CC) -c $(CFLAGS) -o $@ $<
|
${Q}$(CC) -c $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
release/game.so : CFLAGS += -fPIC
|
||||||
|
endif
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
@ -160,8 +200,14 @@ XATRIX_DEPS= $(XATRIX_OBJS:.o=.d)
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
ifeq ($(OSTYPE), Windows)
|
||||||
|
release/game.dll : $(XATRIX_OBJS)
|
||||||
|
@echo "===> LD $@"
|
||||||
|
${Q}$(CC) $(LDFLAGS) -o $@ $(XATRIX_OBJS)
|
||||||
|
else
|
||||||
release/game.so : $(XATRIX_OBJS)
|
release/game.so : $(XATRIX_OBJS)
|
||||||
@echo '===> LD $@'
|
@echo "===> LD $@"
|
||||||
@$(CC) $(LDFLAGS) -o $@ $(XATRIX_OBJS)
|
${Q}$(CC) $(LDFLAGS) -o $@ $(XATRIX_OBJS)
|
||||||
|
endif
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
BIN
tools/mkdir.exe
Normal file
BIN
tools/mkdir.exe
Normal file
Binary file not shown.
Loading…
Reference in a new issue