#
# ----------------------------------------------------------------------
#    T2EX Software Package
#
#    Copyright 2012 by Ken Sakamura.
#    This software is distributed under the latest version of T-License 2.x.
# ----------------------------------------------------------------------
#
#    Released by T-Engine Forum(http://www.t-engine.org/) at 2012/12/12.
#    Modified by T-Engine Forum at 2013/02/19.
#    Modified by TRON Forum(http://www.tron.org/) at 2015/06/04.
#
# ----------------------------------------------------------------------
#

#
# This software package is available for use, modification, 
# and redistribution in accordance with the terms of the attached 
# T-License 2.x.
# If you want to redistribute the source code, you need to attach 
# the T-License 2.x document.
# There's no obligation to publish the content, and no obligation 
# to disclose it to the TRON Forum if you have modified the 
# software package.
# You can also distribute the modified source code. In this case, 
# please register the modification to T-Kernel traceability service.
# People can know the history of modifications by the service, 
# and can be sure that the version you have inherited some 
# modification of a particular version or not.
#
#    http://trace.tron.org/tk/?lang=en
#    http://trace.tron.org/tk/?lang=ja
#
# As per the provisions of the T-License 2.x, TRON Forum ensures that 
# the portion of the software that is copyrighted by Ken Sakamura or 
# the TRON Forum does not infringe the copyrights of a third party.
# However, it does not make any warranty other than this.
# DISCLAIMER: TRON Forum and Ken Sakamura shall not be held
# responsible for any consequences or damages caused directly or
# indirectly by the use of this software package.
#
# The source codes in bsd_source.tar.gz in this software package are 
# derived from NetBSD or OpenBSD and not covered under T-License 2.x.
# They need to be changed or redistributed according to the 
# representation of each source header.
#

#
#       makerules
#               for GNU make
#
#       common rules for T2EX program modules
#
#       environment variables:
#
#       mode  compile mode
#               (empty)      : release version
#               debug        : debug version
#
#       BD    development environment base directory
#
#       GNUs  cross development environment tool
#       GNU_BD        GNU cross development environment tool base directory
#
#       REL_TYP       relocatable format
#               r : relocatable format (default)
#               q : fully-linked relocatable format
#
#       MOD_TYP       module type
#               u : user program module (default)
#               s : system program module
#
#       this makerules needs:
#        * /usr/bin/make      GNU make version 3.78.1
#        * /usr/bin/perl      perl version 5.005_03
#

# ===== default settings ======================================================
ifndef BD
  # SDK base directory
  BD := /usr/local/te
endif

include $(BD)/etc/makerules

# ===== platform specific =====================================================
#
# MODULE_INSTALLDIR     module install directory

MODULE_INSTALLDIR = $(BD)/module/bin/$(TETYPE)_$(MACHINE)$(SUFFIX_INST)

# ===== common definitions ====================================================

### install module binary ###
$(MODULE_INSTALLDIR)/%: %
        $(BD)/etc/backup_copy -t $< $(MODULE_INSTALLDIR)

# ===== individual definitions ================================================

ifeq ($(REL_TYP), q)
  LDFLAGS2 = -static -q -Wl,-q -B $(COMMONLIB) -T $(BD)/lib/build_t2ex/$(TETYPE)_$(MACHINE)$(SUFFIX_LIB)/reloc.lnk
else
  LDFLAGS2 = -static -r -B $(COMMONLIB) -T $(BD)/lib/build_t2ex/$(TETYPE)_$(MACHINE)$(SUFFIX_LIB)/reloc.lnk
endif

ifneq ($(MOD_TYP), s)
  LDLIBS += -lusermod
endif

LOADLIBES =
LDOBJS =
LDLIBS += -ltk -lstr -lsvc

HEADER := $(BD)/include/t2ex $(HEADER)

### symbol list ###
%.map: %
        $(NM) $(NMFLAGS) $< > $@
#       $(NM) $(NMFLAGS) $< | $(BD)/module/etc/chkmain | $(BD)/etc/chkundef -arm > $@

# ============================================================================
