#
# Makefile
#
#  1998 Straylight/Edgeware
#

#----- Licensing note -------------------------------------------------------
#
# This makefile is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This makefile is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this makefile.  If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#----- Compilation flags ----------------------------------------------------

# --- Uncomment to use the C4 tools ---

# OLD = o-

# --- C compilation ---

CC = $(OLD)cc -c -o $@
CFLAGS = -depend !Depend -throwback -ffah -Ilibs: -IC:
COMPILE = $(CC) $(CFLAGS)

# --- Assembling ---

AS = $(OLD)objasm -quit -to $@
ASFLAGS = -stamp -depend !Depend -throwback
ASSEMBLE = $(AS) $(ASFLAGS) -from

BAS = basasm

# --- Linking ---

LD = $(OLD)link -o $@
LD_APP = $(LD) -aif
LD_UTIL = $(LD) -bin -base 0
LD_MOD = $(LD) -bin -base 0
LD_BIN = $(LD) -bin -base 0
LD_DLL = $(LD) -rmf
LD_AOF = $(LD) -aof

# --- Making libraries ---

AR = $(OLD)libfile -o

CDLL = cdll

# --- Setting file types ---

SET_APP = SetType $@ FF8
SET_MOD = SetType $@ FFA
SET_UTIL = SetType $@ FFC
SET_DLL = SetType $@ FFD

# --- Other maintenance things ---

RM = ssrclean
INSTALL = inst
SETDATE = setdate
SQUEEZE = squeeze $@
DATE = %zdy %mo %ce%yr
MODDATE = %dy %m3 %ce%yr
CRIGHT =  %ce%yr Straylight
FIXLINK = fixlink $@

#----- Default rules --------------------------------------------------------

.SUFFIXES: .o .c .s .bs
.c.o:
	$(COMPILE) $<
.s.o:
	$(ASSEMBLE) $<
.bs.o:
	$(BAS) $< $@

#----- Object files ---------------------------------------------------------

OBJS = \
	o.dynamite \
	o.dynAnchor o.dynArea o.dynHeap o.dynTask o.fastMove \
	o.messages

#----- Compiling things -----------------------------------------------------

all: Dynamite

Dynamite: $(OBJS)
	$(SETDATE) o.version version="Dynamite\t1.21 ($(MODDATE)) $(CRIGHT)"
	$(LD_MOD) $(OBJS) o.version
	$(SET_MOD)

o.messages: rsc.messages
	msgaof rsc.messages o.messages sh.messages

install: Dynamite
	$(INSTALL) Dynamite <SSR$ModDir>

clean:
	-$(RM) o.* Dynamite

#----- Dynamic dependencies -------------------------------------------------

# Dynamic dependencies:
o.dynAnchor: s.dynAnchor
o.dynAnchor: libs:header
o.dynAnchor: libs:swis
o.dynAnchor: sh.wSpace
o.dynArea: s.dynArea
o.dynArea: libs:header
o.dynArea: libs:swis
o.dynArea: libs:stream
o.dynArea: sh.wSpace
o.dynamite: s.dynamite
o.dynamite: libs:header
o.dynamite: libs:swis
o.dynamite: libs:stream
o.dynamite: sh.dynAnchor
o.dynamite: sh.dynArea
o.dynamite: sh.dynHeap
o.dynamite: sh.dynTask
o.dynamite: sh.wSpace
o.dynamite: sh.messages
o.dynHeap: s.dynHeap
o.dynHeap: libs:header
o.dynHeap: libs:swis
o.dynHeap: libs:stream
o.dynHeap: libs:sh.fastMove
o.dynHeap: sh.dynArea
o.dynHeap: sh.dynTask
o.dynHeap: sh.wSpace
o.dynHeap: sh.messages
o.dynTask: s.dynTask
o.dynTask: libs:header
o.dynTask: libs:swis
o.dynTask: libs:stream
o.dynTask: sh.dynHeap
o.dynTask: sh.wSpace
o.dynTask: sh.messages
o.fastMove: s.fastMove
o.fastMove: libs:s.fastMove
o.fastMove: libs:header
o.fastMove: libs:swis
