Autoconf and separated include/sources issues

Autoconf and separated include/sources issues

Post by David Anderso » Tue, 15 Oct 2002 01:26:50



Hi all,

I am very new to autoconf/automake, and I have just succeeded in getting a
helloword program to compile using it. The problem I have now is to do
with my directory structure: In my root dir (where configure.ac and
friends are located), I have the following structure:

prog_root
 |
 |-- bin     : where the compiled binaries should be dropped
 |-- src     : where the .c files go (main.c, graph.c ...)
 |-- include : where the corresponding headers (main.h, graph.h ...) go
 |-- obj     : where the object files derived from source and headers go

I would like the makefile generated by automake and the configure script
to take this into account:

1) Check that headers are all in prog_root/include and that all source
files are in prog_root/src
2) Compile each source file into an object file in prog_root/obj
3) Link the relevant files in prog_root/obj into executables in
prog_root/bin

I have tried playing around a bit with Makefile.am, trying to get automake
to understand that binaries should go in ./bin and that they come from
./src AND ./include (I havent't worked out a way of dumping the object
files in ./obj), without success.

Can anyone help me make sense of the autoconf/automake info (if there is
any sense in them :P ), or tell me of an alternative that works easier
than auto* (the end result should still be a configure script and a
makefile, so as not to disorientate the end user who is used to them)?

Thanks in advance
David Anderson

 
 
 

Autoconf and separated include/sources issues

Post by David Anderso » Tue, 15 Oct 2002 03:03:16


Oops, Pan messed up the directory structure I made. The structure is:

prog_root
-- bin     : where the compiled binaries should be dropped
-- src     : where the .c files go (main.c, graph.c ...)
-- include : where the corresponding headers (main.h, graph.h ...) go
-- obj     : where the object files derived from source and headers go

I hope this time it goes through properly :P
David Anderson

 
 
 

Autoconf and separated include/sources issues

Post by David Anderso » Tue, 15 Oct 2002 03:05:03


Hmm, the directory structure wasn't sent properly:

prog_root
 bin     : where the compiled binaries should be dropped
 src     : where the .c files go (main.c, graph.c ...)
 include : where the corresponding headers (main.h, graph.h ...) go
 obj     : where the object files derived from source and headers go

Hoping that THIS time the stuff goes through...
David Anderson

 
 
 

Autoconf and separated include/sources issues

Post by David Anderso » Tue, 15 Oct 2002 03:10:24


Grrr, what is wrong with this newsreader?
Right, try again. The directory structure is:

bin: where the compiled binaries should be dropped
src: where the .c files go
include: whereh the corresponding headers go
obj: where the object files derived from the headers go

Hoping that THIS time it goes through properly...
David Anderson

 
 
 

Autoconf and separated include/sources issues

Post by Forrest J. Cavalier II » Wed, 16 Oct 2002 01:05:30


David Anderson wrote, in part:

Quote:> Can anyone help me make sense of the autoconf/automake info (if there is
> any sense in them :P ), or tell me of an alternative that works easier
> than auto* (the end result should still be a configure script and a
> makefile, so as not to disorientate the end user who is used to them)?

> Thanks in advance
> David Anderson

Here is how you would specify that in CHISEL Master File List:

./src/main.c (./obj/main${OEXT})
./src/graph.c (./obj/graph${OEXT})
./include/main.h
./include/graph.h
./bin/main${EEXT} (_exe) (_name=main)
./obj/main${OEXT} (main) (_nocompile)
./obj/graph${OEXT} (main) (_nocompile)

 
 
 

Autoconf and separated include/sources issues

Post by Forrest J. Cavalier II » Wed, 16 Oct 2002 01:41:53



> Hi all,

> I am very new to autoconf/automake, and I have just succeeded in getting a
> helloword program to compile using it. The problem I have now is to do
> with my directory structure: In my root dir (where configure.ac and
> friends are located), I have the following structure:

> prog_root
>  |
>  |-- bin     : where the compiled binaries should be dropped
>  |-- src     : where the .c files go (main.c, graph.c ...)
>  |-- include : where the corresponding headers (main.h, graph.h ...) go
>  |-- obj     : where the object files derived from source and headers go

> I would like the makefile generated by automake and the configure script
> to take this into account:

> 1) Check that headers are all in prog_root/include and that all source
> files are in prog_root/src
> 2) Compile each source file into an object file in prog_root/obj
> 3) Link the relevant files in prog_root/obj into executables in
> prog_root/bin

