# -*- mode: mak -*-
###############################################################################
# File:         PLATFORM/amx.def
# Contents:     AMX platform defines
#
# Revision History:
#   16/08/99    APY Created
#   16/11/01    APY Build env +v2.0 support, appended ';' to rules
#
# Note:
#   The following have to be defined in a platform specific manner
#   below and come from one of the platform configuration makefiles.
#
#       amx_target      The name that AMX knows the processor by.
#                       This actually names directory at the root
#                       of the amx directory tree .. nominally one
#                       of `amx68k' or `amx386'.
#
#       amx_filesystem  The optional name that AMX knows the 
#                       filesystem by. This actually names directory
#                       at the root of the amx/fs directory tree .. 
#                       nominally one of `afs68k' or `afs386'.
#
#       amx_toolset     The suffix AMX uses for the build tools
#                       nominally `TOOLWC' or `TOOLMR'.
#
#       amx_name        The prefix of the name of AMX's configuration
#                       and library files (normally the AMX part number)
#
#       amx_fsname      The prefix of the name of AMX/FS configuration
#                       and library files (normally the AMX part number)
#
#       amx_calling     The tail end of the AMX library name.
#                       Unfortunately even though the amx librarys
#                       live in different directorys for different
#                       targets they also have different names.
#
# From the above we define....
#
#       amx_dir         Root of the amx platform/compiler specific
#                       tree.
#
#       amx_cfgdir      Configuration
#
#       amx_incdir      Include directory
#
#       amx_objdir      Object directory
#
#       amx_libdir      Library directory
#
###############################################################################

.PHONY:		amx
amx:
	@if [ -z "$(AMX)" ]; then echo AMX env var not set; exit 2; fi

amx		= $(subst \\,/,$(strip $(AMX)))
amx_bin 	= $(amx)/$(strip $(amx_target))/cfg
amx_bin2	= $(amx)/$(strip $(amx_target))/cfgbldw

amx_dir		= $(amx)/$(strip $(amx_target))/$(strip $(amx_toolset))
amx_cfgdir	= $(amx_dir)/cfg
amx_objdir	= $(amx_dir)/obj
amx_libdir	= $(amx_dir)/lib
amx_incdir	= $(amx_dir)/def

ifdef amx_filesystem
amxfs_dir	= $(amx)/$(strip $(amx_filesystem))/$(strip $(amx_toolset))
amxfs_cfgdir	= $(amxfs_dir)/cfg
amxfs_objdir	= $(amxfs_dir)/obj
amxfs_libdir	= $(amxfs_dir)/lib
amxfs_incdir	= $(amxfs_dir)/def
endif

ifeq "$(findstring $(PATH),$(amx))" ""
PATH		:= $(PATH);$(amx_bin);$(amx_bin2)
endif

TS_MASM_AS	= 1

#

cc_defines	+= AMX_$(amx_name)
cc_includes	+= $(amx_incdir)
as_includes	+= $(amx_incdir)
ld_libpath	+= $(amx_libdir)
ifdef amx_filesystem
cc_defines	+= AMXFS_$(amx_fsname)
cc_includes	+= $(amxfs_incdir)    
as_includes	+= $(amxfs_incdir)
ld_libpath	+= $(amxfs_libdir)
endif

define amx_xxx
	@$(echo) [Building $@]
	@$(cmdfile) -ko$@ '\
/* AMX Linker funny stuff,\n\
 *	Force linker ordering requirements of AMX/EP and AMX/ET\n\
 *	whilst allowing main (and the startup code) to be placed\n\
 *	within a the library "eosas".\n\
 */\n\
extern void main(void);\n\
void   (*__main__) = main;\n'
endef

ifdef amx_filesystem
define amx_scf
	@$(echo) [Building - Software Config Module $@ \"$<\"]
	@$(amx_name)CG $< $(amx_cfgdir)/$(amx_name)CG.CT $@1 ;
	@$(amx_name)CG $< $(amxfs_cfgdir)/$(amx_fsname)CG.CT $@2 ;
	@cat $@1 $@2 > $@; rm $@1 $@2
endef
else
define amx_scf
	@$(echo) [Building - Software Config Module $@ \"$<\"]
	@$(amx_name)CG $< $(amx_cfgdir)/$(amx_name)CG.CT  $@;
endef
endif

define amx_tcf
	@$(echo) [Building - Target Config Module $@ \"$<\"]
	@$(amx_name)CG $< $(amx_cfgdir)/$(amx_name)HDW.CT $@;
endef

define amx_pcf
	@$(echo) [Building - PC Config Module $@ \"$<\"]
	@$(amx_name)CG $< $(amx_cfgdir)/$(amx_name)PCG.CT $@;
endef

define amx_int
	@$(echo) [Building - ISP Module $@ \"$<\"]
	@$(amx_name)CG $< $(amx_cfgdir)/$(amx_name)INT.CT $@;
endef

define amx_icf
	@$(echo) [Building - Insight config Module' $@ \"$<\"]
endef

#
