开发者

What's the `./configure` command?

开发者 https://www.devze.com 2023-04-04 10:10 出处:网络
I usually see ./configure to build something. It looks a开发者_开发技巧 script produced by a tool. And today, I realized that I don\'t know what that is.

I usually see ./configure to build something. It looks a开发者_开发技巧 script produced by a tool. And today, I realized that I don't know what that is.

What's this? What's the role of this script, and who does make this? And how can I make something like that?


Every system is different. For example, there are different compilers and compiler versions, the tools of your system might support certain flags (or not), you might have certain libraries installed or not, etc. pp. There a lots of things that are different on computers that might influence how to compile a project.

The configure script tries to figure out all these things and complain if prerequisites aren't met (for example, when the compiler is missing or when a library is missing). It then generates a Makefile that is specific to your system, and just typing make will (hopefully) build the project correctly on your system.

Prior to configure, we had to hand-tune the Makefiles (often the tunable parts were offset into a separate Makefile). This meant that you needed to know a lot about your system and often that you needed to modify the Makefiles. It was a big hurdle, especially since almost every project did it differently. GNU autoconf and automake (which parse the Makefile.am and configure.ac files to generate Makefile.in and configure scripts) really simplified things here (especially if you're doing exotic things like cross-compiling for which almost no project cares to add support; if you're doing autoconf/automake in a clean manner than you get cross-compile support for free, for example).


It's usually a script created by GNU autoconf. Other build tools might use the same name too. Autoconf is quite a complex tool, but there's several short tutorials available on the web. I like this one: http://www.edwardrosten.com/code/autoconf/index.html


GNU Autoconf Autoconf generates a configure script based on the contents of a configure.ac file which characterizes a particular body of source code. The configure script, when run, scans the build environment and generates a subordinate config.status script which, in turn, converts other input files and most commonly Makefile.in into output files (Makefile) which are appropriate for that build environment. Finally the make program uses Makefile to generate executable programs from source code.

http://en.wikipedia.org/wiki/GNU_build_system

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号