Friday, October 27, 2006

Shell command inside Makefile

In this post lets learn how to embed a shell script inside a Makefile.

Wot Makefile does:
The Makefile lists the modules that are part of the project and the libraries that should be linked.It is used by the Make utility of the compiler. Learning about make will give you the freedom of modifying it for compile time optimisation and also during testing we can modify Makefile to compile only the necessary files.

Why script inside Makefile:
The Makefile uses lots of Macros and environmental variables. And it does not have the intelligence to differentiate the shell command and normal text. In order to do manipulations on the variables defined inside the Make , we need to use small shell commands.

Shell command in Make:
when a variable is used within $() then the value of the variable is substituted.
To run a shell command command we need to tell make the path where the sh is present.
which sh

use "shell" in the beginning of the command to tell the make that the string following the shell is a
shell command.
VARIABLE = $(shell command)
variable = $(shell echo $(VERSION))

There is no need to use back-quote for the commands given after shell keyword.

Look this space for more info on how to write, optimise and play with Makefile and tips on scripting as well. :-)

Suggestions are welcome

Saturday, October 07, 2006

Disable Write Protection on USB Stick

Hi folks,
this is how to write USB sticks when they are write protected. This works with WindowsXP.
*start -> run -> type "regedit"
*goto HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control
*select "StorageDevicePolicies" in the tree.
*double click on ‘WriteProtect’ in the right side pane.
*change its value to '0'. ('1' means enable write protection).

Screen shot is below for your reference

Sources: I really don't remember where I came across this tip :-(

Thursday, October 05, 2006

Drive Names in Windows

Have you ever thought how to get drive letters in Windows? If you know the cool hack below, you wont need to struggle for that.


* @author karthikkannan
* Demo for listing drive letters on Windows
public class Utility {
public static void main(String[] args) {
File[] roots = getDrives();
for (File file : roots) {

public static File[] getDrives() {
return File.listRoots();

There is a static method called listRoots() in the class. Hope this was a useful tip. See you in the next post folks.


Let The Game Begin!!!

Hello World!!!

Hi friends, once again programmer’s style of starting things. Let’s hope I learn to write well. Expect only technical articles here folks. Catch you in the next post with some interesting stuff.