After a little bit of struggle with using vi for editing files and then with the installation of Emacs, finally figured out how to install Emacs on a HP UX machine. I started the installation with Emacs-21.4 and then switched over to Emacs-22.1, since i could not find anything about the errors throws while compiling emacs-21.4.
Followed the usual rules of ./configure and make to install but faced hell a lot of problems with that. First ./configure should be run with the option --without-gcc as HP UX does not contain gcc. With that option configure runs to completion without error. The next step is "make" and this is where i ran into lot of problems. First thing is that, in the Makefile inside lib-src directory there is a rule to copy rcs2log, rcs-checkin, vcdiff, grep-changelog from ../ to lib-src. These files are already present in the directory, hence HP make reports an error saying that the files are identical but with gnu make there will not be any problem. So was forced to comment the four rules which copies the files to the directory.
After this is done, i tried to start emacs but got the most common error "Segmentation Fault (core dumped)". Looked like a bug in the emacs source code. Found this link where RMS has discussed this problem. The problem occurs since the uninitialized static pointers. All it required was set the initialize the static pointers to NULL. See this link for more details regarding the solution. So atlast i had the opportunity to correct the Emacs source code :) . Did that and ran "make" and now I have the most powerfull editor in almost all the machines i work.