source: project/wiki/autoconf - automake @ 36409

Last change on this file since 36409 was 33825, checked in by svnwiki, 3 years ago

Anonymous wiki edit for IP [70.113.48.75]: Fixed a misspelling

File size: 3.4 KB
Line 
1[[tags:tutorials autoconf automake]]
2[[toc:]]
3
4== autoconf - automake
5the best thing ever!
6This explains how Autoconf and Automake should be used to build a package with CHICKEN Scheme that conforms to the GNU Coding Standards.
7We will assume your program is the one for the [[/manual/Using the compiler#Examples#An example with multiple files|second example]] of the [[/manual/Using the compiler|Using the compiler]] section of the User's Manual.
8
9'''Note:''' This is just a draft, I expect to improve it in the future.
10
11== Automake
12
13=== Makefile.am
14
15Your {{Makefile.am}} should contain a list of the programs that make up your package and their sources, as well as some additional rules explaining how to compile {{.scm}} files:
16
17 # A list of the programs we want to build:
18 bin_PROGRAMS = foo
19 
20 # The sources for each program we define:
21 foo_SOURCES = foo.scm bar.scm
22 
23 # The following line causes autoconf to become aware of the fact that .scm
24 # files in the *_SOURCES lists should not be ignored:
25 .scm.o:
26
27 # Specify the extension of our object files:
28 OBJEXT=o
29
30 # Specify how to link object files:
31 LINK=csc -o $@
32 
33 # The following lines defines a rule for GNU Make explaining how to build a
34 # .o file from its associated .scm file:
35 %.o: %.scm
36         csc -c $< -o $@ $(CHICKENFLAGS)
37
38=== Compile time dependencies
39
40If all your {{.scm}} files depend at compile time on some other files (which usually happens when you define macros), you'll want to define their dependency.  To do that, change {{%.o: %.scm}} in your Makefile.am to {{%.o: %.scm macros.scm}}, where {{macros.scm}} is your compile-time dependency (you could include more than once).
41
42If just a few of your {{.scm}} files depend at compile time on other files, you can just state the dependencies.  For example:
43
44 foo.o: macros.scm
45
46This reads as ''{{foo.o}} should be rebuilt whenever {{macros.scm}} changes''.
47You can, of course, include multiple of the above kind of lines and you can also include multiple dependencies in one single line.
48
49== Autoconf
50
51=== Configure.in
52
53The following should be the contents of your {{configure.in}} template:
54
55 dnl Process this file with autoconf to produce a configure script.
56 dnl Use the name of an existing source file for your program here:
57 AC_INIT(foo.scm)
58 
59 dnl Use the name and version of your package (which doesn't have to match
60 dnl the names of your executables):
61 AM_INIT_AUTOMAKE(foo, 1.0)
62 
63 AC_PREREQ(2.12)
64 
65 dnl Checks for programs.
66 AC_PROG_CC
67 AC_PROG_INSTALL
68 AC_PROG_LN_S
69 AC_PROG_MAKE_SET
70 
71 dnl Test for presence of csc (we should probably bail out with error if
72 dnl we fail to find it):
73 AC_CHECK_PROG(CSC, csc, YES)
74 
75 AC_CHECK_PROG(CHICKEN, chicken, YES)
76 
77 dnl Use here any special flags you require.  For example, if you want
78 dnl R5RS macros, use "-require-extension syntax-case"
79 AC_SUBST(CHICKENFLAGS,"")
80 
81 AC_OUTPUT(Makefile)
82=== Checking for eggs
83
84TODO: We should write some code that tests for the presence of an egg and, if not found, asks the user to install it and bails out.
85
86== Preparing things
87
88Make sure to create the following files:
89
90* README
91* NEWS
92* ChangeLog
93* AUTHORS
94
95Then run (TODO: I still need to verify this is the correct order):
96
97 $ automake -a
98 $ aclocal
99 $ autoconf
100
101It is ok for automake to print some warnings as it creates some missing files.
102
103Voila, your package should be ready.
104At this point you can use {{./configure}} with its standard parameters such as {{--prefix}}.  You can also use {{make dist}} to prepare a tarball with your package.
Note: See TracBrowser for help on using the repository browser.