Using make Command on OSX to compile application is quite useful as many OS X applications’ source code is distributed as Free Softwares while the dmg are paid. Definitely, this is not only the reason; there are much more reasons why we will use make command or rather compile fro source code. textmate, for example on Links CLI Based Browser With Graphics for OS X guide, we shown that without compiling, actually you can not use the software with all features. In other words, using make Command on OSX to compile application has many practical utility.
Using make Command on OSX to Compile Application : The History Behind
You can ignore this part if you are in a hurry for some reason and just want to see the practical part of using make Command on OSX to compile application, which is written below, this is how the make command came – the history of make Command. The make utility is part of the POSIX standards, its presently designated in IEEE Std 1003.1, 2008.
make is a build management tool that executes commands depending on conditions. It is mainly used in software development. make reads a so-called makefile in the dependencies of the translation process, which are recorded in formalized programs. This formalization describes the source files in which way the compiler or other programs process object files to the linker libraries or executable programs. All steps are carried out in accordance with the detected dependencies in the makefile. Originally make was created by Stuart Feldman in 1977 at Bell Labs, UNIX system consisted of operating system dependent “make” and “install” shell scripts accompanying their program’s source. Software, essentially were free or had a less fee. You can read the this part from Richard Stallman’s books, writings – how few companies introduced the close source software system. Right now we have pmake (BSD), GNU Make (FSF, Richard M. Stallman), Makepp (again GNU and FSF) and nmake (Microsoft’s, difficult to compare with other make due to restricted features). POSIX includes standardization of the basic features and operation of the make utility.
Using make Command on OSX to Compile Application : The Practical Part
OS X uses GNU autoconf, automake, or autoheader :
You can run the command :
on iTerm2 or Terminal App in OS X, you will see the POSIX thing in output :
Other things you can see, we have marked on the screen shot. If you getting trouble to use make command, be sure to run this command :
Also be certain to update your ~/.bashrc (or ~/.profile or ~/.bash_login) file. Definitely, it is must to install XCode. This is easy way – its a part of Conditional Compilation on OS X as Mac has various CPU structures. You can run :
command to check the status of make – usually it will show the path. If you have Xcode 4.3 or newer the command line tools, such as make, are not installed by default. In Xcode preferences go to the “Downloads” tab and under “Components” push the “Install” button next to “Command Line Tools”. After you have successfully downloaded and installed the command line tools you should also type the following command in the Terminal to make sure all your Xcode command line tools are switched to use the 4.3 versions:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Note that from within Terminal you can use the XCRUN tool to launch compilers and other tools embedded within the Xcode application. Use the XCODE-SELECT tool to define which version of Xcode is active. Type “man xcrun” from within Terminal to find out more.
A GNU Make source tarball contains a build.sh script to resolve this. If you need to build GNU Make and have no other make program to use, you can use the shell script build.sh instead. To do this, first run configure as described in INSTALL. Then, instead of typing make to build the program, type sh build.sh. This should compile the program in the current directory. Then you will have a Make program that you can use for ./make install, or whatever else.
Do not apply all the methods together.
Using make Command on OSX to Compile Application : Example
The steps will install memcached and available at /usr/local/bin/memcached :
curl -O http://www.monkey.org/~provos/libevent-1.4.14-stable.tar.gz
tar xzvf libevent-1.4.14-stable.tar.gz
sudo make install
curl -O http://memcached.googlecode.com/files/memcached-1.4.10.tar.gz
tar xzvf memcached-1.4.10.tar.gz
sudo make install