# bzflag
# Copyright (c) 1993 - 2001 Tim Riker
#
# This package is free software;  you can redistribute it and/or
# modify it under the terms of the license found in the file
# named LICENSE that should have accompanied this file.
#
# THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

#
# bzflag common make definitions
#

#
# empty define, used to terminate lists
#
NULL =

#
# target directories
#
LIBDIR     = $(DEPTH)/lib
TARGETDIR  = $(DEPTH)/bin
PACKAGEDIR = $(DEPTH)/dist

#
# default install directories (configs can override these)
#
INSTALL_DATA_DIR = /usr/local/lib/bzflag

#
# C options
#
CFLAGS	= $(LCFLAGS) $(PCFLAGS) $(GCFLAGS) $(COPTIMIZER) $(MKDEPOPT) $(CWOFF)
LCFLAGS	= $(LCDEFS) $(LCINCS) $(LCOPTS)
PCFLAGS	= $(PCDEFS) $(PCINCS) $(PCOPTS)
GCFLAGS	= $(GCDEFS) $(GCINCS) $(GCOPTS)

GCOPTS	=
GCDEFS  =						\
	-DVERSION=$(VERSION)				\
	$(TIMEBOMB)					\
	$(DEBUG_RENDERING)				\
	$(ROBOTS)					\
	-DINSTALL_DATA_DIR=\"$(INSTALL_DATA_DIR)\"	\
	$(NULL)
GCINCS	= -I$(DEPTH)/include

#
# C++ options
#
CXXFLAGS  = $(LCXXFLAGS) $(PCXXFLAGS) $(GCXXFLAGS) $(CXXOPTIMIZER) $(MKDEPOPT) $(CXXWOFF)
LCXXFLAGS = $(LCXXDEFS) $(LCXXINCS) $(LCXXOPTS)
PCXXFLAGS = $(PCXXDEFS) $(PCXXINCS) $(PCXXOPTS)
GCXXFLAGS = $(GCXXDEFS) $(GCXXINCS) $(GCXXOPTS)

GCXXOPTS  =
GCXXDEFS  =						\
	-DVERSION=$(VERSION)				\
	$(TIMEBOMB)					\
	$(DEBUG_RENDERING)				\
	$(ROBOTS)					\
	-DINSTALL_DATA_DIR=\"$(INSTALL_DATA_DIR)\"	\
	$(NULL)
GCXXINCS  = -I$(DEPTH)/include

#
# ld options
#
LDFLAGS	  = $(LDOPTS) $(LDLIBS)
LDOPTS	  = $(LLDOPTS) $(PLDOPTS) $(GLDOPTS)
LDLIBS	  = $(LLDLIBS) $(PLDLIBS) $(GLDLIBS)

GLDLIBS	  =
GLDOPTS	  =

#
# ar options
#
ARF	= $(AR)

#
# Convenient command macros that include the flags macros.
#
CCF	= $(CC) $(CFLAGS)
CXXF	= $(CXX) $(CXXFLAGS)
LDF	= $(LD) $(LDFLAGS)


#
# Rule macros for nonterminal makefiles that iterate over subdirectories,
# making the current target.  Set SUBDIRS to the relevant list of kids.
#
# Set NOSUBMESG to any value to suppress a warning that subdirectories
# are not present.
#
SUBDIR_MAKERULE= \
	if test ! -d $$d; then \
		if test "$(NOSUBMESG)" = "" ; then \
			${ECHO} "SKIPPING $$d: No such directory."; \
		fi \
	else \
		${ECHO} "${CD} $$d; $(MAKE) $${RULE:=$@}"; \
		(${CD} $$d; ${MAKE} $${RULE:=$@}); \
	fi

SUBDIRS_MAKERULE= \
	@for d in $(SUBDIRS); do $(SUBDIR_MAKERULE); done

#
# default target.  makefiles must define a target named `targets'.
#
default: targets

#
# always unsatisfied target
#
_FORCE=$(COMMONPREF)_force


#
# Convenience file list macros:
#
SOURCES = $(HFILES) $(CXXFILES) $(CFILES)
OBJECTS = $(CXXFILES:.cxx=.o) $(CFILES:.c=.o)

#
# stuff to clean
#
DIRT  = $(_FORCE) $(PDIRT) $(GDIRT) $(LDIRT)
GDIRT =

#
#
# common rules
#
#

#
# always unsatisfied target
#
$(_FORCE):

#
# cleaners
#
COMMONTARGETS = clean clobber
$(COMMONPREF)clean: $(_FORCE)
	$(RM) $(DIRT)

$(COMMONPREF)clobber: clean $(_FORCE)
	$(RM) $(TARGETS)

#
# implicit target rules
#
.SUFFIXES: .c .cxx .o

.c.o:
	$(CCF) -c $<

.cxx.o:
	$(CXXF) -c $<

#
# default to optimized build
#
ifdef DEBUG
COPTIMIZER    = $(CDEBUG)
CXXOPTIMIZER  = $(CXXDEBUG)
else
COPTIMIZER    = $(COPT)
CXXOPTIMIZER  = $(CXXOPT)
endif

#
# slurp up configuration
#
include $(DEPTH)/config
include $(DEPTH)/config-sys

