maptools/Makefile

277 lines
6.1 KiB
Makefile
Raw Permalink Normal View History

2012-02-02 12:33:08 +00:00
# ------------------------------------------------------ #
# Makefile for the "Quake II Map Tools" #
# #
# Just type "make" to compile the #
# - bspinfo #
# - qbsp3 #
# - qdata #
# - qrad3 #
# - qvis3 #
# #
# Platforms: #
# - Linux #
# - FreeBSD #
# ------------------------------------------------------ #
2012-02-02 11:32:51 +00:00
# Check the OS type
OSTYPE := $(shell uname -s)
# Some plattforms call it "amd64" and some "x86_64"
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
# Refuse all other plattforms as a firewall against PEBKAC
# (You'll need some #ifdef for your unsupported plattform!)
ifneq ($(ARCH),i386)
ifneq ($(ARCH),x86_64)
$(error arch $(ARCH) is currently not supported)
endif
endif
# ----------
# Base CFLAGS.
#
# -O2 are enough optimizations.
#
# -fno-strict-aliasing since the source doesn't comply
# with strict aliasing rules and it's next to impossible
# to get it there...
#
# -fomit-frame-pointer since the framepointer is mostly
# useless for debugging Quake II and slows things down.
#
# -g to build allways with debug symbols. Please do not
# change this, since it's our only chance to debug this
# crap when random crashes happen!
#
# -MMD to generate header dependencies.
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -MMD
# ----------
# Base include path.
ifeq ($(OSTYPE),Linux)
INCLUDE := -I./src/common
2012-02-02 11:32:51 +00:00
else ifeq ($(OSTYPE),FreeBSD)
INCLUDE := -I./src/common
2012-02-02 11:32:51 +00:00
endif
# ----------
# Base LDFLAGS.
ifeq ($(OSTYPE),Linux)
LDFLAGS := -L/usr/lib -lm
else ifeq ($(OSTYPE),FreeBSD)
LDFLAGS := -L/usr/local/lib -lm
endif
# ----------
2012-02-02 11:32:51 +00:00
# When make is invoked by "make VERBOSE=1" print
# the compiler and linker commands.
ifdef VERBOSE
Q :=
else
Q := @
endif
# ----------
# Builds everything
2012-02-02 12:29:15 +00:00
all: bspinfo qbsp3 qdata qrad3 qvis3
2012-02-02 11:32:51 +00:00
# ----------
# Cleanup
clean:
@echo "===> CLEAN"
${Q}rm -Rf build release
# ----------
2012-02-02 12:33:08 +00:00
# common stuff
build/common/%.o: %.c
2012-02-02 11:32:51 +00:00
@echo '===> CC $<'
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
2012-02-02 12:33:08 +00:00
2012-02-02 11:32:51 +00:00
# ----------
2012-02-02 12:33:08 +00:00
2012-02-02 11:54:03 +00:00
# bspinfo
bspinfo:
@echo '===> Building bspinfo'
${Q}mkdir -p release
$(MAKE) release/bspinfo
build/bspinfo/%.o: %.c
@echo '===> CC $<'
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
# ----------
2012-02-02 12:29:15 +00:00
# qbsp3
qbsp3:
@echo '===> Building qbsp3'
${Q}mkdir -p release
$(MAKE) release/qbsp3
build/qbsp3/%.o: %.c
@echo '===> CC $<'
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
# ----------
2012-02-02 12:33:08 +00:00
# qdata
qdata:
@echo '===> Building qdata'
${Q}mkdir -p release
$(MAKE) release/qdata
build/qdata/%.o: %.c
@echo '===> CC $<'
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
2012-02-02 12:29:15 +00:00
2012-02-02 12:33:08 +00:00
# ----------
2012-02-02 12:29:15 +00:00
# qrad3
qrad3:
@echo '===> Building qrad3'
${Q}mkdir -p release
$(MAKE) release/qrad3
build/qrad3/%.o: %.c
@echo '===> CC $<'
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
# ----------
# qvis3
qvis3:
@echo '===> Building qvis3'
${Q}mkdir -p release
$(MAKE) release/qvis3
build/qvis3/%.o: %.c
@echo '===> CC $<'
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
# ----------
# Common objects
COMMON_OBJS_ = \
src/common/bspfile.o \
src/common/cmdlib.o \
src/common/l3dslib.o \
src/common/lbmlib.o \
src/common/mathlib.o \
src/common/mdfour.o \
src/common/polylib.o \
src/common/scriplib.o \
src/common/threads.o \
src/common/trilib.o
2012-02-02 11:54:03 +00:00
# Used by bspinfo
BSPINFO_OBJS_ = \
src/bspinfo/bspinfo.o
2012-02-02 12:29:15 +00:00
# Used by qbsp3
QBSP_OBJS_ = \
src/qbsp3/brushbsp.o \
src/qbsp3/csg.o \
src/qbsp3/faces.o \
src/qbsp3/glfile.o \
src/qbsp3/leakfile.o \
src/qbsp3/map.o \
src/qbsp3/nodraw.o \
src/qbsp3/portals.o \
src/qbsp3/prtfile.o \
src/qbsp3/qbsp3.o \
src/qbsp3/textures.o \
src/qbsp3/tree.o \
src/qbsp3/writebsp.o
2012-02-02 12:33:08 +00:00
# Used by qdata
QDATA_OBJS_ = \
src/qdata/images.o \
src/qdata/models.o \
src/qdata/qdata.o \
src/qdata/sprites.o \
src/qdata/tables.o \
src/qdata/video.o
2012-02-02 12:29:15 +00:00
# Used by qrad3
QRAD_OBJS_ = \
src/qrad3/lightmap.o \
src/qrad3/patches.o \
src/qrad3/qrad3.o \
src/qrad3/trace.o
# Used by qvis3
QVIS_OBJS_ = \
src/qvis3/flow.o \
src/qvis3/qvis3.o
2012-02-02 11:32:51 +00:00
# ----------
# Rewrite pathes to our object directory
COMMON_OBJS = $(patsubst %,build/common/%,$(COMMON_OBJS_))
2012-02-02 12:29:15 +00:00
BSPINFO_OBJS = $(patsubst %,build/bspinfo/%,$(BSPINFO_OBJS_))
QBSP_OBJS = $(patsubst %,build/qbsp3/%,$(QBSP_OBJS_))
2012-02-02 12:33:08 +00:00
QDATA_OBJS = $(patsubst %,build/qdata/%,$(QDATA_OBJS_))
2012-02-02 12:29:15 +00:00
QRAD_OBJS = $(patsubst %,build/qrad3/%,$(QRAD_OBJS_))
QVIS_OBJS = $(patsubst %,build/qvis3/%,$(QVIS_OBJS_))
2012-02-02 11:32:51 +00:00
# ----------
# Generate header dependencies
COMMON_DEPS= $(COMMON_OBJS:.o=.d)
2012-02-02 11:54:03 +00:00
BSPINFO_DEPS= $(BSPINFO_OBJS:.o=.d)
2012-02-02 12:29:15 +00:00
QBSP_DEPS= $(QBSP_OBJS:.o=.d)
2012-02-02 12:33:08 +00:00
QDATA_DEPS= $(QDATA_OBJS:.o=.d)
2012-02-02 12:29:15 +00:00
QRAD_DEPS= $(QRAD_OBJS:.o=.d)
QVIS_DEPS= $(QVIS_OBJS:.o=.d)
2012-02-02 11:32:51 +00:00
# ----------
-include $(COMMON_DEPS)
2012-02-02 11:54:03 +00:00
-include $(BSPINFO_DEPS)
2012-02-02 12:29:15 +00:00
-include $(QBSP_DEPS)
2012-02-02 12:33:08 +00:00
-include $(QDATA_DEPS)
2012-02-02 12:29:15 +00:00
-include $(QRAD_DEPS)
-include $(QVIS_DEPS)
2012-02-02 11:32:51 +00:00
# ----------
2012-02-02 11:54:03 +00:00
# release/bspinfo
release/bspinfo : $(COMMON_OBJS) $(BSPINFO_OBJS)
@echo '===> LD $@'
${Q}$(CC) $(COMMON_OBJS) $(BSPINFO_OBJS) $(LDFLAGS) -o $@
2012-02-02 12:29:15 +00:00
# release/qbsp3
release/qbsp3 : $(COMMON_OBJS) $(QBSP_OBJS)
@echo '===> LD $@'
${Q}$(CC) $(COMMON_OBJS) $(QBSP_OBJS) $(LDFLAGS) -o $@
2012-02-02 12:33:08 +00:00
# release/qdata
release/qdata : $(COMMON_OBJS) $(QDATA_OBJS)
@echo '===> LD $@'
${Q}$(CC) $(COMMON_OBJS) $(QDATA_OBJS) $(LDFLAGS) -o $@
2012-02-02 12:29:15 +00:00
# release/qrad3
release/qrad3 : $(COMMON_OBJS) $(QRAD_OBJS)
@echo '===> LD $@'
${Q}$(CC) $(COMMON_OBJS) $(QRAD_OBJS) $(LDFLAGS) -o $@
# release/qvis3
release/qvis3 : $(COMMON_OBJS) $(QVIS_OBJS)
@echo '===> LD $@'
${Q}$(CC) $(COMMON_OBJS) $(QVIS_OBJS) $(LDFLAGS) -o $@