Утилита make для windows
GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program’s source files.
Make gets its knowledge of how to build your program from a file called the makefile, which lists each of the non-source files and how to compute it from other files. When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program.
Capabilities of Make
- Make enables the end user to build and install your package without knowing the details of how that is done — because these details are recorded in the makefile that you supply.
- Make figures out automatically which files it needs to update, based on which source files have changed. It also automatically determines the proper order for updating files, in case one non-source file depends on another non-source file.
As a result, if you change a few source files and then run Make, it does not need to recompile all of your program. It updates only those non-source files that depend directly or indirectly on the source files that you changed.
Make Rules and Targets
A rule in the makefile tells Make how to execute a series of commands in order to build a target file from source files. It also specifies a list of dependencies of the target file. This list should include all files (whether source files or other targets) which are used as inputs to the commands in the rule.
Here is what a simple rule looks like:
When you run Make, you can specify particular targets to update; otherwise, Make updates the first target listed in the makefile. Of course, any other target files needed as input for generating these targets must be updated first.
Make uses the makefile to figure out which target files ought to be brought up to date, and then determines which of them actually need to be updated. If a target file is newer than all of its dependencies, then it is already up to date, and it does not need to be regenerated. The other target files do need to be updated, but in the right order: each target file must be regenerated before it is used in regenerating other targets.
Advantages of GNU Make
GNU Make has many powerful features for use in makefiles, beyond what other Make versions have. It can also regenerate, use, and then delete intermediate files which need not be saved.
GNU Make also has a few simple features that are very convenient. For example, the -o file option which says «pretend that source file file has not changed, even though it has changed.» This is extremely useful when you add a new macro to a header file. Most versions of Make will assume they must therefore recompile all the source files that use the header file; but GNU Make gives you a way to avoid the recompilation, in the case where you know your change to the header file does not require it.
However, the most important difference between GNU Make and most versions of Make is that GNU Make is free software.
Makefiles And Conventions
We have developed conventions for how to write Makefiles, which all GNU packages ought to follow. It is a good idea to follow these conventions in your program even if you don’t intend it to be GNU software, so that users will be able to build your package just like many other packages, and will not need to learn anything special before doing so.
Downloading Make
Make can be found on the main GNU ftp server: http://ftp.gnu.org/gnu/make/ (via HTTP) and ftp://ftp.gnu.org/gnu/make/ (via FTP). It can also be found on the GNU mirrors; please use a mirror if possible.
Documentation
Documentation for Make is available online, as is documentation for most GNU software. You may also find more information about Make by running info make or man make, or by looking at /usr/share/doc/make/, /usr/local/doc/make/, or similar directories on your system. A brief summary is available by running make —help.
Mailing lists
Make has the following mailing lists:
- bug-make is used to discuss most aspects of Make, including development and enhancement requests, as well as bug reports.
- help-make is for general user help and discussion.
Announcements about Make and most other GNU software are made on info-gnu (archive).
Security reports that should not be made immediately public can be sent directly to the maintainer. If there is no response to an urgent issue, you can escalate to the general security mailing list for advice.
Getting involved
Development of Make, and GNU in general, is a volunteer effort, and you can contribute. For information, please read How to help GNU. If you’d like to get involved, it’s a good idea to join the discussion mailing list (see above).
Test releases Trying the latest test release (when available) is always appreciated. Test releases of Make can be found at http://alpha.gnu.org/gnu/make/ (via HTTP) and ftp://alpha.gnu.org/gnu/make/ (via FTP). Development For development sources, issue trackers, and other information, please see the Make project page at savannah.gnu.org. Translating Make To translate Make’s messages into other languages, please see the Translation Project page for Make. If you have a new translation of the message strings, or updates to the existing strings, please have the changes made in this repository. Only translations from this site will be incorporated into Make. For more information, see the Translation Project. Maintainer Make is currently being maintained by Paul Smith. Please use the mailing lists for contact.
Licensing
Make is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
“The Free Software Foundation (FSF) is a nonprofit with a worldwide mission to promote computer user freedom. We defend the rights of all software users.”
Please send general FSF & GNU inquiries to . There are also other ways to contact the FSF. Broken links and other corrections or suggestions can be sent to .
For information on coordinating and submitting translations of our web pages, see Translations README. —> Please see the Translations README for information on coordinating and submitting translations of this article.
Copyright © 2019 Free Software Foundation, Inc.
Make for Windows
Make: GNU make utility to maintain groups of programs
Version
Description
Make is a tool which controls the generation of executables and other non-source files of a program from the program’s source files. Make gets its knowledge of how to build your program from a file called the makefile, which lists each of the non-source files and how to compute it from other files. When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program.
Capabilities of Make
- Make enables the end user to build and install your package without knowing the details of how that is done — because these details are recorded in the makefile that you supply.
- Make figures out automatically which files it needs to update, based on which source files have changed. It also automatically determines the proper order for updating files, in case one non-source file depends on another non-source file. As a result, if you change a few source files and then run Make, it does not need to recompile all of your program. It updates only those non-source files that depend directly or indirectly on the source files that you changed.
- Make is not limited to any particular language. For each non-source file in the program, the makefile specifies the shell commands to compute it. These shell commands can run a compiler to produce an object file, the linker to produce an executable, ar to update a library, or TeX or Makeinfo to format documentation.
- Make is not limited to building a package. You can also use Make to control installing or deinstalling a package, generate tags tables for it, or anything else you want to do often enough to make it worth while writing down how to do it.
Homepage
Download
If you download the Setup program of the package, any requirements for running applications, such as dynamic link libraries (DLL’s) from the dependencies as listed below under Requirements, are already included. If you download the package as Zip files, then you must download and install the dependencies zip file yourself. Developer files (header files and libraries) from other packages are however not included; so if you wish to develop your own applications, you must separately install the required packages.
Description | Download | Size | Last change | Md5sum |
---|---|---|---|---|
• Complete package, except sources | Setup | 3384653 | 25 November 2006 | 8ae51379d1f3eef8360df4e674f17d6d |
• Sources | Setup | 1252948 | 25 November 2006 | b896c02e3d581040ba1ad65024bbf2cd |
• Binaries | Zip | 495645 | 25 November 2006 | 3521948bc27a31d1ade0dcb23be16d49 |
• Dependencies | Zip | 708206 | 25 November 2006 | d370415aa924fa023411c4099ef84563 |
• Documentation | Zip | 2470575 | 25 November 2006 | 43a07e449d4bab3eb3f31821640ecab7 |
• Sources | Zip | 2094753 | 25 November 2006 | 8bed4cf17c5206f8094f9c96779be663 |
You can also download the files from the GnuWin32 files page.
You can monitor new releases of the port of this package.
C Урок 20. MAKE. Наш первый Makefile. Часть 1
До сих пор мы для сборки нашей программы пользовались командным файлом, объединяющим в себе команды для препроцессинга, компиляции, ассемблирования, компоновки файлов в исполняемый файл. Так тоже делать можно и зачастую так и делается, если дело касается проектов, которые содержат в себе малое количество модулей, а также не требующих какой-то автоматизации процесса сборки.
Но для более грамотной работы с проектом существуют сценарии, работа с которыми осуществляется в утилите Make.
Make – это утилита, предназначенная для сборки проектов, автоматически определяющая, какие части большой программы должны быть перекомпилированы, и выполняет необходимые для этого действия.
Утилита Make работает с файлами сценариев, в которых описывается, какие цели мы перед собой ставим при сборке нашего проекта, а также то, каким путём мы этих целей будем добиваться. Также в файлах сценариев поддерживается очень много всего, что описать в рамках одного занятия невозможно. Поэтому в данном уроке мы проведём только очень краткое знакомство с написанием данных сценариев, создадим такой сценарий, который поможет нам собрать наш проект и увидим, что изменилось по сравнению с использованием командных файлов для сборки проектов, какие у нас появились новые возможности благодаря использованию утилиты Make.
Так как мы работаем с системой сборки MinGW, основанной на системе GNU, соответственно, и утилита Make будет также из этой системы.
Авторами GNU make являются Richard Stallman и Roland McGrath. Начиная с версии 3.76, разработкой программы руководит Paul D. Smith.
Чтобы использовать Make, мы даём одноимённую команду в командной строке, либо добавляем её в среду разработки. Так как данная команда расположена в комплекте MinGW в виде исполняемого файла mingw32-make.exe, то мы будем использовать одноимённую команду «mingw32-make». Можно конечно сделать дубликат в папке с данной утилитой и назвать её make.exe для упрощения ввода команды, только мы этого делать не будем во избежание конфликтов имён с другими подобными утилитами, которые вполне могут быть использованы в наших операционных системах. В качестве параметра к данной команде используется обычно имя файла сценария и при этом перед именем данного файла используется ключ -f. Но если назвать файл сценария Makefile или makefile, то никаких ключей и параметров не потребуется, так как это имя файла сценария по умолчанию для make.
В файле сценария обязательно должно присутствовать хотя бы одно правило.
Правило состоит из цели, зависимостей или пререквизитов, обязательных для достижения цели, а также одной или нескольких команд, которые для достижения данной цели будут выполняться.
Команды перечисляются каждая с новой строки. Перед каждой такой командой мы используем табуляцию. Без этого сценарий работать не будет.
В качестве команд используются обычные команды оболочки Shell. Все используемые команды будут выводиться в командной строке. Если же мы ходим, чтобы тексты команд не выводились в консоли, то мы используем перед командой символ ‘@‘.
Когда мы запускаем утилиту make с командной строки, то помимо имени файла с ключом мы можем указать имя цели, которую мы хотим выполнить в сценарии. Если не ввести имя цели, то выполнится либо цель с именем all либо самая первая в файле сценария цель.
В качестве пререквизитов (зависимостей) как правило используются другие цели, представляющие собой, как правило, имена файлов. Также могут использоваться и фиктивные цели. Но об этом не в данном уроке.
Чтобы было немного понятнее, давайте поработаем всё-таки с утилитой Make на практике.
Создадим проект, как и прежде, из проекта прошлого занятия с именем MYPROG19 и присвоим ему имя MYPROG20.
Файл build.cmd можно будет теперь удалить. clean.cmd пока оставим.
Тексты исходников не трогаем. Задача наше сегодня – не писать новый код, а использовать существующий, но собрать его мы должны уже с помощью утилиты Make.
Все лишние файлы из папки с нашей программой должны быть удалены, должны остаться только файлы с исходными текстами. Если это не так, то дадим команду clean.