gzdoom/Makefile.linux
Christoph Oelckers 67bf668ad9 April 20, 2006 (Changes by Graf Zahl)
- Fixed: Strife's ending check included destroying the computer - an event
  that happens before the branch in the story.
- Fixed: The overloaded FRandom::Random2 function with mask parameter didn't
  use its parameter.
- Added Jim's latest makefile.linux


SVN r60 (trunk)
2006-04-21 16:32:49 +00:00

138 lines
3.9 KiB
Text

# created on 4/12/2006 by James Bentler
CXX ?= g++
CC ?= gcc
ifndef DEBUG
CFLAGS ?= -pipe -Wall -Wno-unused -O2 -fomit-frame-pointer
else
CFLAGS ?= -pipe -Wall -Wno-unused
endif
CFLAGS += -DHAVE_FILELENGTH -D__forceinline=inline -Izlib -IFLAC `sdl-config --cflags`
CFLAGS += -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNEED_STRUPR
LDFLAGS += -lFLAC++ -lFLAC -lz -lfmod `sdl-config --libs`
NASM ?= nasm
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))
CFLAGS += $(INCLUDES)
RELEASEOBJ ?= releaseobj
DEBUGOBJ ?= debugobj
CPPSRCS = $(wildcard $(addsuffix *.cpp,$(SRCDIRS)))
CSRCS = $(wildcard $(addsuffix *.c,$(SRCDIRS)))
ifndef NOASM
ASRCS = $(wildcard src/*.nas)
CFLAGS += -DUSEASM=1
else
CFLAGS += -DNOASM
endif
SRCS = $(CSRCS) $(CPPSRCS) $(ASRCS)
CPPOBJFILES = $(notdir $(patsubst %.cpp,%.o,$(CPPSRCS)))
COBJFILES = $(notdir $(patsubst %.c,%.o,$(CSRCS)))
AOBJFILES = $(notdir $(patsubst %.nas,%.o,$(ASRCS)))
ZDOOM = zdoom
ZDOOMDEBUG = zdoomd
ifndef DEBUG
OBJDIR = $(RELEASEOBJ)
CFLAGS += -DNDEBUG
LDFLAGS += -Wl,-Map=$(ZDOOM).map
ZDOOMBIN = $(ZDOOM)
else
OBJDIR = $(DEBUGOBJ)
CFLAGS += -D_DEBUG -g3
ZDOOMBIN = $(ZDOOMDEBUG)
endif
CXXFLAGS += $(CFLAGS)
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
# rule pattern for dependencies
define DEPBUILD_PATTERN
_dep_: _src_
$(CXX) _src_ -MM $(CXXFLAGS) -MT "$$(patsubst %.d,%.o,_dep_) _dep_" -MF _dep_
endef
# rule pattern for assembly files
define ASMBUILD_PATTERN
_obj_: _src_
$(NASM) -o _obj_ $(NASMFLAGS) _src_
endef
define CBUILD_PATTERN
_obj_: _src_
$(CC) -c $(CFLAGS) -o _obj_ -c _src_
endef
all: $(ZDOOMBIN) zdoom.wad
$(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
# include any of the dep files that already exist
$(foreach dep,$(DEPS),$(if $(wildcard $(dep)),$(eval include $(dep))))
# 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)))))
# 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)))))
# textually substitute in the _obj_ and the _src_ it depends on to create rules
$(foreach src,$(CSRCS), $(eval $(subst _src_,$(src),$(subst \
_obj_,$(OBJDIR)/$(patsubst %.c,%.o,$(notdir $$$(src))),$(CBUILD_PATTERN)))))
$(OBJDIR)/%.o:
$(CXX) -c $(CXXFLAGS) -o $@ -c $<
# start a new instance of make after dependency files have been made
deps: $(DEPS)
ifdef RESTART
@make -f $(firstword $(MAKEFILE_LIST)) RESTART=
endif
$(OBJDIR):
mkdir $(OBJDIR)
zdoom.wad:
make -C wadsrc/ -f Makefile
.PHONY : clean cleandeps cleanobjs distclean deps
clean: cleanobjs
rm -f $(ZDOOMDEBUG) $(ZDOOM) $(ZDOOM).map
cleandebug:
rm -f $(ZDOOMDEBUG) $(DEBUGOBJ)/*.o $(DEBUGOBJ)/*.d
-rmdir $(DEBUGOBJ)
cleanrelease:
rm -f $(ZDOOM) $(ZDOOM).map $(RELEASEOBJ)/*.o $(RELEASEOBJ)/*.o
-rmdir $(RELEASEOBJ)
# I could use a recursive delete instead, but that could be dangerous...
distclean: clean cleandeps
-rmdir $(RELEASEOBJ) $(DEBUGOBJ)
cleandeps:
rm -f $(RELEASEOBJ)/*.d $(DEBUGOBJ)/*.d
cleanobjs:
rm -f $(RELEASEOBJ)/*.o $(DEBUGOBJ)/*.o