#
# 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.dheader \
	o.app o.dll o.misc o.suballoc \
	o.messages

VERSION = 1.14

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

all: DLLManager dllmdump

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

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

dllmdump: o.dllmdump
	$(LD_UTIL) o.dllmdump
	$(SET_UTIL)

install: DLLManager
	$(INSTALL) DLLManager <SSR$DLLDir>
	$(INSTALL) dllmdump <SSR$BinDir>

clean:
	-$(RM) o.* DLLManager

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

# Dynamic dependencies:
o.dheader: s.dheader
o.dheader: libs:header
o.dheader: libs:swis
o.dheader: sh.wSpace
o.dheader: sh.misc
o.dheader: sh.dll
o.dheader: sh.app
o.dheader: sh.suballoc
o.dheader: sh.messages
o.app: s.app
o.app: libs:header
o.app: libs:swis
o.app: libs:stream
o.app: sh.wSpace
o.app: sh.appblock
o.app: sh.linkblock
o.app: sh.dllblock
o.app: sh.misc
o.app: sh.suballoc
o.app: sh.dll
o.app: sh.messages
o.dll: s.dll
o.dll: libs:header
o.dll: libs:swis
o.dll: libs:stream
o.dll: sh.wSpace
o.dll: sh.dllblock
o.dll: sh.linkblock
o.dll: sh.misc
o.dll: sh.app
o.dll: sh.messages
o.misc: s.misc
o.misc: libs:header
o.misc: libs:swis
o.misc: sh.wSpace
o.misc: sh.messages
o.suballoc: s.suballoc
o.suballoc: libs:swis
o.suballoc: libs:header
o.suballoc: sh.wSpace
o.suballoc: sh.linkblock
o.dllmdump: s.dllmdump
o.dllmdump: libs:header
o.dllmdump: libs:swis
o.dllmdump: sh.dllblock
o.dllmdump: sh.appblock
o.dllmdump: sh.linkblock
o.dllmdump: sh.wspace
