Все Make-файлы повреждаются

Я не могу больше выполнять Make-файлы. Я добираюсь:

./Makefile: line 1: sorter:: command not found

Содержание make-файла:

sorter: sorter.o
    gcc sorter.o -o sorter

sorter.o: sorter.c
    gcc -c sorter.c

test:
    ./run_test

check:
    c_style_check sorter.c

clean:
    rm -f sorter *.o

То, что удивительно, - то, что все мои Make-файлы раньше хорошо работали только вчера. Я не знаю то, что произошло, я думаю, что мой Lubuntu имел обновление, но это было им.

3
задан 15 October 2017 в 16:49

1 ответ

Ошибка происходит, потому что Вы ожидаете, что Ваша оболочка будет понимать и петлять.

Make-файлы не предназначены, чтобы быть исполняемым файлом - им дают как исходные данные к эти make команда, например, make -f Makefile - или всего make, так как это будет искать текущий каталог файл с именами по умолчанию как Makefile, makefile.

От man make:

   To  prepare to use make, you must write a file called the makefile that
   describes the relationships among files in your program, and the states
   the  commands for updating each file.  In a program, typically the exe‐
   cutable file is updated from object files, which are in  turn  made  by
   compiling source files.

   Once  a  suitable  makefile  exists,  each  time you change some source
   files, this simple shell command:

          make

   suffices to perform all necessary  recompilations.   The  make  program
   uses  the  makefile  description and the last-modification times of the
   files to decide which of the files need to be  updated.   For  each  of
   those files, it issues the commands recorded in the makefile.

   make  executes  commands  in  the makefile to update one or more target
   names, where name is typically a program.  If no -f option is  present,
   make  will  look for the makefiles GNUmakefile, makefile, and Makefile,
   in that order.
7
ответ дан 1 December 2019 в 13:23

Другие вопросы по тегам:

Похожие вопросы: