#* @(#) pSOSystem x86/V2.2.5: apps/xxxx/386/makefile (hello) 2.20 96/09/27 07:19:30 * 
#***********************************************************************
#*                                                                     *
#*   MODULE:  apps/xxxx/makefile                                       *
#*   DATE:    96/09/27                                                   *
#*   PURPOSE: Sample makefile to build a pSOSystem application         *
#*                                                                     *
#*---------------------------------------------------------------------*
#*                                                                     *
#*        Copyright 1991 - 1993, Integrated Systems, Inc.              *
#*                      ALL RIGHTS RESERVED                            *
#*                                                                     *
#*   Permission is hereby granted to licensees of Integrated Systems,  *
#*   Inc. products to use or abstract this computer program for the    *
#*   sole purpose of implementing a product based on Integrated        *
#*   Systems, Inc. products.   No other rights to reproduce, use,      *
#*   or disseminate this computer program, whether in part or in       *
#*   whole, are granted.                                               *
#*                                                                     *
#*   Integrated Systems, Inc. makes no representation or warranties    *
#*   with respect to the performance of this computer program, and     *
#*   specifically disclaims any responsibility for any damages,        *
#*   special or consequential, connected with the use of this program. *
#*                                                                     *
#*---------------------------------------------------------------------*
#*   Before using this makefile, you must define environment variable  *
#*   PSS_ROOT to point to the pSOSystem "root" directory. You must     *
#*   also modify the variable PSS_BSP in this file if your BSP is      *
#*   not the default BSP.                                              *
#*                                                                     *
#***********************************************************************
#PSS_BSP        =       $(PSS_ROOT)/bsps/pc

UGL_ROOT = $(ZAF_ROOT)/ugl
UGL_OS_HEADER=uosPsos.h
UGL_ARCH_HEADER=uarX86.h

#---------------------------------------------------------------------
# PSS_DRVOBJS is a list of drivers to be add to the os. When the os and
# application are built separately PSS_DRVOBJS will be included as part
# of the os download file.
# When the os and application are built together PSS_DRVOBJS will be
# included in the system download file
# The driver configuration file drv_conf.obj needs to always be included
# in PSS_DRVOBJS.
#---------------------------------------------------------------------
PSS_DRVOBJS=	obj/drv_conf.obj

#---------------------------------------------------------------------
# PSS_APPOBJS is a list of object files for the application. When the
# os and application are built separately PSS_APPOBJS will be included
# as part of the application download file.
# When the os and application are built together PSS_APPOBJS will be
# included in the system download file
#---------------------------------------------------------------------
APPOBJS1= obj/hello1.obj obj/p_app.obj 
APPOBJS2= obj/board.obj obj/psosasm.obj
PSS_APPOBJS= $(APPOBJS1) $(APPOBJS2)
 
#---------------------------------------------------------------------
# PSS_APPINCS can be used to add non standard include paths for
# the application such as directories of drivers added in addition to
# pSOSystem. If no non standard include paths are needed, define
# PSS_APPINCS as "."
#---------------------------------------------------------------------
PSS_APPINCS=-I$(ZAF_ROOT)/include -I$(UGL_ROOT)/h
 
#---------------------------------------------------------------------
# DRV_LIB?s are the libraries that you want to link with your
# application like all the networking libraries.
#
# So set DRV_LIB1....DRV_LIB5 with what ever libraries you intend to
# link.
# DRV_LIB1=
# DRV_LIB2=
# DRV_LIB3=
# DRV_LIB4=
# DRV_LIB5=
#---------------------------------------------------------------------
DRV_LIB1=$(PSS_ROOT)/sys/libc/libprepc.lib
#DRV_LIB1=

#---------------------------------------------------------------------
# PSS_COMPLIB can be used to include any additional library in
# the load step that you want (for example MetaWindow). Note you must
# use full path names for PSS_COMPLIB.
#---------------------------------------------------------------------
PSS_COMPLIB=$(PSS_ROOT)/sys/libc/i386fm00.lib $(PSS_ROOT)/sys/libc/i386fx00.lib
PSS_FIXLIB=$(PSS_ROOT)/sys/libc/libcxxsp.lib

#---------------------------------------------------------------------
# APP_LIB is the name of the library file that will contain the
# compiled application code.
#---------------------------------------------------------------------
APP_LIB1= obj/app.lib
APP_LIB2= $(PSS_ROOT)/sys/libc/libcxxsp.lib $(UGL_ROOT)/lib/ugl.lib
APP_LIB3= $(ZAF_ROOT)/lib/cadul/zafpsos.lib

APP_LIB = $(APP_LIB1) $(APP_LIB2) $(APP_LIB3) $(APP_LIB4) $(APP_LIB5)

