Makefile Errors - “***missing separator” & “***recipe commences before first target”

眉间皱痕 提交于 2019-12-25 05:19:14

问题


I am trying to build the userland for os161. When I type make in the command line I get the following error:

Makefile 24: ***missing separator (did you mean TAB instead of 8 spaces?). Stop.

I checked the Makefile at line 24 and tried adding a TAB to the start of the line, but that didn't work as I then get another error:

Makefile 24: ***recipe commences before first target. Stop.

Here is the full makefile for reference:

#
# Toplevel makefile for OS/161.
#
#
# Main rules:
#    all (default):  depend and compile system; install into staging area
#    rebuild:        likewise, but start with a clean slate.
#    fullrebuild:    likewise, but start with a very clean slate.
#
# What all does, in order:
#    tools:          depend and compile the tools used in build.
#    includes:       install header files.
#    build:          depend and compile the system.
#
# Other targets:
#    depend:         just update make dependency information.
#    tags:           generate/regenerate "tags" files.
#    install:        install into $(OSTREE).
#    clean:          remove generated files.
#    distclean:      remove all generated files.
#

TOP=.
.include "$(TOP)/mk/os161.config.mk"

all:;  # make this first

MKDIRS=$(OSTREE)

.include "$(TOP)/mk/os161.mkdirs.mk"

all: tools .WAIT includes .WAIT build

rebuild:
    $(MAKE) clean
    $(MAKE) all

fullrebuild:
    $(MAKE) distclean
    $(MAKE) all

# currently no tools required, hence no tools/ dir or work to do
tools:
    @true

build:
    (cd userland && $(MAKE) build)
    (cd man && $(MAKE) install-staging)
    (cd testscripts && $(MAKE) build)

includes tags depend:
    (cd kern && $(MAKE) $@)
    (cd userland && $(MAKE) $@)

clean:
    (cd kern && $(MAKE) $@)
    (cd userland && $(MAKE) $@)
    rm -rf $(INSTALLTOP)

distclean: clean
    rm -rf $(WORKDIR)

install: $(OSTREE)
    (cd $(INSTALLTOP) && tar -cf - .) | (cd $(OSTREE) && tar -xvf -)


.PHONY: all rebuild fullrebuild tools build includes tags depend
.PHONY: clean distclean

# old BSD name, same as distclean
cleandir: distclean
.PHONY: cleandir

The line is question (24) is:

.include "$(TOP)/mk/os161.config.mk"

Any help would be appreciated. I checked out similar makefile errors but I can't seem to find what's wrong.


回答1:


Read carefully documentation of GNU make, notably about the include directive.

Your

.include "$(TOP)/mk/os161.config.mk"

is (wrongly) requesting the inclusion of a file whose path starts with a double quote (and you probably don't have any, so the include fails ...)

You want

-include $(TOP)/mk/os161.config.mk

and that line starts with a minus sign or dash, not a dot.

Be sure to use an editor keeping tab characters intact.

BTW, the FreeBSD make accepts .include directives with starting dot and wants a path in double-quotes.




回答2:


A separator is a <TAB> . Please do not use spaces at line begin in a Makefile, Makefile.in ...

Snippet:

21  #
22  
23  
24  TOP=.
25  
26  all:;  # make this first
27  
28  MKDIRS=$(OSTREE)
29  
30  <TAB>include "$(TOP)/mk/os161.mkdirs.mk"
31  
32  all: tools .WAIT includes .WAIT build
33  
34  rebuild:
35  <TAB>$(MAKE) clean
36  <TAB>$(MAKE) all
37  
38  <TAB>fullrebuild:
39  <TAB>$(MAKE) distclean
40  <TAB>$(MAKE) all


来源:https://stackoverflow.com/questions/44081364/makefile-errors-missing-separator-recipe-commences-before-first-tar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!