#
# $Id$
#
# :ts=8
#

.c.o:
	sc $(CFLAGS) $<
#	 @ctags $< >tagfiles/$>.c

.a.o:
	asm $(AFLAGS) $<

.cd.h:
	catcomp $*.cd cfile $*.h nocode noblock

#############################################################################
#
# Program version and revision; automagically inserted in the bumprev
# revision file when "version" target is made
#
#############################################################################

VERSION = 2

#############################################################################

GSTFILE =	system_headers.gst
OPTIMIZE =	optimize opttime optinlocal optschedule optdepth=10 optrdepth=10
#CPU =		040
CPU =		any
DEBUG =		line
CFLAGS =	idlen=64 streq strmerge nostackcheck params=r \
		idir=include gst=$(GSTFILE) cpu=$(CPU) debug=$(DEBUG) $(OPTIMIZE)
AFLAGS =	-u
LFLAGS =	smallcode smalldata noicons
LIBS =		lib:sc.lib lib:amiga.lib lib:debug.lib

###############################################################################

MAIN_SOURCE = \
	main.c misc.c \
	data.c wedge.c windowglyphs.c memory.c menuboxes.c \
	dointuimenu.c sendintuimessage.c remap.a \
	storage.c

MAIN_OBJS = \
	main.o stubs.o misc.o \
	data.o wedge.o windowglyphs.o memory.o menuboxes.o \
	dointuimenu.o sendintuimessage.o remap.o \
	storage.o

###############################################################################

PREFS_SOURCE = \
	edit.c demoimagedata.c remap.a storage.c

PREFS_OBJS = \
	edit.o demoimagedata.o remap.o storage.o

###############################################################################

SOURCE = \
	data.c data.h defines.h \
	dointuimenu.c edit.c global.h magicmenu.cd \
	MagicMenuPrefs_rev.h MagicMenuPrefs_rev.i MagicMenuPrefs_rev.rev MagicMenu_rev.h \
	MagicMenu_rev.i MagicMenu_rev.rev main.c memory.c \
	menuboxes.c misc.c protos.h remap.a \
	sendintuimessage.c smakefile structures.h stubs.a \
	system_headers.c system_headers.h wedge.c windowglyphs.c \
	demoimagedata.c storage.c storage.h releasenotes MagicMenu.guide \
	Assert.c Assert.h

###############################################################################

all: $(GSTFILE) protos.h MagicMenu.h MagicMenu MagicMenuPrefs

###############################################################################

MagicMenu: $(MAIN_OBJS) Assert.o
	slink lib:c.o $(MAIN_OBJS) to $@.debug lib $(LIBS) Assert.o $(LFLAGS)
	slink $@.debug to $@ noicons nodebug
#	 @type "tagfiles/\#?" >t:tags
#	 @copy t:tags tags
#	 @delete quiet t:tags

MagicMenuPrefs: $(PREFS_OBJS) Assert.o
	slink lib:c.o $(PREFS_OBJS) to $@.debug lib $(LIBS) Assert.o $(LFLAGS)
	slink $@.debug to $@ noicons nodebug

###############################################################################

$(GSTFILE): system_headers.c system_headers.h
	gst unload $@
	sc $(CFLAGS) nogst noobjname makegst=$@ system_headers.c

###############################################################################

#tagfiles:
#	 makedir $@

#RCS:
#	 makedir $@

#protos.h: $(MAIN_SOURCE)
#	 mkptypes -c >protos.h $(MAIN_SOURCE)

###############################################################################

clean:
	-delete \#?.o MagicMenu MagicMenu.debug \
		MagicMenuPrefs MagicMenuPrefs.debug magicmenu.h \
		tags tagfiles all quiet

realclean: clean
	-delete ID $(GSTFILE)

###############################################################################

bumpMM:
	bumprev $(VERSION) MagicMenu

bumpPrefs:
	execute <<
		set foo `type MagicMenu_rev.rev`
		echo >MagicMenuPrefs_rev.rev `eval $${foo} - 1`
		unset foo
	<
	bumprev $(VERSION) MagicMenuPrefs

version: bumpMM bumpPrefs

###############################################################################

install: MagicMenu MagicMenuPrefs
	copy MagicMenu SYS:WBStartup
	copy MagicMenuPrefs SYS:Prefs

###############################################################################

#mkid:
#	 mkid -v \#?.(c|h|a|i)

#update:
#	 mkid -v -u

#xref:
#	 cxref -xref \#?.c
#	 cxref -xref -index -html \#?.c

#xref-update:
#	 cxref -xref -index -html \#?.c

#xref-clean:
#	 -delete \#?.html cxref.\#?

###############################################################################

#checkin: RCS
#	 ci -M -d -l$(VERSION) -m. -t-. $(SOURCE)

#lock: RCS
#	 rcs -l $(SOURCE)

#unlock: RCS
#	 rcs -u $(SOURCE)

#freeze: RCS
#	 rcs -q -nV$(VERSION)_`type MagicMenu_rev.rev`: $(SOURCE)

###############################################################################

magicmenu.h: locale/magicmenu.cd
main.o : main.c MagicMenu_rev.h
edit.o : edit.c MagicMenuPrefs_rev.h
