autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: copying object files and binary files in different directories


From: ranjith
Subject: RE: copying object files and binary files in different directories
Date: Mon, 28 May 2007 17:37:51 +0530

Hi,
        Thanks for your valuable suggestions.

        I want to run configure (and make) from the build directory itself
and it should take the makefile from either win32 or linux32 folder,
according to the platform, and compile it.

        I am able to do that now (with the help of AM_CONDITIONAL), but the
thing is that I am getting the .o (or .obj) files and the binary file in
win32 (or linux32) folder. This (.o and the binary files) I want to move to
the obj folder (in win32 or linux32 folder) automatically. 

        Is there any way in automake where I can specify the obj directory?
So that after compilation all the .o (or .obj) files will be moved to the
obj folder.


Regards,
Ranjith
--- Begin Message --- Subject: RE: copying object files and binary files in different directories Date: Mon, 28 May 2007 12:20:16 +0530
Quoting ranjith <address@hidden>:
>
> Hi,

Hi
Please could you avoid top posting
(http://en.wikipedia.org/wiki/Top-posting)
Also keep the list you posted your question on in CC.

>
> Thanks for the suggestion.
>
>
> I am having the directory structure something like below
>
> Root
>             Src
>             Build
>                         Win32
>                         Linux32

Then what about this:

cd Build/Win32
../../configure
make
make install DESTDIR=`pwd`/install
cd Build/Linux32
../../configure
make
make install DESTDIR=`pwd`/install

The make install steps are only useful if you really want to get the  
final results of the builds somewhere (so that you can tar-gz them and  
redistribute them).  Not however that you have to be careful and  
install these binary results under the same prefix you passed to  
configure (or /usr/local if you didn't pass one).

> All of my source files are there in the src directory and the configure.in
> in the build directory. My configure.in looks like given below
>
> dnl
> dnl Author  : Ranjith Thai Valappil
> dnl
>
>
> AC_INIT("MyProject", 1.0.0.0, configure.in)

Use:
AC_INIT([MyProject], [1.0.0.0], address@hidden)
See:
http://www.gnu.org/software/autoconf/manual/html_node/Initializing-configure
.html

> AM_INIT_AUTOMAKE(MyProject, 1.0.0.0)

This is the old form, use the new form:
AM_INIT_AUTOMAKE

Or maybe:
AM_INIT_AUTOMAKE([1.9 foreign -Wall])
which will require Automake 1.9 minimum, say that you're not a GNU  
package and thus don't have to comply with GNU requirements, and  
enable all warnings which is generally a Good Thing.

See:
http://www.gnu.org/software/automake/manual/html_node/Public-macros.html

> dnl AC_CONFIG_HEADER(config.h)
>
> AM_PROG_AS
> AC_PROG_CXX
> AC_ISC_POSIX
>
> AC_SUBST(PACKAGE_CFLAGS)
> AC_SUBST(PACKAGE_LIBS)

AC_SUBST([PACKAGE_xxx])
Always quote your arguments.  You might want to read:
http://www.gnu.org/software/automake/manual/html_node/Hello.html
http://www-src.lip6.fr/homepages/Alexandre.Duret-Lutz/dl/autotools.pdf

>
> ALL_LINGUAS=""
>
>
> AC_ARG_ENABLE(debug,
>   [  --enable_debug          adds the debuging support])

You might want to use AS_HELP_STRING to nicely format your entry  
automagically.
See:  
http://www.gnu.org/software/autoconf/manual/html_node/Pretty-Help-Strings.ht
ml

>
> if test "$enable_debug"; then
>   AC_DEFINE(DEBUG)
> fi
>
>
> AC_ARG_ENABLE(platform,
>   [  --enable-platform          set the platform for which the makefiles
to
> be created,
>                              possible values are linu32, win32 and
win_x64.
> If you don't enter anything, I will try to get it
> ],

AS_HELP_STRING :)

> [case "${enableval}" in
>   win32)    platform=win32   ;;
>   linux32)  platform=linux32 ;;
>   win_x64)  platform=win_x64 ;;
>   *) AC_MSG_ERROR(bad value ${enableval} for --enable-platform) ;;
        AC_MSG_ERROR([[bad value ${enableval} for --enable-platform]])
>   esac],[platform=none])
>
> if test x"$platform" = x"none"
> then
>   AM_CONDITIONAL(WIN32, test x"`uname -ms`" = x"CYGWIN_NT-5.1 i686")
>   AM_CONDITIONAL(LINUX32, test x"`uname -ms`" = x"Linux i686")
>   AM_CONDITIONAL(WIN_X64, test "1" = "2") # for X64 you need to explicitly

What if I use a different version of Cygwin?  Or if I use MinGW?

You can do something like this:

AC_CANONICAL_HOST
case $host_os in
   cygwin* | mingw* | pw32* | interix*)
     # Windows stuff
     ;;
   gnu* | linux*)
     # Linux stuff
     ;;
   *)
     AC_MSG_WARN([[$host_os not known: hope for the best]])
     ;;
esac

But it would even better to test the features you need rather than  
trying to be clever about matching the version of something.  For  
instance, if you want to know whether you're building for a 64bit  
target, you could try to compile a small test program that returns  
sizeof (void*).  Note however that is likely to break cross-compiling  
but since your current setup does not support cross-compiling anyway,  
it's probably not a problem for you.

> specify it
> else
>   AM_CONDITIONAL(LINUX32, test x$platform = xlinux32)
>   AM_CONDITIONAL(WIN32, test x$platform = xwin32)
>   AM_CONDITIONAL(WIN_X64, test x$platform = xwin_x64)
> fi
>
> AC_OUTPUT([
> Makefile
> linux32/Makefile
> win32/Makefile
> ])
>
>
> And the Makefile.am in the linux32 directory is given below
>
> if LINUX32
> bin_PROGRAMS    = MyProject1 MyProject2
> endif
>
> VPATH           = \
>                   ../../src

I'm not sure why you're doing this here.  You should let configure do  
this for you I think.  When you invoke configure from another  
directory, you automagically enter the VPATH-build mode.

>
> MyProject1_SOURCES   = \
>                 Exception.cpp \
>                 Thread.cpp \
>                 ThreadSync.cpp \
>                 Main.cpp
>
> MyProject2_SOURCES   =
>
> INCLUDES                 = -I../../src
> LIBS                            = -pthread
> AM_CXXFLAGS       = -Wall
>
>
> Now the thing is that I don't want the object files to be in linux32
> directory, instead I want to create directories obj and bin under the
> linux32 directory and all the object files copied in to the obj directory
> and executables and libraries in the bin folder. Obj and bin will be
> dynamically created and I don't want makefiles.am to be put in those
> directories.
>
> Kindly let me know is there anyway of doing it using automake.
>
>
> Regards
> Ranjith
>
> -----Original Message-----
> From: Tsuna [mailto:address@hidden
> Sent: Saturday, May 26, 2007 12:40 AM
> To: address@hidden
> Cc: address@hidden
> Subject: Re: copying object files and binary files in different
directories
>
>
> On Fri, May 25, 2007 14:17, ranjith said:
>> Hi,
>>
>
> Hello,
>
>>
>>
>>             I am using autoconf to build my project. I want the object
>> files
>> and the binary to be moved to another directory after the build is over.
>>
>
> Did you try VPATH builds?  (Invoke configure from another directory, for
> instance go at the root of your projet and do: mkdir build && cd build &&
> ../configure [options])
> If VPATH does not suit you then try to explain what you're really trying
> to achieve and why.
>
> Cheers,
>



-- 
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]