📄 makefile
字号:
VERSION=1.4.3EXTRAVERSION=TARVERSION=1.4.3# spec file can overrideRPMVERSION=$(VERSION)# If you don't have either nasm or the ELKS as86, then just do make# and make install because the assembler sources are supplied preassembled# If you do make realclean you will have to unpack the mknbi archive again# Use nasm or as86ASM=nasm# This must be the as86 from the ELKS project, the default Linux one won't do#ASM=as86# for first32*.linux# This one makes multiple versionsFIRSTRELOCS= 0x92800 0x82800OLDGAS:= $(shell $(AS) --version | grep -q '2\.9\.1' && echo -DGAS291)CFLAGS= -I. -Os -ffreestanding -fstrength-reduce -fomit-frame-pointer \ -mcpu=i386 \ -Wall -W -Wno-format -Wno-unused -DVERSION=\"$(VERSION)$(EXTRAVERSION)\"LDBINARYFLAG= --oformat binaryFIRST32SIZE= 6144# for first32dosF32DRELOC=0x93000# for FreeDOSFDKSEG= 0x60# for menuMENURELOC= 0x60000# Options for auxiliary menu program# Available: -DANSIESC -DMOTD -DUSRPARMS -DPASSWD# -DCONSOLE_CRT -DCONSOLE_SERIAL -DSHOW_NUMERIC -DPOWERSAVE# Might as well take the lot since code size is not a concern# Must pick ANSIMODE=1 if ANSIESC is chosenBOOTMENU_FLAGS= -DCONSOLE_CRT -DANSIESC -DANSIMODE=1 -DMOTD -DUSRPARMS -DPASSWD -DPOWERSAVE -DCOMCONSOLE=0x3f8 -DCOMPRESERVEPREFIX= /usr/localINSTPREFIX= $(BUILD_ROOT)$(PREFIX)LIBDIR= $(PREFIX)/lib/mknbiINSTLIBDIR= $(INSTPREFIX)/lib/mknbiBINDIR= $(INSTPREFIX)/binMANDIR= $(INSTPREFIX)/share/man/man1DOCDIR= $(INSTPREFIX)/share/doc/mknbi-$(RPMVERSION)INSTALL= installPROG= mknbi disnbi dismbr disdosbb nbitoelfMODULES=Nbi.pm Elf.pm TruncFD.pmFIRSTS= $(foreach i,$(FIRSTRELOCS),first32@$(i).linux first32elf@$(i).linux) \ first.dos first.fdos menu nflALTBOOT=altboot.binRMRD= rmrd.comMANS= mknbi.1 disnbi.1 menuc.1HTMLS= mknbi.html disnbi.html menuc.htmlDOCS= $(MANS) $(HTMLS)all: $(PROG) $(FIRSTS) $(RMRD) $(DOCS)# Tagged image buildermknbi: mknbi.pl Nbi.pm TruncFD.pm perl -ne 's|\@\@VERSION\@\@|$(VERSION)|; s|\@\@LIBDIR\@\@|$(LIBDIR)|; s|\@\@FDKSEG\@\@|$(FDKSEG)|; print $$_;' mknbi.pl > $@ chmod 755 $@# Tagged image display and disassembledisnbi: disnbi.pl cp -p disnbi.pl disnbi chmod 755 disnbi# Master boot record displaydismbr: dismbr.pl cp -p dismbr.pl dismbr chmod 755 dismbr# DOS boot block displaydisdosbb: disdosbb.pl cp -p disdosbb.pl disdosbb chmod 755 disdosbb# NBI to ELF converternbitoelf: nbitoelf.pl cp -p nbitoelf.pl nbitoelf chmod 755 nbitoelf# 32-bit first stage protected mode call setup programfirst32@%.linux: start32@%.o first32.o memsizes.o printf.o $(LD) -N -Ttext $* -e _start $(LDBINARYFLAG) -o $@ start32@$*.o first32.o memsizes.o printf.o @if [ `wc -c < $@` -gt $(FIRST32SIZE) ]; then echo Binary too large; fi# 32-bit first stage ELF setup programfirst32elf@%.linux: start32@%.o first32elf.o memsizes.o printf.o $(LD) -N -Ttext $* -e _start $(LDBINARYFLAG) -o $@ start32@$*.o first32elf.o memsizes.o printf.o @if [ `wc -c < $@` -gt $(FIRST32SIZE) ]; then echo Binary too large; fi# 32-bit first stage ELF DOS setup programfirst32elf@%.dos: start32@%.o first32dos.o printf.o $(LD) -N -Ttext $* -e _start $(LDBINARYFLAG) -o $@ start32@$*.o first32dos.o printf.ostart32@%.o: start32.S gcc -E -DRELOC=$* $(OLDGAS) start32.S | $(AS) -o start32@$*.ofirst32.o: first32.c etherboot.h start32.h gcc $(CFLAGS) -o first32.o -c first32.cfirst32elf.o: first32.c etherboot.h start32.h gcc $(CFLAGS) -DFIRST32ELF -o first32elf.o -c first32.cfirst32dos.o: first32.c etherboot.h start32.h gcc $(CFLAGS) -DRELOC=$(F32DRELOC) -DFIRST32DOS -DFIRST32ELF -o first32dos.o -c first32.cmemsizes.o: memsizes.c gcc $(CFLAGS) -c $*.cprintf.o: printf.c gcc $(CFLAGS) -c $*.c# DOS first stage setup program, depend on Makefile for version numberfirst.dos: first-dos.S first-dos.h version-dos.h Makefileifeq ($(ASM),as86) gcc $(ASMCFLAGS) -DUSE_AS86 -DVENDOR_MAGIC=\"mknbi-dos-$(VERSION)\" -E -traditional -o first-dos.s first-dos.S as86 -0 -b first.dos first-dos.selse gcc $(ASMCFLAGS) -DUSE_NASM -DVENDOR_MAGIC=\"mknbi-dos-$(VERSION)\" -E -traditional -o first-dos.s first-dos.S nasm -f bin first-dos.s -o first.dosendif# FreeDOS first stage setup program, depend on Makefile for version numberfirst.fdos: first-dos.S first-dos.h version-dos.h Makefileifeq ($(ASM),as86) gcc $(ASMCFLAGS) -DFREEDOS -DFDKSEG=$(FDKSEG) -DUSE_AS86 -DVENDOR_MAGIC=\"mknbi-fdos-$(VERSION)\" -E -traditional -o first-fdos.s first-dos.S as86 -0 -b first.fdos first-fdos.selse gcc $(ASMCFLAGS) -DFREEDOS -DFDKSEG=$(FDKSEG) -DUSE_NASM -DVENDOR_MAGIC=\"mknbi-fdos-$(VERSION)\" -E -traditional -o first-fdos.s first-dos.S nasm -f bin first-fdos.s -o first.fdosendiffirst-elf.dos: first.dos first32elf@$(F32DRELOC).dos cat first.dos first32elf@$(F32DRELOC).dos > first-elf.dosfirst-elf.fdos: first.fdos first32elf@$(F32DRELOC).dos cat first.fdos first32elf@$(F32DRELOC).dos > first-elf.fdos# Menu first stage programmenu: startmenu.o menu.o bootmenu.o string.o printf.o ansiesc.o md5.o misc.o serial.o $(LD) -N -Ttext $(MENURELOC) -e _start $(LDBINARYFLAG) -o $@ startmenu.o menu.o bootmenu.o string.o printf.o ansiesc.o md5.o misc.o serial.o# Another menu program, this one simplermenu-simple: startmenu.o menu-simple.o string.o printf.o ansiesc.o $(LD) -N -Ttext $(MENURELOC) -e _start $(LDBINARYFLAG) -o $@ startmenu.o menu-simple.o string.o printf.o ansiesc.o# Network FreeLoader (light-bar menu program)nfl: startmenu.o nfl.o string.o printf.o ansiesc.o $(LD) -N -Ttext $(MENURELOC) -e _start $(LDBINARYFLAG) -o $@ startmenu.o nfl.o string.o printf.o ansiesc.o# LUA interpreterlua/bin/lua: cd lua; makestartmenu.o: startmenu.S startmenu.h gcc -E -Ui386 -DRELOC=$(MENURELOC) $(OLDGAS) startmenu.S | $(AS) -o startmenu.omenu.o: menu.c stddef.h string.h printf.h ansiesc.h \ misc.h linux-asm-io.h etherboot.h gcc $(CFLAGS) $(BOOTMENU_FLAGS) -c $*.cbootmenu.o: bootmenu.h bootmenu.c stddef.h string.h md5.h misc.h etherboot.h start32.h gcc $(CFLAGS) $(BOOTMENU_FLAGS) -c $*.cstring.o: string.h string.c gcc $(CFLAGS) -c $*.cansiesc.o: ansiesc.h ansiesc.c stddef.h string.h etherboot.h gcc $(CFLAGS) -DGFX -c $*.cmd5.o: md5.h md5.c etherboot.h gcc $(CFLAGS) $(BOOTMENU_FLAGS) -c $*.cmisc.o: misc.h misc.c ansiesc.h etherboot.h start32.h gcc $(CFLAGS) $(BOOTMENU_FLAGS) -c $*.cserial.o: serial.c gcc $(CFLAGS) $(BOOTMENU_FLAGS) -c $*.cmenu-simple.o: menu-simple.h menu-simple.c string.h etherboot.h gcc $(CFLAGS) -c $*.c# Remove ramdisk utility under DOSrmrd.com: rmrd.Sifeq ($(ASM),as86) gcc $(ASMCFLAGS) -DUSE_AS86 -E -traditional -o rmrd.s rmrd.S # -s appears to be necessary to start binary at 0x100 as86 -0 -b rmrd.com -s rmrd.map rmrd.selse gcc $(ASMCFLAGS) -DUSE_NASM -E -traditional -o rmrd.s rmrd.S nasm -f bin rmrd.s -o rmrd.comendif# Alternate boot block, taken from netboot mknbi-dos# Not made by default because not everybody has as86 installed$(ALTBOOT): altboot.S gcc -E altboot.S > altboot.s as86 -s /dev/null -b $(ALTBOOT) altboot.s $(RM) altboot.s$(MANS): mknbi.pl disnbi.pl Makefile pod2man --date=`date +%Y-%m-%d` --release="Mknbi $(VERSION)$(EXTRAVERSION)" --center="Etherboot tools" mknbi.pl > mknbi.1 pod2man --date=`date +%Y-%m-%d` --release="Mknbi $(VERSION)$(EXTRAVERSION)" --center="Etherboot tools" disnbi.pl > disnbi.1 pod2man --date=`date +%Y-%m-%d` --release="Mknbi $(VERSION)$(EXTRAVERSION)" --center="Etherboot tools" menuc.pl > menuc.1$(HTMLS): mknbi.pl disnbi.pl pod2html mknbi.pl > mknbi.html pod2html disnbi.pl > disnbi.html pod2html menuc.pl > menuc.htmlinstall: all $(ALTBOOT) -mkdir -p $(INSTLIBDIR) $(INSTALL) $(PROG) $(INSTLIBDIR)/ $(INSTALL) -m 644 $(MODULES) $(FIRSTS) $(ALTBOOT) $(RMRD) $(INSTLIBDIR)/ if [ -e lua-4.0.1/bin/lua ]; then \ cp -p lua-4.0.1/bin/lua lua; \ fi if [ -e lua ]; then \ $(INSTALL) -m 644 lua $(INSTLIBDIR)/lua; \ fi -mkdir -p $(BINDIR) cd $(BINDIR); \ for i in linux rom fdos dos menu nfl; \ do \ ln -sf ../lib/mknbi/mknbi mknbi-$$i; \ done; \ for i in linux img menu nfl lua; \ do \ ln -sf ../lib/mknbi/mknbi mkelf-$$i; \ done (cd $(BINDIR); ln -sf ../lib/mknbi/disnbi disnbi) (cd $(BINDIR); ln -sf ../lib/mknbi/dismbr dismbr) (cd $(BINDIR); ln -sf ../lib/mknbi/disdosbb disdosbb) (cd $(BINDIR); ln -sf ../lib/mknbi/nbitoelf nbitoelf) -mkdir -p $(MANDIR) $(INSTALL) -m 644 mknbi.1 disnbi.1 $(MANDIR)/ cd $(MANDIR); \ for i in mkelf mknbi-linux mkelf-linux mknbi-rom mkelf-img mknbi-menu mkelf-menu mknbi-nfl mkelf-nfl mkelf-lua mknbi-dos mknbi-fdos; \ do \ ln -sf mknbi.1 $$i.1; \ done -mkdir -p $(DOCDIR) $(INSTALL) -m 644 README LOG spec.txt $(DOCDIR)/tarball: mkdir -p luabuild -diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1 lua-4.0.1 > luabuild/luapatch.txt (cd ..; tar zcf /tmp/mknbi-$(TARVERSION).tar.gz --exclude CVS --exclude lua-4.0.1 mknbi-$(TARVERSION))clean: $(RM) -f $(PROG) start32*.o first32*.o \ printf.o menu.o menu-simple.o nfl.o startmenu.o \ bootmenu.o md5.o misc.o serial.o ansiesc.o string.o memsizes.o \ first-dos.s first-fdos.s rmrd.s rmrd.map *.l pod2htm*realclean: clean $(RM) -f $(FIRSTS) $(RMRD) $(DOCS)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -