#
# 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.sculptrix \
	o.bbox o.border o.colours o.config o.plot o.redraw o.slab \
	o.rules o.utils o.vString \
	o.messages

VERSION = 2.01

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

all: Sculptrix

Sculptrix: $(OBJS)
	$(SETDATE) \
		o.version \
		version="Sculptrix\t$(VERSION) ($(MODDATE)) $(CRIGHT)"
	$(LD_MOD) $(OBJS) o.version
	$(SET_MOD)

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

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

clean:
	-$(RM) o.* Sculptrix

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

# Dynamic dependencies:
o.sculptrix: s.sculptrix
o.sculptrix: libs:header
o.sculptrix: libs:swis
o.sculptrix: libs:stream
o.sculptrix: sh.bbox
o.sculptrix: sh.config
o.sculptrix: sh.plot
o.sculptrix: sh.redraw
o.sculptrix: sh.slab
o.sculptrix: sh.vString
o.sculptrix: sh.wSpace
o.sculptrix: sh.messages
o.bbox: s.bbox
o.bbox: libs:header
o.bbox: libs:swis
o.bbox: libs:stream
o.bbox: sh.vString
o.bbox: sh.wSpace
o.border: s.border
o.border: libs:header
o.border: libs:swis
o.border: libs:stream
o.border: sh.colours
o.border: sh.wSpace
o.border: sh.messages
o.colours: s.colours
o.colours: libs:header
o.colours: libs:swis
o.colours: libs:stream
o.colours: sh.vString
o.config: s.config
o.config: libs:header
o.config: libs:swis
o.config: libs:stream
o.config: sh.wSpace
o.config: sh.messages
o.plot: s.plot
o.plot: libs:header
o.plot: libs:swis
o.plot: libs:stream
o.plot: sh.border
o.plot: sh.rules
o.plot: sh.utils
o.plot: sh.vString
o.plot: sh.wSpace
o.redraw: s.redraw
o.redraw: libs:header
o.redraw: libs:swis
o.redraw: libs:stream
o.redraw: sh.plot
o.redraw: sh.vString
o.redraw: sh.wSpace
o.slab: s.slab
o.slab: libs:header
o.slab: libs:swis
o.slab: libs:stream
o.slab: sh.colours
o.slab: sh.plot
o.slab: sh.vString
o.slab: sh.wSpace
o.rules: s.rules
o.rules: libs:header
o.rules: libs:swis
o.rules: libs:stream
o.utils: s.utils
o.utils: libs:header
o.utils: libs:swis
o.utils: libs:stream
o.vString: s.vString
o.vString: libs:header
o.vString: libs:swis
o.vString: libs:stream
o.vString: sh.wSpace
