2006-04-13 02:01:40 +00:00
|
|
|
# created on 4/12/2006 by James Bentler
|
2006-06-06 21:39:08 +00:00
|
|
|
|
|
|
|
# RH says: Might I suggest using -MMD instead of -MM? You can create the
|
|
|
|
# .o files and the .d files in the same step and avoid rerunning make.
|
|
|
|
# I'd do it myself, but I don't want to break anything without testing
|
|
|
|
# it first.
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
CXX ?= g++
|
2006-04-13 22:35:56 +00:00
|
|
|
CC ?= gcc
|
2006-05-09 21:30:31 +00:00
|
|
|
NASM ?= nasm
|
2006-06-05 07:56:30 +00:00
|
|
|
ifdef DEBUG
|
|
|
|
CFLAGS ?= -pipe -Wall -Wno-unused
|
2006-04-21 16:32:49 +00:00
|
|
|
else
|
2006-06-05 07:56:30 +00:00
|
|
|
CFLAGS ?= -pipe -Wall -Wno-unused -O2 -fomit-frame-pointer -fno-rtti
|
|
|
|
endif
|
|
|
|
ifdef GC
|
|
|
|
CFLAGS += -ffunction-sections
|
|
|
|
LDFLAGS += -Wl,--gc-sections
|
2006-04-21 16:32:49 +00:00
|
|
|
endif
|
2006-04-13 22:35:56 +00:00
|
|
|
CFLAGS += -DHAVE_FILELENGTH -D__forceinline=inline -Izlib -IFLAC `sdl-config --cflags`
|
2006-04-17 13:53:34 +00:00
|
|
|
CFLAGS += -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNEED_STRUPR
|
2006-04-13 02:01:40 +00:00
|
|
|
LDFLAGS += -lFLAC++ -lFLAC -lz -lfmod `sdl-config --libs`
|
|
|
|
NASMFLAGS += -f elf -DM_TARGET_LINUX
|
|
|
|
|
|
|
|
SRCDIRS = src/ $(addprefix src/,g_doom/ g_heretic/ g_hexen/ g_raven/ g_shared/ g_strife/ oplsynth/ sound/ sdl/)
|
|
|
|
INCLUDES = $(addprefix -I,$(SRCDIRS))
|
2006-04-13 22:35:56 +00:00
|
|
|
CFLAGS += $(INCLUDES)
|
2006-04-13 02:01:40 +00:00
|
|
|
|
|
|
|
RELEASEOBJ ?= releaseobj
|
|
|
|
DEBUGOBJ ?= debugobj
|
|
|
|
|
2006-04-13 22:35:56 +00:00
|
|
|
CPPSRCS = $(wildcard $(addsuffix *.cpp,$(SRCDIRS)))
|
|
|
|
CSRCS = $(wildcard $(addsuffix *.c,$(SRCDIRS)))
|
2006-06-05 07:56:30 +00:00
|
|
|
ifdef NOASM
|
|
|
|
CFLAGS += -DNOASM
|
|
|
|
else
|
2006-04-20 14:21:27 +00:00
|
|
|
ASRCS = $(wildcard src/*.nas)
|
|
|
|
CFLAGS += -DUSEASM=1
|
2006-04-13 22:35:56 +00:00
|
|
|
endif
|
|
|
|
SRCS = $(CSRCS) $(CPPSRCS) $(ASRCS)
|
|
|
|
CPPOBJFILES = $(notdir $(patsubst %.cpp,%.o,$(CPPSRCS)))
|
|
|
|
COBJFILES = $(notdir $(patsubst %.c,%.o,$(CSRCS)))
|
2006-04-13 02:01:40 +00:00
|
|
|
AOBJFILES = $(notdir $(patsubst %.nas,%.o,$(ASRCS)))
|
|
|
|
|
|
|
|
ZDOOM = zdoom
|
|
|
|
ZDOOMDEBUG = zdoomd
|
|
|
|
|
2006-06-05 07:56:30 +00:00
|
|
|
ifdef DEBUG
|
2006-04-13 02:01:40 +00:00
|
|
|
OBJDIR = $(DEBUGOBJ)
|
2006-04-13 22:35:56 +00:00
|
|
|
CFLAGS += -D_DEBUG -g3
|
2006-05-09 21:30:31 +00:00
|
|
|
NASMFLAGS += -g
|
2006-04-13 02:01:40 +00:00
|
|
|
ZDOOMBIN = $(ZDOOMDEBUG)
|
2006-06-05 07:56:30 +00:00
|
|
|
else
|
|
|
|
OBJDIR = $(RELEASEOBJ)
|
|
|
|
CFLAGS += -DNDEBUG
|
|
|
|
LDFLAGS += -s -Wl,-Map=$(ZDOOM).map
|
|
|
|
ZDOOMBIN = $(ZDOOM)
|
2006-04-13 02:01:40 +00:00
|
|
|
endif
|
2006-04-13 22:35:56 +00:00
|
|
|
CXXFLAGS += $(CFLAGS)
|
2006-04-13 02:01:40 +00:00
|
|
|
|
2006-04-17 13:53:34 +00:00
|
|
|
COBJS = $(addprefix $(OBJDIR)/,$(CPPOBJFILES) $(COBJFILES))
|
|
|
|
DEPS = $(patsubst %.o,%.d,$(COBJS))
|
|
|
|
OBJS = $(addprefix $(OBJDIR)/,$(AOBJFILES)) $(COBJS)
|
|
|
|
|
|
|
|
# controls whether to start another instance of make at deps
|
|
|
|
RESTART?=1
|
2006-04-13 02:01:40 +00:00
|
|
|
|
|
|
|
# rule pattern for dependencies
|
|
|
|
define DEPBUILD_PATTERN
|
|
|
|
_dep_: _src_
|
2006-04-20 14:21:27 +00:00
|
|
|
$(CXX) _src_ -MM $(CXXFLAGS) -MT "$$(patsubst %.d,%.o,_dep_) _dep_" -MF _dep_
|
2006-04-13 02:01:40 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# rule pattern for assembly files
|
|
|
|
define ASMBUILD_PATTERN
|
|
|
|
_obj_: _src_
|
2006-04-20 14:21:27 +00:00
|
|
|
$(NASM) -o _obj_ $(NASMFLAGS) _src_
|
2006-04-13 22:35:56 +00:00
|
|
|
endef
|
2006-04-13 02:01:40 +00:00
|
|
|
|
2006-04-13 22:35:56 +00:00
|
|
|
define CBUILD_PATTERN
|
|
|
|
_obj_: _src_
|
2006-04-20 14:21:27 +00:00
|
|
|
$(CC) -c $(CFLAGS) -o _obj_ -c _src_
|
2006-04-13 02:01:40 +00:00
|
|
|
endef
|
|
|
|
|
2006-05-09 21:30:31 +00:00
|
|
|
all: $(ZDOOMBIN) toolsandpk3 zdoom.pk3
|
2006-04-13 02:01:40 +00:00
|
|
|
|
2006-04-20 14:21:27 +00:00
|
|
|
$(ZDOOMBIN): $(OBJDIR) $(if $(RESTART),deps) $(OBJS)
|
|
|
|
ifndef RESTART
|
|
|
|
$(CXX) $(LDFLAGS) $(OBJDIR)/autostart.o \
|
|
|
|
$(filter-out %/autostart.o %/autozend.o,$(OBJS)) \
|
|
|
|
$(OBJDIR)/autozend.o -o $(ZDOOMBIN)
|
|
|
|
endif
|
2006-04-17 13:53:34 +00:00
|
|
|
|
2006-05-24 20:25:02 +00:00
|
|
|
# include any of the dep files that already exist if we aren't making clean
|
|
|
|
$(if !$(findstring clean,$(MAKECMDGOALS)),$(foreach dep,$(DEPS),$(if $(wildcard $(dep)),$(eval include $(dep)))))
|
2006-04-13 22:35:56 +00:00
|
|
|
|
|
|
|
# textually substitute in the _dep_ and the _src_ it depends on to create rules
|
|
|
|
# for creating dependency files without any existing dependency files
|
|
|
|
$(foreach src,$(CPPSRCS) $(CSRCS), $(eval $(subst _src_,$(src),$(subst \
|
|
|
|
_dep_,$(OBJDIR)/$(patsubst %.c,%.d,$(patsubst %.cpp,%.d,$(notdir $$$(src)))),\
|
|
|
|
$(DEPBUILD_PATTERN)))))
|
2006-04-13 02:01:40 +00:00
|
|
|
|
|
|
|
# textually substitute in the _obj_ and the _src_ it depends on to create rules
|
|
|
|
$(foreach src,$(ASRCS), $(eval $(subst _src_,$(src),$(subst \
|
|
|
|
_obj_,$(OBJDIR)/$(patsubst %.nas,%.o,$(notdir $$$(src))),$(ASMBUILD_PATTERN)))))
|
|
|
|
|
2006-04-13 22:35:56 +00:00
|
|
|
# textually substitute in the _obj_ and the _src_ it depends on to create rules
|
2006-04-13 02:01:40 +00:00
|
|
|
$(foreach src,$(CSRCS), $(eval $(subst _src_,$(src),$(subst \
|
2006-04-13 22:35:56 +00:00
|
|
|
_obj_,$(OBJDIR)/$(patsubst %.c,%.o,$(notdir $$$(src))),$(CBUILD_PATTERN)))))
|
2006-04-13 02:01:40 +00:00
|
|
|
|
|
|
|
$(OBJDIR)/%.o:
|
2006-04-20 14:21:27 +00:00
|
|
|
$(CXX) -c $(CXXFLAGS) -o $@ -c $<
|
2006-04-13 02:01:40 +00:00
|
|
|
|
2006-06-06 21:39:08 +00:00
|
|
|
# Hi, you Linux people. This works with Makefile.mingw, so i assume it works here too.
|
|
|
|
# This file needs special handling so that it actually gets compiled with SSE2 support.
|
2006-06-07 20:53:40 +00:00
|
|
|
$(OBJDIR)/nodebuild_classify_sse2.o: src/nodebuild_classify_sse2.cpp
|
2006-06-06 21:39:08 +00:00
|
|
|
$(CXX) $(CXXFLAGS) -msse2 -mfpmath=sse -c -o $@ $<
|
|
|
|
|
2006-04-17 13:53:34 +00:00
|
|
|
# start a new instance of make after dependency files have been made
|
|
|
|
deps: $(DEPS)
|
2006-04-20 14:21:27 +00:00
|
|
|
ifdef RESTART
|
|
|
|
@make -f $(firstword $(MAKEFILE_LIST)) RESTART=
|
|
|
|
endif
|
2006-04-13 02:01:40 +00:00
|
|
|
|
|
|
|
$(OBJDIR):
|
2006-04-20 14:21:27 +00:00
|
|
|
mkdir $(OBJDIR)
|
2006-04-13 02:01:40 +00:00
|
|
|
|
2006-05-09 21:30:31 +00:00
|
|
|
toolsandpk3: tools/makewad/makewad tools/dehsupp/dehsupp tools/xlatcc/xlatcc
|
|
|
|
make -C wadsrc/
|
|
|
|
|
|
|
|
zdoom.pk3: toolsandpk3
|
|
|
|
ln -sf wadsrc/zdoom.pk3 ./
|
|
|
|
|
|
|
|
tools/makewad/makewad:
|
|
|
|
make -C tools/makewad/
|
|
|
|
|
|
|
|
tools/dehsupp/dehsupp:
|
|
|
|
make -C tools/dehsupp/
|
|
|
|
|
|
|
|
tools/xlatcc/xlatcc:
|
|
|
|
make -C tools/xlatcc/
|
2006-04-17 13:53:34 +00:00
|
|
|
|
2006-05-09 21:30:31 +00:00
|
|
|
.PHONY : clean cleandeps cleanobjs distclean deps toolsandpk3
|
2006-04-13 02:01:40 +00:00
|
|
|
|
2006-04-17 13:53:34 +00:00
|
|
|
clean: cleanobjs
|
2006-04-20 14:21:27 +00:00
|
|
|
rm -f $(ZDOOMDEBUG) $(ZDOOM) $(ZDOOM).map
|
2006-04-13 02:01:40 +00:00
|
|
|
|
2006-04-21 16:32:49 +00:00
|
|
|
cleandebug:
|
|
|
|
rm -f $(ZDOOMDEBUG) $(DEBUGOBJ)/*.o $(DEBUGOBJ)/*.d
|
|
|
|
-rmdir $(DEBUGOBJ)
|
|
|
|
|
|
|
|
cleanrelease:
|
|
|
|
rm -f $(ZDOOM) $(ZDOOM).map $(RELEASEOBJ)/*.o $(RELEASEOBJ)/*.o
|
|
|
|
-rmdir $(RELEASEOBJ)
|
|
|
|
|
2006-04-17 13:53:34 +00:00
|
|
|
# I could use a recursive delete instead, but that could be dangerous...
|
|
|
|
distclean: clean cleandeps
|
2006-04-21 16:32:49 +00:00
|
|
|
-rmdir $(RELEASEOBJ) $(DEBUGOBJ)
|
2006-04-13 02:01:40 +00:00
|
|
|
|
|
|
|
cleandeps:
|
2006-04-20 14:21:27 +00:00
|
|
|
rm -f $(RELEASEOBJ)/*.d $(DEBUGOBJ)/*.d
|
2006-04-13 02:01:40 +00:00
|
|
|
|
|
|
|
cleanobjs:
|
2006-04-20 14:21:27 +00:00
|
|
|
rm -f $(RELEASEOBJ)/*.o $(DEBUGOBJ)/*.o
|
|
|
|
|