#
#  PCC II Build Script Source
#
#  The Makefiles used to build PCC II are generated from the files in this
#  directory using a Perl script "proj9" (meaning that this is the ninth
#  revision; many previous versions were generated by "proj6"). The idea is
#  to have a constant set of rules (the .mak files) which can be applied to
#  many projects (the .pr) files to generate Makefiles that require only
#  minimum intelligence, and are still human-readable (so you can fix
#  problems with the build even if you don't have the Makefile generator).
#
#  The Generator effectively takes all these files, adds a few variables
#  and instantiates top-level rules (linking, archiving), and outputs them
#  to a Makefile in a semi-sorted fashion. As of 05/Jul/2007, proj9 is
#  usable enough to manage PCC II, and I'm optimistic it won't need yet
#  another rewrite. It's still missing a little chrome, though (the
#  generated files don't contain any comments, for example).
#

GENERATE = Makefile Makefile.min Makefile.vc8

INCLUDE_Makefile     = Rules-unix.mak  Settings-unix
INCLUDE_Makefile.min = Rules-mingw.mak Settings-mingw
INCLUDE_Makefile.vc8 = Rules-vc8.mak   Settings-vc8

include acdefs.mak

# Set default options, and forward flags from autoconf.
CXXFLAGS      = -I. -Icpluslib $(AC_CXXFLAGS) $(MY_CFLAGS)
LIBS          = $(AC_LIBS)
LIBDEPEND     =
LDFLAGS       = $(AC_LDFLAGS)
MAIN_VARS    += CXXFLAGS LIBS LIBDEPEND LDFLAGS

# Now some additional rules we want to see:
.PHONY: tags
tags:
	ctags -R .

# Automatically pick things to build. This prevents the makefile generator
# from making its own 'all' rule.
.PHONY: all all-sdl-yes all-sdl-no
all: all-sdl-$(HAVE_SDL)
all-sdl-yes: all-sdl-no $(OUTPUT_$(PROJECTS_sdlapp))
all-sdl-no: $(OUTPUT_$(PROJECTS_app))
MAIN_TARGETS += all all-sdl-yes all-sdl-no

game/struct.h game/struct.cc: game/struct.in scripts/iogen.pl
	$(PERL) scripts/iogen.pl game/struct

game/utildata.h game/utildata.cc: game/utildata.in scripts/iogen.pl
	$(PERL) scripts/iogen.pl game/utildata

# Dependencies. Do NOT use CXXFLAGS; that one will probably include
# system header directories (from SDL).
depend depend.mak:
	$(PERL) scripts/depend.pl -q -e'$$(OBJEXT)' -I. -Icpluslib -autoscan=. -makefile=Makefile >depend.mak

# Include dependencies. Placing it here means the Generator will place it
# below a rule in output.
include depend.mak

# "sdlapp" project type. This is still quite ugly, see also
# Settings-windows. Normally, we would arrange for linking with -lSDL etc. 
# here, but currently that is set up by configure.
begin sdlapp
PARENT = app
end
