source: project/wiki/using the gnu autotools with compiled code @ 36321

Last change on this file since 36321 was 3574, checked in by arto, 13 years ago

Tested and updated instructions for Chicken 2.6.

File size: 2.2 KB
Line 
1== Using the gnu autotools with compiled code
2
3This builds on Generating the smallest possible, self-contained executable and adds support for using the GNU Autotools (autoconf, automake, etc.).
4
5Again, we start with our simple hello.scm:
6
7 $ cat hello.scm
8 (display "Hello, world!\n")
9 $ chicken hello.scm -explicit-use -uses library
10
11Now we copy {{library.c}}, {{runtime.c}}, {{chicken.h}} and {{chicken-defaults.h}} from the CHICKEN source distribution into the current directory. (If your source directory doesn't have {{chicken-defaults.h}}, the {{make chicken-defaults.h}} command will build it for you.)
12
13Next we need a {{Makefile.am}} and {{configure.in}}:
14
15 $ cat Makefile.am
16 bin_PROGRAMS = hello
17 hello_SOURCES = hello.c runtime.c library.c
18 hello_LDADD = -lm
19
20 $ cat configure.in
21 AC_INIT(hello, 1.0.0)
22 AM_INIT_AUTOMAKE()
23 AC_CONFIG_SRCDIR([chicken.h])
24 AC_CONFIG_HEADER([chicken-config.h])
25 
26 # Checks for programs.
27 AC_PROG_CC
28 
29 # Checks for header files.
30 AC_FUNC_ALLOCA
31 AC_HEADER_STDC
32 AC_HEADER_SYS_WAIT
33 AC_CHECK_HEADERS([alloca.a stdint.h limits.h malloc.h stdint.h stdlib.h string.h sys/time.h])
34 
35 # Checks for typedefs, structures, and compiler characteristics.
36 AC_C_CONST
37 AC_TYPE_SIZE_T
38 AC_HEADER_TIME
39 AC_STRUCT_TM
40 AC_C_VOLATILE
41 
42 # Checks for library functions.
43 AC_FUNC_MALLOC
44 AC_FUNC_REALLOC
45 AC_TYPE_SIGNAL
46 AC_FUNC_STAT
47 AC_CHECK_FUNCS([floor memset modf pow strerror strncasecmp strpbrk])
48 AC_CONFIG_FILES([Makefile])
49 AC_OUTPUT
50
51(This is mostly generated by {{autoscan}})
52
53You should now have the following files:
54
55 Makefile.am
56 chicken.h
57 chicken-defaults.h
58 configure.in
59 hello.c
60 library.c
61 runtime.c
62
63Running a few autotools in the appropriate order, we generate the rest of the required infrastructure:
64
65 $ aclocal
66 $ autoheader
67 $ automake --foreign -a --copy
68 configure.in: installing `./install-sh'
69 configure.in: installing `./mkinstalldirs'
70 configure.in: installing `./missing'
71 Makefile.am: installing `./depcomp'
72 $ autoconf
73
74Now you could put all files in the directory into a tarball and install it on most UNIX machines (For more exotic platforms, some tweaking of {{configure.in}} might be needed, though).
75
76Build and installation can now be performed in the usual manner:
77
78 $ ./configure
79 $ make
80 $ make install
Note: See TracBrowser for help on using the repository browser.