Makefile.ALL 5.92 KB
#!gmake

ifndef SIMTOOLS
SIMTOOLS = ../../..
endif

include $(SIMTOOLS)/makedefs

VPATH = ..

################################################################
# INCLUDE DIRECTORIES
################################################################
INCS = -I.. -I$(SIMTOOLS)/devices/controllers -I$(SIMTOOLS)/cpus/shared $(GLOBAL_INCS) -I$(ROOT)/host_include

################################################################
# DEFINES
################################################################
ifeq ($(CPUSIM),mxs)
DEF1 = -DMIPSY_MXS
endif
DEFS = $(DEF1) $(GLOBAL_DEFS)

ASFLAGS  = $(GLOBAL_ASFLAGS) 
CFLAGS   = $(GLOBAL_CFLAGS)  
LDFLAGS  = $(GLOBAL_LDFLAGS) 

AS_OPTS  = $(ASFLAGS) $(DEFS) $(INCS)
CC_OPTS  = $(CFLAGS) $(DEFS) $(INCS)

################################################################
# TARGETS
################################################################
C_TARGETS = simmagic.o simmisc.o startup.o faults.o rcp.o nand.o

TARGETS = $(C_TARGETS)

#################################################################
# Archives that are linked in
#################################################################

SUBDIR_PREFIX = SIMOS

ifdef SIMOS64
SUBDIR_PREFIX = SIMOS64
endif

SUBDIR = $(SUBDIR_PREFIX)-$(CPU)

ifeq ($(CPUSIM),mxs)
MIPSYLIB  = $(SIMTOOLS)/cpus/mxs/$(SUBDIR)/mxslib.a
else
MIPSYLIB  = $(SIMTOOLS)/cpus/mipsy/$(SUBDIR)/mipsylib.a
endif
ifndef NO_EMBRA

EMBRALIB  = $(SIMTOOLS)/cpus/embra/$(SUBDIR)/embralib.a \
		$(LIBDIR)/vcode.lib.a


EMBRALIB  += $(SIMTOOLS)/common/dcg_support/$(SUBDIR)/dcg_support.a 
endif

CPULIBS   =  $(MIPSYLIB) $(EMBRALIB)

CACHELIBS      = $(SIMTOOLS)/caches/2Level/$(SUBDIR)/2levellib.a

MEMSYSLIBS     = $(SIMTOOLS)/memsystems/flashlite/$(SUBDIR)/flashlitelib.a
MEMSYSLIBS    += $(SIMTOOLS)/memsystems/misc/$(SUBDIR)/memsysmisc.a

COMMONLIBS     = $(SIMTOOLS)/common/tcl/$(SUBDIR)/tcl.a
COMMONLIBS    +=  $(SIMTOOLS)/common/misc/$(SUBDIR)/misc.a
COMMONLIBS    += $(SIMTOOLS)/common/stats/$(SUBDIR)/stats.a
COMMONLIBS    += $(SIMTOOLS)/common/symbols/$(SUBDIR)/symbols.a

D_DIR         = $(SIMTOOLS)/devices
DEVICES       = $(D_DIR)/disk/$(SUBDIR)/disklib.a \
                $(D_DIR)/controllers/$(SUBDIR)/controllerlib.a \
                $(D_DIR)/network/$(SUBDIR)/networklib.a 

ifdef USE_FLASHLITE
MEMSYSLIBS +=  $(SIMDIR)/$(CPU)/flashlite.a
MEMSYSLIBS += $(SIMDIR)/protocols/dyn_ptr/$(CPU)/protocolLib.a
ifeq ($(CPU), SGI)
MEMSYSLIBS += $(LIBDIR)/libgcc2.7.2.a 
endif
endif 

ifdef USE_TCL8
LIBTCL = $(LIBDIR)/libtcl8.0.a
else
#LIBTCL = $(LIBDIR)/libtcl7.6.a
LIBTCL = -ltcl
endif

