Q:

How to use 'apt' to get source code and then do separate compile

I want to get the source code for a project and then build it the same way that apt would.  E.g. I want the working source code and be able to run 'make' or similar command on the source.
How can I do that?
Specifically I want to get this source 'icedtea-6-jre-jamvm'

A:

For this example I'll use icedtea-6-jre-jamvm as the package you want to rebuild.
First install all the dependencies and build essential:
sudo apt-get build-dep icedtea-6-jre-jamvm
sudo apt-get install build-essential

Then grab the source:
apt-get source icedtea-6-jre-jamvm

Then cd in the openjdk directory directory and build the deb, the -us and -uc here skip the GPG checks if you're just rebuilding it for yourself:
cd openjdk-6-6b24-1.11.5
dpkg-buildpackage -us -uc

Then go up a directory and you should have .deb files. 
Sources:

http://www.debian.org/doc/manuals/maint-guide/build.en.html

A:

to just compile the package use the debian/rules script which is provided in each debain package:
sudo apt-get build-dep <package>
apt-get source <package>
cd <package>_<version>
./debian/rules binary

this just does the configure and the compile part.

A:

You can use the follwing :
apt-get source <package>

you need to make sure you install the build dependencies :
sudo apt-get build-dep <package> 

for more info run :
man apt-get

Alternative option :First you need to know the location of the package.
then download the tar file using :
sudo wget <url>

You can then untar it and compile it using make
if your not sure about the specific command look inside of the folder, there should be a README file or INSTALL which will tell you the appropriate command .

