Install Xcode from the App store or the Apple developer website.
For installing Xcode command line tools run the command
xcode-select --install
It'll prompt you to install the command line tools. Follow the instructions and now you have Xcode and Xcode command line tools both installed and running.
Also install XQuartz for X11 server and client libraries for OS X Mountain Lion.