17c478bd9Sstevel@tonic-gate#
224da5b34Srie# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate# Use is subject to license terms.
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
67c478bd9Sstevel@tonic-gate#
77c478bd9Sstevel@tonic-gateinclude ../../Makefile.grub
87c478bd9Sstevel@tonic-gateinclude ../Makefile.solaris.defs
97c478bd9Sstevel@tonic-gate
107c478bd9Sstevel@tonic-gate
117c478bd9Sstevel@tonic-gateGRUB		= grub
127c478bd9Sstevel@tonic-gateGRUB_OBJS	= asmstub.o main.o
137c478bd9Sstevel@tonic-gate$(GRUB)		:= LIBS = ../stage2/libgrub.a ../lib/libcommon.a -lcurses
147c478bd9Sstevel@tonic-gate$(GRUB)		:= LDFLAGS += $(LDLIBS.cmd)
157c478bd9Sstevel@tonic-gate$(GRUB)		:= CCLD = $(CC)
167c478bd9Sstevel@tonic-gate
1724da5b34Srie#
1824da5b34Srie# The grub shell interposes on the getopt() family.  Should direct bindings be
1924da5b34Srie# enabled, these interfaces should be explicitly defined as interposes.  Use a
2024da5b34Srie# mapfile to associate the necessary interposer definitions.
2124da5b34Srie#
2224da5b34SrieMAPFILES	= $(MAPFILE.INT)
2324da5b34Srie
247c478bd9Sstevel@tonic-gateINCLUDES	= -I. -I.. -I../stage1 -I../stage2 -I../lib
257c478bd9Sstevel@tonic-gateCFLAGS		+= -O2
2624da5b34SrieLINKFLAGS	+= -O2 $(MAPFILES:%=-Wl,-M%)
277c478bd9Sstevel@tonic-gateCPPFLAGS	+= -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
287c478bd9Sstevel@tonic-gate		   -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 \
29b1b8ab34Slling		   -DFSYS_REISERFS=1 -DFSYS_ZFS=1 -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 \
307c478bd9Sstevel@tonic-gate		   -DFSYS_XFS=1 -DUSE_MD5_PASSWORDS=1 -DSUPPORT_HERCULES=1 \
317c478bd9Sstevel@tonic-gate		   -DSUPPORT_SERIAL=1
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gatePROGRAMS	= $(GRUB)
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gateINSTALL_DIR	= $(ROOT_BOOT_GRUB)/bin
367c478bd9Sstevel@tonic-gateINSTALL_TARGETS	= $(PROGRAMS:%=$(INSTALL_DIR)/%)
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate$(INSTALL_DIR)/% := FILEMODE = 0555
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate#
417c478bd9Sstevel@tonic-gate# Source files to be installed in $(SRC_DIR).
427c478bd9Sstevel@tonic-gate#
437c478bd9Sstevel@tonic-gateSRC_DIR		= $(ROOT_SRC)/grub
447c478bd9Sstevel@tonic-gateSRC_FILES	= Makefile.am Makefile.in asmstub.c main.c
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gateINSTALL_TARGETS	+= $(SRC_FILES:%=$(SRC_DIR)/%)
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gateall: $(PROGRAMS)
507c478bd9Sstevel@tonic-gate
5124da5b34Srie$(GRUB): $(GRUB_OBJS) $(MAPFILES)
527c478bd9Sstevel@tonic-gate	$(LINK) -o $@ $(GRUB_OBJS) $(LIBS)
537c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate$(GRUB_OBJS): $$(@:.o=.c)
567c478bd9Sstevel@tonic-gate	$(CC) $(CFLAGS) -c -o $@ $(@:.o=.c)
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gateinstall: all $(INSTALL_TARGETS)
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate$(INSTALL_DIR)/%: $(INSTALL_DIR) %
627c478bd9Sstevel@tonic-gate	$(INS.file)
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate$(SRC_DIR)/%: $(SRC_DIR) %
657c478bd9Sstevel@tonic-gate	$(INS.file)
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate$(INSTALL_DIR) $(SRC_DIR):
687c478bd9Sstevel@tonic-gate	$(INS.dir)
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gateclean: _FORCE
72c6fe1048Sjongkis	$(RM) *.o
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gateclobber: clean
75c6fe1048Sjongkis	$(RM) $(PROGRAMS)
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate_FORCE:
78