gonzui


Format: Advanced Search

t2ex/t2ex_source/kernel/sysmain/build_t2ex/Makefile.commonbare sourcepermlink (0.02 seconds)

Search this content:

    1: #
    2: # ----------------------------------------------------------------------
    3: #    T2EX Software Package
    4: #
    5: #    Copyright 2012 by Ken Sakamura.
    6: #    This software is distributed under the latest version of T-License 2.x.
    7: # ----------------------------------------------------------------------
    8: #
    9: #    Released by T-Engine Forum(http://www.t-engine.org/) at 2012/12/12.
   10: #    Modified by T-Engine Forum at 2014/07/31.
   11: #    Modified by TRON Forum(http://www.tron.org/) at 2015/06/04.
   12: #
   13: # ----------------------------------------------------------------------
   14: #
   15: 
   16: #
   17: # This software package is available for use, modification, 
   18: # and redistribution in accordance with the terms of the attached 
   19: # T-License 2.x.
   20: # If you want to redistribute the source code, you need to attach 
   21: # the T-License 2.x document.
   22: # There's no obligation to publish the content, and no obligation 
   23: # to disclose it to the TRON Forum if you have modified the 
   24: # software package.
   25: # You can also distribute the modified source code. In this case, 
   26: # please register the modification to T-Kernel traceability service.
   27: # People can know the history of modifications by the service, 
   28: # and can be sure that the version you have inherited some 
   29: # modification of a particular version or not.
   30: #
   31: #    http://trace.tron.org/tk/?lang=en
   32: #    http://trace.tron.org/tk/?lang=ja
   33: #
   34: # As per the provisions of the T-License 2.x, TRON Forum ensures that 
   35: # the portion of the software that is copyrighted by Ken Sakamura or 
   36: # the TRON Forum does not infringe the copyrights of a third party.
   37: # However, it does not make any warranty other than this.
   38: # DISCLAIMER: TRON Forum and Ken Sakamura shall not be held
   39: # responsible for any consequences or damages caused directly or
   40: # indirectly by the use of this software package.
   41: #
   42: # The source codes in bsd_source.tar.gz in this software package are 
   43: # derived from NetBSD or OpenBSD and not covered under T-License 2.x.
   44: # They need to be changed or redistributed according to the 
   45: # representation of each source header.
   46: #
   47: 
   48: #
   49: #       Makefile for gmake
   50: #       sysmain (common description)
   51: #
   52: 
   53: # source file dependencies (generated automatically)
   54: DEPS = Dependencies
   55: DEPENDENCIES_OUTPUT := $(DEPS)
   56: 
   57: MDIR = $(TETYPE)_$(MACHINE)
   58: 
   59: # ----------------------------------------------------------------------------
   60: # kernel install path
   61: KERNEL_INSTALLDIR       = $(BD)/kernel/bin/$(MDIR)
   62: 
   63: # kernel modules path
   64: BLD_TKERNEL_PATH        = $(BD)/kernel/tkernel/build$(T2EX_MM)/$(MDIR)
   65: BLD_SYSMGR_PATH         = $(BD)/kernel/sysmgr/build$(T2EX_MM)/$(MDIR)
   66: BLD_SYSINIT_PATH        = $(BD)/kernel/sysinit/build$(T2EX_MM)/$(MDIR)
   67: 
   68: ifdef T2EX
   69:   BLD_DATETIME_PATH     = $(BD)/t2ex/datetime/build/$(MDIR)
   70:   BLD_LOAD_PATH         = $(BD)/t2ex/load/build/$(MDIR)
   71:   BLD_FS_PATH           = $(BD)/t2ex/fs/build/$(MDIR)
   72:   BLD_NET_PATH          = $(BD)/t2ex/network/build/$(MDIR)
   73:   BLD_T2EX_PATH         = $(BD)/t2ex/build/$(MDIR)
   74: endif
   75: 
   76: # device driver path
   77: BLD_DRIVER_PATH         = $(BD)/driver/$(MDIR)/build$(T2EX)
   78: 
   79: # config modules path
   80: BLD_CONFIG_PATH         = $(BD)/config/build$(T2EX)/$(MDIR)
   81: 
   82: # monitor path
   83: BLD_MONITOR_PATH        = $(BD)/monitor/tmmain/build/$(MDIR)
   84: 
   85: # library path
   86: BLD_LIBS_PATH           = $(BD)/lib/build$(T2EX)/$(MDIR)
   87: 
   88: # ----------------------------------------------------------------------------
   89: # target objects
   90: TARGET_RAM      = kernel$(T2EX)-ram.sys
   91: TARGET_ROM      = kernel$(T2EX)-rom.rom
   92: TARGET_RAMCRT0  = icrt0$(T2EX_MM)_ram.o
   93: TARGET_ROMCRT0  = icrt0$(T2EX_MM).o
   94: 
   95: # emulator targets
   96: TARGET_EMU      = rom$(T2EX).bin
   97: TARGET_DBG_EMU  = rom$(T2EX)-dbg.bin
   98: 
   99: S       = ../../src
  100: 
  101: # common (system-level) source files
  102: SRC_SYS += inittask_main.c
  103: VPATH   += $(S)
  104: HEADER  += $(S)
  105: 
  106: # user-level source files
  107: SRC_USR +=
  108: 
  109: # additional source files (cpu-dependent)
  110: ifneq ($(T2EX_MM),)
  111:   VPATH   += $(BD)/kernel/sysdepend$(T2EX_MM)/cpu/$(MACHINE)
  112:   HEADER  += $(BD)/kernel/sysdepend$(T2EX_MM)/cpu/$(MACHINE)
  113: endif
  114: VPATH   += $(BD)/kernel/sysdepend/cpu/$(MACHINE)
  115: HEADER  += $(BD)/kernel/sysdepend/cpu/$(MACHINE)
  116: 
  117: # additional source files (device-dependent)
  118: ifneq ($(T2EX_MM),)
  119:   VPATH   += $(BD)/kernel/sysdepend$(T2EX_MM)/device/$(MDIR)
  120:   HEADER  += $(BD)/kernel/sysdepend$(T2EX_MM)/device/$(MDIR)
  121: endif
  122: VPATH   += $(BD)/kernel/sysdepend/device/$(MDIR)
  123: HEADER  += $(BD)/kernel/sysdepend/device/$(MDIR)
  124: 
  125: # header file path (kernel settings)
  126: HEADER  += $(BD)/kernel/tkernel/src
  127: ifdef  T2EX
  128:   HEADER  += $(BD)/include/t2ex/
  129: endif
  130: 
  131: # object files (system-level)
  132: OBJ     = $(addsuffix .o, $(basename $(SRC_SYS)))
  133: 
  134: # object files (user-level)
  135: U_OBJ   = $(addsuffix .uo, $(basename $(SRC_USR)))
  136: 
  137: # T-Kernel modules
  138: K_OBJ   +=        $(BLD_TKERNEL_PATH)/tkernel.o \
  139:                 $(BLD_SYSMGR_PATH)/sysmgr.o \
  140:                 $(BLD_SYSINIT_PATH)/sysinit.o
  141: 
  142: # T2EX function objects
  143: ifdef  T2EX
  144: 
  145:   LDUSRLIBS += -lc
  146: 
  147:   ifdef  T2EX_DT
  148:     # T2EX calendar date / time
  149:     K_OBJ += $(BLD_T2EX_PATH)/datetime.o
  150:     ADD_MODULES += datetime
  151:     CPPFLAGS += -DUSE_T2EX_DT
  152:     LDUSRLIBS += -ldatetime
  153:   endif
  154: 
  155:   ifdef  T2EX_PM
  156:     # T2EX program load
  157:     K_OBJ += $(BLD_T2EX_PATH)/load.o
  158:     ADD_MODULES += load
  159:     CPPFLAGS += -DUSE_T2EX_PM
  160:     LDUSRLIBS += -lload
  161:   endif
  162: 
  163:   ifdef  T2EX_FS
  164:     # T2EX file management
  165:     K_OBJ += $(BLD_T2EX_PATH)/fs.o $(BLD_T2EX_PATH)/fimp.o
  166:     ADD_MODULES += fs
  167:     CPPFLAGS += -DUSE_T2EX_FS
  168:     LDUSRLIBS += -lfs
  169:   endif
  170: 
  171:   ifdef  T2EX_NET
  172:     # T2EX network communication
  173:     K_OBJ += $(BLD_T2EX_PATH)/network.o
  174:     ADD_MODULES += net
  175:     CPPFLAGS += -DUSE_T2EX_NET
  176:     LDUSRLIBS += -lnetwork
  177:   endif
  178: 
  179: endif
  180: 
  181: # gcc standard library
  182: STDLIB = -lgcc
  183: 
  184: # additional library
  185: LDSYSLIBS = -ltk -lsys -ltm -lsvc
  186: LDLIBS += $(LDUSRLIBS) $(LDSYSLIBS)
  187: 
  188: # linker options
  189: LDFLAGS += -static -nostdlib -T $(LINKSCRIPT)
  190: 
  191: LINKSCRIPT = kernel$(T2EX_MM)-ram$(_GCCVER).lnk
  192: $(TARGET_ROM): LINKSCRIPT = kernel$(T2EX_MM)-rom$(_GCCVER).lnk
  193: 
  194: # compiler options
  195: CFLAGS += $(CFLAGS_WARNING)
  196: CPPFLAGS += -DTKERNEL_ONLY
  197: 
  198: # suppress debug options for the system codes
  199: # (comment out to debug the whole kernel)
  200: DBGOPT := mode=
  201: 
  202: # ----------------------------------------------------------------------------
  203: ALL  = $(TARGET_ROM) $(TARGET_ROM:%.rom=%.map) $(TARGET_ROM:%.rom=%.mot)
  204: ALL += $(TARGET_RAM) $(TARGET_RAM:%.sys=%.map) $(TARGET_RAM:%.sys=%.mot)
  205: ALL += $(TARGET_RAM:%.sys=%.bin)
  206: EMU  = $(TARGET_EMU) $(TARGET_DBG_EMU)
  207: REQ_MODULES = libraries tkernel sysmgr sysinit drivers $(ADD_MODULES)
  208: 
  209: # make targets
  210: .PHONY: all emu clean install install_emu
  211: .PHONY: source clean_source clean_all
  212: .PHONY: tkernel sysmgr sysinit libraries drivers config monitor 
  213: .PHONY: clean_libraries clean_drivers clean_config clean_monitor
  214: ifdef  T2EX
  215: .PHONY: datetime load fs net
  216: endif
  217: 
  218: # default make targets
  219: all: $(REQ_MODULES) $(TARGET_RAMCRT0) $(TARGET_ROMCRT0)
  220:         $(MAKE) $(ALL)
  221:         $(MAKE) install
  222: 
  223: # make targets for emulator
  224: emu: all config monitor
  225:         $(MAKE) $(EMU)
  226:         $(MAKE) install_emu
  227: 
  228: # objects for RAM
  229: $(TARGET_RAM): $(TARGET_RAMCRT0) $(OBJ) $(U_OBJ) $(K_OBJ) $(I_OBJ)
  230:         $(CC) $(TARGET_ARCH) $(LDFLAGS) $^ $(LDLIBS) $(STDLIB) $(OUTPUT_OPTION)
  231: 
  232: $(TARGET_RAM:%.sys=%.map): $(TARGET_RAM)
  233:         $(NM) $(NMFLAGS) $< > $@
  234: 
  235: $(TARGET_RAM:%.sys=%.mot): $(TARGET_RAM)
  236:         $(OBJCOPY) $(OUTPUT_SREC) $< $@
  237: 
  238: $(TARGET_RAM:%.sys=%.bin): $(TARGET_RAM)
  239:         $(OBJCOPY) -O binary $< $@
  240: 
  241: # objects for ROM
  242: $(TARGET_ROM): $(TARGET_ROMCRT0) $(OBJ) $(U_OBJ) $(K_OBJ) $(I_OBJ)
  243:         $(CC) $(TARGET_ARCH) $(LDFLAGS) $^ $(LDLIBS) $(STDLIB) $(OUTPUT_OPTION)
  244: 
  245: $(TARGET_ROM:%.rom=%.map): $(TARGET_ROM)
  246:         $(NM) $(NMFLAGS) $< > $@
  247: 
  248: $(TARGET_ROM:%.rom=%.mot): $(TARGET_ROM)
  249:         $(OBJCOPY) $(OUTPUT_SREC) $< $@
  250: 
  251: # objects for emulator rom images
  252: EMU_OBJ =       $(BLD_MONITOR_PATH)/tmonitor.mot \
  253:                $(BLD_CONFIG_PATH)/rominfo$(T2EX)-rom.mot \
  254:                $(TARGET_ROM:%.rom=%.mot)
  255: 
  256: DBG_EMU_OBJ =   $(BLD_MONITOR_PATH)/tmonitor.mot \
  257:                $(BLD_CONFIG_PATH)/rominfo$(T2EX)-ram.mot
  258: 
  259: $(TARGET_EMU): $(EMU_OBJ)
  260:         $(BD)/etc/mergesrec $^ > _rom.mot
  261:         $(OBJCOPY) -I srec -O binary _rom.mot $@
  262:         $(RM) _rom.mot
  263: 
  264: $(TARGET_DBG_EMU): $(DBG_EMU_OBJ)
  265:         $(BD)/etc/mergesrec $^ > _rom-dbg.mot
  266:         $(OBJCOPY) -I srec -O binary _rom-dbg.mot $@
  267:         $(RM) _rom-dbg.mot
  268: 
  269: # required modules
  270: tkernel:
  271:         ( cd $(BLD_TKERNEL_PATH) ; $(MAKE) $(DBGOPT) )
  272: 
  273: sysmgr:
  274:         ( cd $(BLD_SYSMGR_PATH) ; $(MAKE) $(DBGOPT) )
  275: 
  276: sysinit:
  277:         ( cd $(BLD_SYSINIT_PATH) ; $(MAKE) $(DBGOPT) )
  278: 
  279: ifdef  T2EX
  280: datetime:
  281:         ( cd $(BLD_DATETIME_PATH) ; $(MAKE) $(DBGOPT) install )
  282: 
  283: load:
  284:         ( cd $(BLD_LOAD_PATH) ; $(MAKE) $(DBGOPT) install )
  285: 
  286: fs:
  287:         ( cd $(BLD_FS_PATH) ; $(MAKE) $(DBGOPT) install)
  288: 
  289: net:
  290:         ( cd $(BLD_NET_PATH) ; $(MAKE) $(DBGOPT) install)
  291: endif
  292: 
  293: libraries:
  294:         ( cd $(BLD_LIBS_PATH) ; $(MAKE) $(DBGOPT) )
  295: 
  296: clean_libraries:
  297:         ( cd $(BLD_LIBS_PATH) ; $(MAKE) $(DBGOPT) clean )
  298: 
  299: drivers:
  300:         ( cd $(BLD_DRIVER_PATH) ; $(MAKE) $(DBGOPT) )
  301: 
  302: clean_drivers:
  303:         ( cd $(BLD_DRIVER_PATH) ; $(MAKE) $(DBGOPT) clean )
  304: 
  305: config:
  306:         ( cd $(BLD_CONFIG_PATH) ; $(MAKE) $(DBGOPT) )
  307: 
  308: clean_config:
  309:         ( cd $(BLD_CONFIG_PATH) ; $(MAKE) $(DBGOPT) clean )
  310: 
  311: monitor:
  312:         ( cd $(BLD_MONITOR_PATH) ; $(MAKE) $(DBGOPT) )
  313: 
  314: clean_monitor:
  315:         ( cd $(BLD_MONITOR_PATH) ; $(MAKE) $(DBGOPT) clean )
  316: 
  317: # make source files of svc interface 
  318: source:
  319:         ( cd $(BLD_LIBS_PATH) ; $(MAKE) $(DBGOPT) source )
  320:         ( cd $(BLD_DRIVER_PATH) ; $(MAKE) $(DBGOPT) source )
  321: ifdef  T2EX
  322:         ( cd $(BLD_DATETIME_PATH) ; $(MAKE) $(DBGOPT) source )
  323:         ( cd $(BLD_LOAD_PATH) ; $(MAKE) $(DBGOPT) source )
  324:         ( cd $(BLD_FS_PATH) ; $(MAKE) $(DBGOPT) source )
  325:         ( cd $(BLD_NET_PATH) ; $(MAKE) $(DBGOPT) source )
  326: endif
  327: 
  328: # clean source files of svc interface 
  329: clean_source:
  330:         ( cd $(BLD_LIBS_PATH) ; $(MAKE) $(DBGOPT) clean_source )
  331:         ( cd $(BLD_DRIVER_PATH) ; $(MAKE) $(DBGOPT) clean_source )
  332: ifdef  T2EX
  333:         ( cd $(BLD_DATETIME_PATH) ; $(MAKE) $(DBGOPT) clean_source )
  334:         ( cd $(BLD_LOAD_PATH) ; $(MAKE) $(DBGOPT) clean_source )
  335:         ( cd $(BLD_FS_PATH) ; $(MAKE) $(DBGOPT) clean_source )
  336:         ( cd $(BLD_NET_PATH) ; $(MAKE) $(DBGOPT) clean_source )
  337: endif
  338: 
  339: # clean all objects
  340: clean:  clean_libraries clean_drivers
  341:         ( cd $(BLD_TKERNEL_PATH) ; $(MAKE) $(DBGOPT) clean )
  342:         ( cd $(BLD_SYSMGR_PATH) ; $(MAKE) $(DBGOPT) clean )
  343:         ( cd $(BLD_SYSINIT_PATH) ; $(MAKE) $(DBGOPT) clean )
  344: ifdef  T2EX
  345:         ( cd $(BLD_LOAD_PATH) ; $(MAKE) $(DBGOPT) clean clean_install )
  346:         ( cd $(BLD_DATETIME_PATH) ; $(MAKE) $(DBGOPT) clean clean_install )
  347:         ( cd $(BLD_FS_PATH) ; $(MAKE) $(DBGOPT) clean clean_install )
  348:         ( cd $(BLD_NET_PATH) ; $(MAKE) $(DBGOPT) clean clean_install )
  349: endif
  350:         $(RM) $(OBJ) $(U_OBJ) $(TARGET_RAMCRT0) $(TARGET_ROMCRT0) $(ALL) $(DEPS)
  351:         $(RM) $(TARGET_EMU) $(TARGET_DBG_EMU)
  352: 
  353: # clean all objects and source files of svc interface 
  354: clean_all: clean clean_source
  355: 
  356: # install kernel target
  357: install: $(addprefix $(EXE_INSTALLDIR)/, $(ALL))
  358: 
  359: # install emualtor target
  360: install_emu: $(addprefix $(EXE_INSTALLDIR)/, $(EMU))
  361: 
  362: $(addprefix $(EXE_INSTALLDIR)/, $(TARGET)): $(EXE_INSTALLDIR)/%: %
  363: 
  364: # generate dependencies
  365: $(DEPS): ; touch $(DEPS)
  366: -include $(DEPS)
  367: