I am running Linux, Ubuntu 10.04 .
It is not the first time I try to use autotools. I did a lot of researches and follow a lot of tutorials : here is what I want to do, what I tried and what issue I am facing.
Goal :
- compile (and then cross-compile, but this will be an other job) my own library coded in C using libtool, autoconf and automake
What I tried and where I am :
The library name is FXPLib, the package name is libfxplib-0.1
My project folder is :
Makefile.am (the only one) include include/fxplib.h (main header) include/FXPLib include/FXPLib/header1.h (these are public headers) include/FXPLib/header2.h include/FXPLib/... src src/sub1/file1.c src/sub2/file1.c src/sub3 ...
I ran autoscan, got a configure.ac, edited it as here :
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) AC_INIT([libfxplib-0.1], [0.1], [<>]) AC_CONFIG_SRCDIR([src/object_system/FXP_image_s.h]) AC_CONFIG_HEADERS(config.h) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE AM_PROG_LIBTOOL LT_PREREQ([2.2]) LT_INIT # Checks for programs. AC_PROG_CC AC_PROG_MAKE_SET # Checks for libraries. # Checks for header files. AC_CHECK_HEADERS([stdlib.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_REALLOC AC_CHECK_FUNCS([memset]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT
I wrote Makefile.am like this :
lib_LTLIBRARIES = libfxplib-0.1.la libfxplib_0_1_la_CFLAGS = -I$(srcdir)/include -I$(srcdir)/include/FXPLib `sdl-config --cflags --libs` -lSDL_image libfxplib_0_1_la_SOURCES = src/sub1/file1.c \ src/sub1/file2.c \ src/sub2/file1.h \ ... nobase_include_HEADERS = include/fxplib.h \ include/FXPLib/header1.h \ include/FXPLib/header2.h \ ... ACLOCAL_AMFLAGS = -I m4
- Then I ran aclocal and autoheader to get files needed by automake
- Then the most important : autoconf
- And : automake --add-missing --copy
From there, everything is ok. But then I try to compile :
$ ./configure
Everything ok too...
$ make
and then I get :
...
src/graphics_engine/FXP_rendering.c:35:25: error: FXP_image_s.h: File not found
...
where :
- "graphics_engine" is equivalent to src/sub
- "FXP_rendering.c" to src/sub/file.c
- "FXP_image_s.h" to src/sub2/header.h
This means : automake can compile .c files in a sub directory, but can't include in these files a private .h file that is in an other sub directory.
My problem is : How to tell automake to compile every files in every subdirectories as if they were all in the same place ?
I hope I am understandable (and sorry for some problems you could find in my words, cause I am French)
Thank you by advance.