17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate# Use is subject to license terms.
49890706eSHans Rosenfeld# Copyright 2016 Nexenta Systems, Inc.
5f52943a9SAndy Fiddaman# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
67c478bd9Sstevel@tonic-gate#
77c478bd9Sstevel@tonic-gateinclude $(SRC)/Makefile.master
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate.KEEP_STATE:
107c478bd9Sstevel@tonic-gate
117c478bd9Sstevel@tonic-gateVERSION		= 0.95
127c478bd9Sstevel@tonic-gate
137c478bd9Sstevel@tonic-gate# $(POUND_SIGN) is just a #.  Used to turn a feature off.
147c478bd9Sstevel@tonic-gate# The $(POUND_SIGN)POUND_SIGN:sh construct is just so make doesn't have to
157c478bd9Sstevel@tonic-gate# spawn a shell and redefine POUND_SIGN if it is already defined (e.g.
167c478bd9Sstevel@tonic-gate# $(SRC)/Makefile.master was already included).
177c478bd9Sstevel@tonic-gate$(POUND_SIGN)POUND_SIGN:sh = echo '\043'
187c478bd9Sstevel@tonic-gate
197c478bd9Sstevel@tonic-gate
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate# Optional features (set to $(POUND_SIGN) to turn off):
227c478bd9Sstevel@tonic-gate#
237c478bd9Sstevel@tonic-gate# OPTION_UTILS:
247c478bd9Sstevel@tonic-gate#	Build the userland utilities.
257c478bd9Sstevel@tonic-gate#	NOTE: these utilities will be installed in
267c478bd9Sstevel@tonic-gate#	      /platform/$(PLATFORM)/boot/grub, not /boot/grub.
277c478bd9Sstevel@tonic-gate#
287c478bd9Sstevel@tonic-gate# OPTION_DOCS:
297c478bd9Sstevel@tonic-gate#	Build and install some GRUB documentations, e.g. man and info files.
307c478bd9Sstevel@tonic-gate#	NOTE: these docs will be installed in
317c478bd9Sstevel@tonic-gate#	      /platform/$(PLATFORM)/boot/grub, not /boot/grub.
327c478bd9Sstevel@tonic-gate#
337c478bd9Sstevel@tonic-gate# OPTION_FS:
347c478bd9Sstevel@tonic-gate#	Build additional filesystem support into GRUB. This will increase
357c478bd9Sstevel@tonic-gate#	the sizes of stage2 and pxegrub and may cause malfunction.
367c478bd9Sstevel@tonic-gate#
377c478bd9Sstevel@tonic-gate# STAGE2_NETBOOT:
387c478bd9Sstevel@tonic-gate#	Include netboot support in stage2 (on by default).
397c478bd9Sstevel@tonic-gate#	This only affects stage2, not pxegrub (diskless support).
407c478bd9Sstevel@tonic-gate#
417c478bd9Sstevel@tonic-gate# STAGE2_NETBOOT	= $(POUND_SIGN)
427c478bd9Sstevel@tonic-gateOPTION_UTILS	= $(POUND_SIGN)
437c478bd9Sstevel@tonic-gateOPTION_DOCS	= $(POUND_SIGN)
447c478bd9Sstevel@tonic-gateOPTION_FS	= $(POUND_SIGN)
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate
47*58e78d16SToomas SoomeBASE_CFLAGS	= $($(MACH)_XARCH)
48*58e78d16SToomas SoomeBASE_CFLAGS	+= -B$(GNUC_ROOT)/bin/ -g $(CPPFLAGS) $(OPTFLAGS) -std=gnu89
49*58e78d16SToomas SoomeBASE_CCASFLAGS	= $($(MACH)_XARCH)
50*58e78d16SToomas SoomeBASE_CCASFLAGS	+= -B$(GNUC_ROOT)/bin/ -g $(CPPFLAGS) $(OPTFLAGS)
51*58e78d16SToomas SoomeBASE_LDFLAGS	= $($(MACH)_XARCH)
527c478bd9Sstevel@tonic-gate
537ed54634SRobert MustacchiCC		= $(GNUC_ROOT)/bin/gcc
547c478bd9Sstevel@tonic-gateCFLAGS		= $(BASE_CFLAGS)
557c478bd9Sstevel@tonic-gateCCDEPMODE	= depmode=none
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gateCCAS		= $(CC)
587c478bd9Sstevel@tonic-gateCCASFLAGS	= $(BASE_CCASFLAGS)
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gateCPP		= $(CC) -E
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate# $(ENVCPPFLAGS4), if defined, should be something like "-Y I,somepath".
637c478bd9Sstevel@tonic-gate# We want to get rid of the "-Y I," part but make's pattern replacement
647c478bd9Sstevel@tonic-gate# macro reference doesn't allow spaces in it, e.g. $(ENVCPPFLAGS4:-Y I,%=%).
657c478bd9Sstevel@tonic-gate# So we'll get rid of the "-Y" now and then the "I," later.  By the way, this
667c478bd9Sstevel@tonic-gate# should also work in case $(ENVCPPFLAGS4) is "-YI,somepath" (no space).
677c478bd9Sstevel@tonic-gatet.ENVCPPFLAGS4	= $(ENVCPPFLAGS4:-Y%=%)
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gateCPPFLAGS	= $(DEFS) $(INCLUDES) $(WARNFLAGS) \
707c478bd9Sstevel@tonic-gate		  $(ENVCPPFLAGS1:-I%=-isystem %) \
717c478bd9Sstevel@tonic-gate		  $(ENVCPPFLAGS2:-I%=-isystem %) \
727c478bd9Sstevel@tonic-gate		  $(ENVCPPFLAGS3:-I%=-isystem %) \
737c478bd9Sstevel@tonic-gate		  $(t.ENVCPPFLAGS4:I,%=-nostdinc -isystem %)
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gateCCLD		= $(GNU_ROOT)/bin/gld
76f52943a9SAndy FiddamanGLDTARGET	= -melf_i386_sol2
777c478bd9Sstevel@tonic-gateLDFLAGS		= $(BASE_LDFLAGS)
787c478bd9Sstevel@tonic-gateLINKFLAGS	= -g
797c478bd9Sstevel@tonic-gateLINK		= $(CCLD) $(LINKFLAGS) $(LDFLAGS)
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gateDEFS		= -DHAVE_CONFIG_H -DSOLARIS_NETBOOT
827c478bd9Sstevel@tonic-gateOPTFLAGS	= -falign-jumps=1 -falign-loops=1 -falign-functions=1
83e153cda9SToomas SoomeOPTFLAGS	+= -fno-reorder-functions
847c478bd9Sstevel@tonic-gate#WARNFLAGS	= -Wall -Wmissing-prototypes -Wunused -Wshadow \
857c478bd9Sstevel@tonic-gate#		  -Wpointer-arith -Wundef
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gateOBJCOPY		= $(GNU_ROOT)/bin/gobjcopy
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gateAR		= /usr/ccs/bin/ar
907c478bd9Sstevel@tonic-gateRANLIB		= :
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gateMKDIR		= mkdir -p
93