ifdef USE_SESL
LIBSESL = $(LIBDIR)/libsesl.a -lbfd -liberty
else
LIBSESL = 
endif

ifdef USE_TRACING
LIBTRACE = $(LIBDIR)/libtrace.a $(LIBDIR)/globals.a $(LIBDIR)/libMipsR.a
else
LIBTRACE = 
endif

LIBS  = $(CPULIBS) $(CACHELIBS) $(MEMSYSLIBS) $(COMMONLIBS) $(DEVICES) $(LIBTCL) $(LIBSESL) $(LIBTRACE)

ifdef DWARF2
LIBS += $(LIBDIR)/libdwarf.a -lelf
endif

#################################################################
# In order to compile IRIX for the simport, we need to export the
# interface headers to a place where the kernel can read them.
# We assume the ROOT environment variable is set properly.
#
# In the 5.2 based kernels the headers need to go to $ROOT/kern/sys/SIMOS.
# In the 5.3 based kernels they need to got to $ROOT/usr/include/sys/SIMOS.
# Luckily /usr/include/sys/SIMOS does not exist in the 5.2 kernels, so
# try it first and fail over to EXPORTDIR2.
#################################################################
#EXPORTDIR1    = /usr/include/sys/SIMOS
EXPORTDIR1    = $(ROOT)/kern/sys/SIMOS
EXPORTDIR2    = /kern/sys/SIMOS
PPHEADERS     = sw_services.h iec.h ospcdefs.h
EXPORTHEADERS = os_interface.h simcp0.h simether.h simhd.h simmp.h \
                syslimits.h simdetail.h simfirewall.h simmagic.h \
		hw_bcopy.h flashhw.h simprom.h $(PPHEADERS)
COMMONHEADERS = simtypes.h


TARGET     = simbb-$(CPU)


.PHONY:	warn deps

default: warn
	@$(MAKE) -f ../Makefile.ALL deps
	@$(MAKE) -f ../Makefile.ALL INCLUDE_DEPS=1  $(TARGET)

simos-SGI:  $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -32 -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm -lelfutil
	@echo "done."

simos-SGIN32:  $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -Wl,-full_got_pages -n32 -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm -lelfutil
	@echo "done."

simos64-SGIN32:$(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -Wl,-full_got_pages -n32 -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm -lelfutil
	@echo "done."


simos-SGIM4:  $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -Wl,-full_got_pages -n32 -mips4 -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm
	@echo "done."

simos-SUN: $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm -lsocket -lnsl -ldl
	@echo "done."

simos-ALPHA: $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm 
	@echo "done."

simos-X86: $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm  -ldl
	@echo "done."

simbb-X86: $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -o $(SIMTOOLS)/cpus/simbb/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm  -ldl -L$(ROOT)/host_lib -lecc -lcryptoX86
	@echo "done."

simos-X86-solaris: $(TARGETS) $(LIBS) Makefile LinkOutput
	$(LD) $(LDFLAGS) -o $(SIMTOOLS)/cpus/simos/$(SUBDIR)/simos $(TARGETS) $(LIBS) -lm  -ldl -lsocket -lnsl
	@echo "done."

warn:
	@echo ""
	@echo "Making $(CPU) SIMOS"
	@echo "  DEFS :   `$(FORMAT) $(DEFS)`"
	@echo "  CFLAGS : `$(FORMAT) $(CFLAGS)`"
	@echo ""

LinkOutput: 
	@echo ""
	@echo "Linking $(CPU) SIMOS"
	@echo "  LDFLAGS : `$(FORMAT) $(LDFLAGS)`"
	@echo "  LIBS : `$(FORMAT) $(LIBS)`"


$(C_TARGETS): %.o: %.c
	@echo "Compiling  $(<F)"
	$(CC) $(CC_OPTS) -c $<

deps: ${TARGETS:.o=.d}

%.d: %.c
	@$(CC) -M $(CC_OPTS) $< > $@

ifdef INCLUDE_DEPS
include ${TARGETS:.o=.d}
endif