#-----------------------------------------------------------------------
# Target "all" defines what is made when make is invoked with no
# arguments.  You may want to change this if you are building something
# else all the time.  The possible targets are:
#
#    ram.abs 	- OS and application together in RAM
#    rom.abs 	- OS and application together in ROM
#    os.abs  	- OS only in RAM
#    romos.abs	- OS only in ROM
#    app.BD  	- application only (.BD format), downloaded to RAM
#    app.HX  	- application only (HX format), downloaded to RAM
#
# Targets with a ".abs" extension are absolute binary. You may build any of
# these in Intel Hex format instead by substituting a ".hex" extension,
# such as "ram.hex".
#-----------------------------------------------------------------------
all:	ram.abs

#---------------------------------------------------------------------
# These next 5 lines must come before any of the application rules.
#---------------------------------------------------------------------
PSS_CONFIG=	$(PSS_ROOT)/configs/std

include $(PSS_BSP)/bsp.mk		# board support settings
include $(PSS_BSP)/build.mk		# linker build file rules
include $(PSS_BSP)/memory.mk		# target memory layout
include $(PSS_CONFIG)/configxx.mk

#---------------------------------------------------------------------
# print out used memory layout (defined in $(PSS_BSP)/memory.mk)
#---------------------------------------------------------------------
layout:
	@echo 'Memory layout settings:'
	@echo 'OS-Code  :  $(OS_CODE_START)-$(OS_CODE_END)'
	@echo 'OS-Data  :  $(OS_DATA_START)-$(OS_DATA_END)'
	@echo 'APP-Code :  $(APP_CODE_START)-$(APP_CODE_END)'
	@echo 'APP-Data :  $(APP_DATA_START)-$(APP_DATA_END)'

clean:
	@$(RM) obj
	@$(RM) lst
	@$(RM) *.map
	@$(RM) ram.bld
	@$(RM) app.bld
	@$(RM) rom.bld
	@$(RM) romos.bld
	@$(RM) os.bld
	@$(RM) *.loc
	@$(RM) *.abs
	@$(RM) *.BD
	@$(RM) *.HX
	@$(RM) *.hex
	@$(RM) *.opt
	@$(RM) lnk.cmd
	@$(RM) ram.tmp
	@$(RM) os.tmp
	@$(RM) tmpbegin
	@$(MKDIR) obj
	@$(MKDIR) lst

obj/app.lib:	$(PSS_APPOBJS)
	$(RM)  obj/app.lib
	$(LIB) -idp obj/app.lib $(PSS_APPOBJS)

obj/hello1.obj: ../hello1.cpp \
		makefile \
		sys_conf.h \
		$(PSS_ROOT)/include/psos.h
	$(CXX) -DUGL_ROOT=$(UGL_ROOT) -DUGL_OS_HEADER=$(UGL_OS_HEADER) -DUGL_ARCH_HEADER=$(UGL_ARCH_HEADER) \
	-DZAF_PSOS -DZAF_UGL -D_WCHAR_T_DEFINED $(CXXOPTS) ../hello1.cpp -o obj/hello1.obj
	$(INI) $(INIFLAG) obj/hello1.obj

obj/p_app.obj: p_app.cpp \
		makefile \
		sys_conf.h \
		$(PSS_ROOT)/include/psos.h
	$(CXX) -DUGL_ROOT=$(UGL_ROOT) -DUGL_OS_HEADER=$(UGL_OS_HEADER) -DUGL_ARCH_HEADER=$(UGL_ARCH_HEADER) \
	-DZAF_PSOS -DZAF_UGL -D_WCHAR_T_DEFINED $(CXXOPTS) p_app.cpp -o obj/p_app.obj
	$(INI) $(INIFLAG) obj/p_app.obj

obj/drv_conf.obj:	$(ZAF_ROOT)/source/psos/drv_conf.c			\
		sys_conf.h			\
		$(PSS_BSP)/bsp.h		\
		$(PSS_ROOT)/include/bspfuncs.h	\
		$(PSS_ROOT)/include/configs.h	\
		$(PSS_ROOT)/include/sysvars.h	\
		$(PSS_ROOT)/include/pna.h
	$(CC) $(COPTS) $(ZAF_ROOT)/source/psos/drv_conf.c -o obj/drv_conf.obj
	$(INI) $(INIFLAG) obj/drv_conf.obj

obj/board.obj: $(ZAF_ROOT)/source/psos/board.c \
    $(PSS_BSP)/bsp.h \
    $(PSS_ROOT)/include/bspfuncs.h \
    makefile
	$(CC) $(COPTS) -o obj/board.obj $(ZAF_ROOT)/source/psos/board.c
	$(INI) $(INIFLAG) obj/board.obj

obj/psosasm.obj: $(ZAF_ROOT)/source/psos/psosasm.asm \
    makefile 
	cat $(ZAF_ROOT)/source/psos/psosasm.asm > psosasm.c
	$(CPP) -VNOANSI -I. -I$(PSS_BSP) -D$(MODEL) -I$(PSS_ROOT)/include psosasm.c
	cstrip psosasm.i psosasm.ii
	$(AS) -I $(PSS_ROOT)/include -CS -o obj/psosasm.obj psosasm.ii
	$(INI) $(INIFLAG) obj/psosasm.obj
	@$(RM) psosasm.c psosasm.i psosasm.ii