> I have tried playing around a bit with Makefile.am, trying to get automake
> to understand that binaries should go in ./bin and that they come from
> ./src AND ./include (I havent't worked out a way of dumping the object
> files in ./obj), without success.

> Can anyone help me make sense of the autoconf/automake info (if there is
> any sense in them :P ), or tell me of an alternative that works easier
> than auto* (the end result should still be a configure script and a
> makefile, so as not to disorientate the end user who is used to them)?

> Thanks in advance
> David Anderson

Here is how you would specify that in CHISEL Master File List:
./src/main.c (./obj/main.${OEXT})
./src/graph.c (./obj/graph.${OEXT})
./include/main.h (./obj/main.${OEXT})
./include/graph.h (./obj/graph.${OEXT})
./bin/main${EEXT} (_exe) (_name=main)
./obj/main.${OEXT} (main) (_obj)
./obj/graph.${OEXT} (main) (_obj)

To build (on any platform, don't need make or a particular shell)
you would run CHISEL as:
    chisel _build out=do varSRCDIR=. probe=1 <master.lst

To generate a makefile, run CHISEL as:
    chisel _build out=mkfile varSRCDIR=. <master.lst

CHISEL is still under development.  If you are interested in trying it,
send email.

Forrest

Here is the makefile output for the above "out=mkfile" output.
Cleaned up a little (Removed comments, etc.)

./obj/main.${OEXT}: ${SRCDIR}./src/main.c ./include/main.h
        $(CC) $(CFLAGS) -c $(NAMEOBJ)./obj/main.$(OEXT) $(SRCDIR)./src/main.c

./obj/graph.${OEXT}: ${SRCDIR}./src/graph.c ./include/graph.h
        $(CC) $(CFLAGS) -c $(NAMEOBJ)./obj/graph.$(OEXT) $(SRCDIR)./src/graph.c

main:  ./obj/main.${OEXT} ./obj/main.${OEXT} ./obj/graph.${OEXT}
./obj/graph.${OEXT}
        $(CMDLINK) $(LINKNAMEEXE)./bin/main$(EEXT)  ./obj/main.$(OEXT)
./obj/graph.$(OEXT)

 
 
 

Autoconf and separated include/sources issues

Post by Marc Tardi » Wed, 16 Oct 2002 02:59:24



> prog_root
>  |
>  |-- bin     : where the compiled binaries should be dropped
>  |-- src     : where the .c files go (main.c, graph.c ...)
>  |-- include : where the corresponding headers (main.h, graph.h ...) go
>  |-- obj     : where the object files derived from source and headers go

> I would like the makefile generated by automake and the configure script
> to take this into account:

> 1) Check that headers are all in prog_root/include and that all source
> files are in prog_root/src

If you define all your source and header files in the SOURCES line of
your Makefile.am file, the existence of these files will be implicitly
checked as dependencies. See the General Operation section of the
automake manual for more details.

Quote:> 2) Compile each source file into an object file in prog_root/obj

I'd advise against having a generic object file directory. If you want
another directory containing source code eventually, perhaps an extern
or contrib directory for example. Then you won't be able to store all
object files in the same directory because there may be name conflicts.

Quote:> 3) Link the relevant files in prog_root/obj into executables in
> prog_root/bin

If you define bin_PROGRAMS as ../bin/my_program, you might be able to
pull that off. I'd advise against that also because you might find it a
pain to debug your application at times, ie fix bug in src dir, execute
program in bin dir, fix bug in src dir, and so on. Typically, you should
keep all related things together, including your tests (don't forget to
write those).

Marc - Sitepak

 
 
 

1. missing /usr/include/linux/autoconf.h

Looks like 1.3.83 and 1.3.84 are missing something.  When trying to
compile hdparm-2.7

# make
gcc -Wall -Wstrict-prototypes -O2 -s -N -o hdparm hdparm.c
In file included from /usr/include/linux/fs.h:9,
                 from hdparm.c:19:
/usr/include/linux/config.h:4: linux/autoconf.h: No such file or directory
make: *** [hdparm] Error 1

Greg

2. bind() system call Fails ...?

3. include/linux/autoconf.h missing from 2.4.13?

4. showmount -e shows filesystems not mounted

5. autoconf and files in /usr/local/include

6. How a package will be lost in the network ?

7. INCLUDING SEPARATE FILES?

8. Red Hat Installation

9. Two separate issues re: Samsung Harddrive and D-Link DE-220PCT NIC?

10. Separate keymaps for separate vt's?

11. Two separate MAC addresses for two separate NICS?

12. Matrox Mystique ands X.