How to fix "PKG_PROG_PKG_CONFIG: command not found" error?

I have Ubuntu 13.10 32 bit system. Recently when I try to to compile by running ./autogen.sh and ./configure I get

 PKG_PROG_PKG_CONFIG: command not found

error. I have libtool installed. I have three aclocal files in usr/share/ like alocal, aclocal-1.13 and aclocal-1.4

How can I fix that alocal error?

EDIT:

Some time ago I compiled latest version of automake from source and installed it because a source code needed recent version of automake to run configure process. Since then whenever I run standard ./autogen and /configure commands in source directory to generate makefile I get

  PKG_PROG_PKG_CONFIG: command not found

error

  find /usr -name "pkg.m4"

gives me

  /usr/share/aclocal/pkg.m4

and

  aclocal --print-ac-dir

gives me

  /usr/local/share/aclocal

The PKG_PROG_PKG_CONFIG variable refers to a macro pkg.m4 that is provided as part of the pkg-config package, so the first thing to check is that pkg-config is installed and that the macro file is in the default location (and is readable, of course)

dpkg -l pkg-config

ls -l /usr/share/aclocal/pkg.m4

If that checks out, then the question becomes why is aclocal not finding it? You can check where aclocal is configured to look for third-party m4 files using the --print-ac-dir switch i.e.

aclocal --print-ac-dir

If that's not the same as the location above, it suggests there is a non-standard version of automake on your system - if you can't resolve that, then a possible workaround is to set or export the ACLOCAL_PATH environment variable before running the autogen.sh script e.g.

ACLOCAL_PATH=/usr/share/aclocal ./autogen.sh

or

export ACLOCAL_PATH=/usr/share/aclocal
./autogen.sh
./configure

See the macro search path section of the GNU automake manual.