17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate# Use is subject to license terms.
47c478bd9Sstevel@tonic-gate#
5*f52943a9SAndy Fiddaman# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
67c478bd9Sstevel@tonic-gate#
77c478bd9Sstevel@tonic-gateinclude ../../Makefile.grub
87c478bd9Sstevel@tonic-gateinclude ../Makefile.solaris.defs
97c478bd9Sstevel@tonic-gate
107c478bd9Sstevel@tonic-gate.SUFFIXES:
117c478bd9Sstevel@tonic-gate.SUFFIXES: .exec $(SUFFIXES)
127c478bd9Sstevel@tonic-gate
137c478bd9Sstevel@tonic-gate.exec:
147c478bd9Sstevel@tonic-gate	$(OBJCOPY) -O binary $< $@
157c478bd9Sstevel@tonic-gate
167c478bd9Sstevel@tonic-gateINCLUDES	= -I. -I..
177c478bd9Sstevel@tonic-gateCCASFLAGS	+= -O2 -fno-builtin -nostdinc
18*f52943a9SAndy FiddamanLDFLAGS		+= -nostdlib -N -Ttext 7C00 $(GLDTARGET)
197c478bd9Sstevel@tonic-gateLIBS		=
207c478bd9Sstevel@tonic-gate
217c478bd9Sstevel@tonic-gate
227c478bd9Sstevel@tonic-gateDATA		= $(STAGE1_DATA)
237c478bd9Sstevel@tonic-gatePROGRAMS	= $(STAGE1_EXEC)
247c478bd9Sstevel@tonic-gate
257c478bd9Sstevel@tonic-gateSTAGE1_DATA	= stage1
267c478bd9Sstevel@tonic-gateSTAGE1_EXEC	= stage1.exec
277c478bd9Sstevel@tonic-gateSTAGE1_ASMOBJS	= stage1.o
287c478bd9Sstevel@tonic-gateSTAGE1_OBJS	=
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gateINSTALL_TARGETS	= $(DATA:%=$(ROOT_BOOT_GRUB)/%)
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate#
337c478bd9Sstevel@tonic-gate# Source files to be installed in $(SRC_DIR).
347c478bd9Sstevel@tonic-gate#
357c478bd9Sstevel@tonic-gateSRC_DIR		= $(ROOT_SRC)/stage1
367c478bd9Sstevel@tonic-gateSRC_FILES	= Makefile.am Makefile.in stage1.S stage1.h
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gateINSTALL_TARGETS	+= $(SRC_FILES:%=$(SRC_DIR)/%)
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gateall: $(PROGRAMS) $(DATA)
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate$(STAGE1_EXEC): $(STAGE1_ASMOBJS) $(STAGE1_OBJS)
457c478bd9Sstevel@tonic-gate	$(RM) $@
467c478bd9Sstevel@tonic-gate	$(LINK) -o $@ $(STAGE1_ASMOBJS) $(STAGE1_OBJS) $(LIBS)
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate$(STAGE1_ASMOBJS): $$(@:.o=.S)
497c478bd9Sstevel@tonic-gate	$(CCAS) $(CCASFLAGS) -c -o $@ $(@:.o=.S)
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate$(STAGE1_OBJS): $$(@:.o=.c)
527c478bd9Sstevel@tonic-gate	$(CC) $(CFLAGS) -c -o $@ $(@:.o=.c)
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gateinstall: all $(INSTALL_TARGETS)
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate$(ROOT_BOOT_GRUB)/%: $(ROOT_BOOT_GRUB) %
587c478bd9Sstevel@tonic-gate	$(INS.file)
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate$(SRC_DIR)/%: $(SRC_DIR) %
617c478bd9Sstevel@tonic-gate	$(INS.file)
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate$(ROOT_BOOT_GRUB) $(SRC_DIR):
647c478bd9Sstevel@tonic-gate	$(INS.dir)
657c478bd9Sstevel@tonic-gate
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gateclean: _FORCE
68c6fe1048Sjongkis	$(RM) *.o $(PROGRAMS)
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gateclobber: clean
71c6fe1048Sjongkis	$(RM) $(DATA)
727c478bd9Sstevel@tonic-gate
737c478bd9Sstevel@tonic-gate_FORCE:
74