TECHNOLOGY
- Dokuwiki
- Miscellaneous
I frequently encounter software packages that need to be built from source. Linux has a mostly-standardized build process which consists of configure
, then make
, followed by make install
. But there are frequently additional targets in the Makefile. How do I find out what these targets are?
You'd think that make
would have options to help with this, but it doesn't. So the simplest way I've found is to write a utility of my own. Here it is, in all its glory:
#! /bin/bash # maketargets - shell script to output target names found in a Makefile # Chris@TheFreyers.net 3/23/2010 cat Makefile | egrep "^[[:alnum:][:punct:]]+\:" | grep -v ":=" | cut -d":" -f1
Understanding what this script does, by segment:
This works surprisingly well in most Makefiles (good enough to do the job). If anyone has another way to do this, I'd love to hear about it.
The script is useful as it is, but there are other ways to deploy it as well.
alias maketargets='cat Makefile | egrep "^[[:alnum:][:punct:]]+\:" | grep -v ":=" | cut -d":" -f1'
Once you login again, all you have to do is cd
into a directory where a makefile exists, and type maketargets
/etc/bashrc
instead. This way, its available to all logged in users on your system who use the bash shell/usr/bin directory
so everyone on your system (including other scripts) can use it