注册 登录
编程论坛 Ubuntu

makefile遇到问题

初学编程的人 发布于 2017-10-07 21:35, 3945 次点击
执行makefile出现如下提示
boot/include/fat12hdr.inc boot/include/pm.inc
: not founde/fat12hdr.inc: 1: boot/include/fat12hdr.inc:
: not founde/fat12hdr.inc: 2: boot/include/fat12hdr.inc:
boot/include/fat12hdr.inc: 3: boot/include/fat12hdr.inc: Syntax error: ";" unexpected
make: *** [boot/loader.bin] Error 2

编译环境 VMware下32位Ubuntu
找不出错误原因

makefile文件如下
程序代码:

#########################

# Makefile for Orange'S #

#########################



# Entry point of Orange'S

# It must have the same value with 'KernelEntryPointPhyAddr' in load.inc!

ENTRYPOINT    = 0x30400



# Offset of entry point in kernel file

# It depends on ENTRYPOINT

ENTRYOFFSET    =   0x400



# Programs, flags, etc.

ASM        = nasm

DASM        = ndisasm

CC        = gcc

LD        = ld

ASMBFLAGS    = -I boot/include/

ASMKFLAGS    = -I include/ -f elf

CFLAGS        = -I include/ -c -fno-builtin

LDFLAGS        = -s -Ttext $(ENTRYPOINT)

DASMFLAGS    = -u -o $(ENTRYPOINT) -e $(ENTRYOFFSET)



# This Program

ORANGESBOOT    = boot/boot.bin boot/loader.bin

ORANGESKERNEL    = kernel.bin

OBJS        = kernel/kernel.o kernel/start.o lib/kliba.o lib/string.o

DASMOUTPUT    = kernel.bin.asm



# All Phony Targets

.PHONY : everything final image clean realclean disasm all buildimg



# Default starting position

everything : $(ORANGESBOOT) $(ORANGESKERNEL)



all : realclean everything



final : all clean



image : final buildimg



clean :

    rm -f $(OBJS)



realclean :

    rm -f $(OBJS) $(ORANGESBOOT) $(ORANGESKERNEL)



disasm :

    $(DASM) $(DASMFLAGS) $(ORANGESKERNEL) > $(DASMOUTPUT)



# We assume that "a.img" exists in current folder

buildimg :

    dd if=boot/boot.bin of=a.img bs=512 count=1 conv=notrunc

    sudo mount -o loop a.img /mnt/floppy/

    sudo cp -fv boot/loader.bin /mnt/floppy/

    sudo cp -fv kernel.bin /mnt/floppy

    sudo umount /mnt/floppy



boot/boot.bin : boot/boot.asm boot/include/load.inc boot/include/fat12hdr.inc

    $(ASM) $(ASMBFLAGS) -o $@ $<



boot/loader.bin : boot/loader.asm boot/include/load.inc \

            boot/include/fat12hdr.inc boot/include/pm.inc

    $(ASM) $(ASMBFLAGS) -o $@ $<



$(ORANGESKERNEL) : $(OBJS)

    $(LD) $(LDFLAGS) -o $(ORANGESKERNEL) $(OBJS)



kernel/kernel.o : kernel/kernel.asm

    $(ASM) $(ASMKFLAGS) -o $@ $<



kernel/start.o : kernel/start.c include/type.h include/const.h include/protect.h

    $(CC) $(CFLAGS) -o $@ $<



lib/kliba.o : lib/kliba.asm

    $(ASM) $(ASMKFLAGS) -o $@ $<



lib/string.o : lib/string.asm

    $(ASM) $(ASMKFLAGS) -o $@ $<
4 回复
#2
初学编程的人2017-10-09 23:54
有没有老师教一下,代码是复制的教学代码肯定没错,如果文件都放在一个文件夹里面,换一个makefile就没问题,有了文件夹就出现这种问题了,明明文件夹里fat12hdr.inc是存在的,可就是提示not found。已经卡了两天了,这问题百度不到,make手册下载了,看了出错提示部分也没提到这类错误
#3
初学编程的人2017-10-15 00:10
boot/loader.bin : boot/loader.asm boot/include/load.inc \

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boot/include/fat12hdr.inc boot/include/pm.inc
出错原因是反斜杠链接符后面不能有空行,超郁闷这个小问题卡这么久。
boot/loader.bin : boot/loader.asm boot/include/load.inc \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boot/include/fat12hdr.inc boot/include/pm.inc
这样写就没问题,看来不能100%相信下载的代码
#4
初学编程的人2017-10-15 12:44
从github上复制代码到windows的记事本时行与行之间会被自动加上空行,有谁能解释一下这是什么原因么?
make程序不能自动跳过空行,这么做的原因是啥?
#5
初学编程的人2017-10-15 17:38
错了,编辑掉

[此贴子已经被作者于2017-10-15 18:31编辑过]

1