PDA

View Full Version : Problem with make file



nickman
09-25-2012, 11:10 PM
Hi

I am trying to create my own executable using makefile concepts.

I have followed steps as mention in this thread:



http://cboard.cprogramming.com/linux-programming/98697-problem-creating-executable-configure-ac.html


All files like makefile.am, makefile.in etc are created.
But when I try to run make... it give me following errors:



make[1]: Entering directory `/home/nick/Desktop/myprogram'
Making all in src
make[2]: Entering directory `/home/nick/Desktop/myprogram/src'
make[2]: *** No rule to make target `test.o', needed by `test'. Stop.
make[2]: Leaving directory `/home/nick/Desktop/myprogram/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/nick/Desktop/myprogram'
make: *** [all] Error 2



The makefile.am is as follow in src:


bin_PROGRAMS = test
test_SOURCES = test.c


And the makefile.am in myprogram folder:


SUBDIRS = src


The configure.ac is:


# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(test.c, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([test.c])
AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([makefile
src/makefile])
AM_INIT_AUTOMAKE
AC_OUTPUT


I think that I have mention somewhere for test.o.
Can anybody help me in this?

Thanks
Nick

anduril462
09-26-2012, 11:07 AM
With the files you gave, ./configure was failing for me with the following:

$ ./configureconfigure: error: cannot find sources (test.c) in . or ..

Then I realized, your configure.ac doesn't specify the src directory before test.c:

AC_CONFIG_SRCDIR([src/test.c])
Once I did that, configure and make worked just fine, I didn't have to add any .o rule.

Start with a clean setup, just configure.ac, Makefile.am, src/Makefile.am and src/test.c.

If that still doesn't work, provide all 4 of those basic files, and provide a full dump of your terminal session, with every command you run and all of it's output.

Also, maybe Google around for some other tutorials. This one seems decent: Developing Programmers .com Blog Archive Autotools Tutorial (http://www.developingprogrammers.com/index.php/2006/01/05/autotools-tutorial/).

nickman
09-26-2012, 11:41 AM
Thank for response.
The executable was created in src now.
I have a question..
What should I do that it should always created in my myprogram folder and not in src?
I have followed the instruction and done in that way.

Thanks
Nickman

anduril462
09-26-2012, 12:19 PM
The tutorial you were following talks about how to change the location of where the executable is intalled, with the prefix argument to configure. The tutorial I linked you to also discusses how to do it via src/Makefile.am.

EDIT: I never messed with GNU autotools until last night when I saw your post, so I know about as much as you do. The best thing you can do is read lots of tutorials and manuals, and experiment.