diff options
Diffstat (limited to 'distribution/autotools')
| -rw-r--r-- | distribution/autotools/autotools.tex | 175 |
1 files changed, 90 insertions, 85 deletions
diff --git a/distribution/autotools/autotools.tex b/distribution/autotools/autotools.tex index 30791d4..eb8d6f9 100644 --- a/distribution/autotools/autotools.tex +++ b/distribution/autotools/autotools.tex @@ -23,8 +23,8 @@ int main(int argc, char **argv) { - printf("Hello World\n"); - return 0; + printf("Hello World\n"); + return 0; } \end{verbatim} \end{frame} @@ -44,8 +44,8 @@ int main(int argc, char **argv) hello: install: - install -d /usr/bin - install hello /usr/bin/hello + install -d /usr/bin + install hello /usr/bin/hello \end{verbatim} \begin{verbatim} @@ -64,8 +64,8 @@ use a template 'Makefile.in' hello: install: - install -d @exec_prefix@ - install hello @exec_prefix@/hello + install -d @exec_prefix@ + install hello @exec_prefix@/hello \end{verbatim} and run './configure --exec-prefix=/opt/bin' \end{frame} @@ -116,8 +116,8 @@ the generated Makefile: hello: install: - install -d /opt/bin/hello - install hello /opt/bin/hello + install -d /opt/bin/hello + install hello /opt/bin/hello \end{verbatim} \end{frame} @@ -153,9 +153,9 @@ include 'config.h' in main.c and use the PACKAGE\_STRING define: int main(int argc, char **argv) { - printf(PACKAGE_STRING "\n\n") - printf("Hello World\n"); - return 0; + printf(PACKAGE_STRING "\n\n") + printf("Hello World\n"); + return 0; } \end{verbatim} \begin{verbatim} @@ -208,18 +208,14 @@ Makefile.am: error: required file './NEWS' not found Makefile.am: error: required file './README' not found Makefile.am: error: required file './AUTHORS' not found Makefile.am: error: required file './ChangeLog' not found -Makefile.am: installing './COPYING' using GNU General Public License v3 file -Makefile.am: Consider adding the COPYING file to the version control system -Makefile.am: for your code, to avoid questions about which license your project uses +Makefile.am: installing './COPYING' using GNU General Public License v3 +Makefile.am: Consider adding the COPYING file to the version contro +Makefile.am: for your code, to avoid questions about which license Makefile.am: installing './depcomp' -/usr/share/automake-1.15/am/depend2.am: error: am__fastdepCC does not appear in AM_CONDITIONAL -/usr/share/automake-1.15/am/depend2.am: The usual way to define 'am__fastdepCC' is to add 'AC_PROG_CC' -/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again -/usr/share/automake-1.15/am/depend2.am: error: AMDEP does not appear in AM_CONDITIONAL -/usr/share/automake-1.15/am/depend2.am: The usual way to define 'AMDEP' is to add one of the compiler tests -/usr/share/automake-1.15/am/depend2.am: AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX, -/usr/share/automake-1.15/am/depend2.am: AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC -/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again +/usr/share/automake-1.15/am/depend2.am: error: am__fastdepCC does not a +... +/usr/share/automake-1.15/am/depend2.am: AM_PROG_AS, AM_PROG_GCJ, AM +/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run 'ac Makefile.am: error: C source seen but 'CC' is undefined Makefile.am: The usual way to define 'CC' is to add 'AC_PROG_CC' Makefile.am: to 'configure.ac' and run 'autoconf' again. @@ -246,14 +242,14 @@ Some other files are mandatory, create them: \frametitle{remember 2nd part of the errors} \begin{verbatim} % autoreconf -sif -/usr/share/automake-1.15/am/depend2.am: error: am__fastdepCC does not appear in AM_CONDITIONAL -/usr/share/automake-1.15/am/depend2.am: The usual way to define 'am__fastdepCC' is to add 'AC_PROG_CC' -/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again -/usr/share/automake-1.15/am/depend2.am: error: AMDEP does not appear in AM_CONDITIONAL -/usr/share/automake-1.15/am/depend2.am: The usual way to define 'AMDEP' is to add one of the compiler tests -/usr/share/automake-1.15/am/depend2.am: AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX, -/usr/share/automake-1.15/am/depend2.am: AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC -/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again +/usr/share/automake-1.15/am/depend2.am: error: am__fastdepCC does n +/usr/share/automake-1.15/am/depend2.am: The usual way to define ' +/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run +/usr/share/automake-1.15/am/depend2.am: error: AMDEP does not appea +/usr/share/automake-1.15/am/depend2.am: The usual way to define ' +/usr/share/automake-1.15/am/depend2.am: AC_PROG_CC, AC_PROG_CXX +/usr/share/automake-1.15/am/depend2.am: AM_PROG_AS, AM_PROG_GCJ +/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run Makefile.am: error: C source seen but 'CC' is undefined Makefile.am: The usual way to define 'CC' is to add 'AC_PROG_CC' Makefile.am: to 'configure.ac' and run 'autoconf' again. @@ -277,7 +273,7 @@ rerun autoconf % autoreconf -sif configure.ac:11: installing './compile' \end{verbatim} - +\end{frame} \begin{frame}[fragile] \frametitle{generate a Makefile} @@ -288,7 +284,7 @@ was generated! % make make all-am make[1]: Entering directory '/home/local/hello' -gcc -DHAVE_CONFIG_H -I. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c +gcc -DHAVE_CONFIG_H -I. -g -O2 -MT hello.o -MD -MP -MF mv -f .deps/hello.Tpo .deps/hello.Po gcc -g -O2 -o hello hello.o make[1]: Leaving directory '/home/local/hello' @@ -346,12 +342,16 @@ All needed steps are executed automatically! \end{description} \end{block} \begin{block}{install} +\begin{description} \item[install] takes care on DESTDIR environment variable +\end{description} \end{block} \begin{block}{dist} +\begin{description} \item[dist] generates a hello-1.0.tar.gz \item[distcheck] same as dist, but checks if the sw can be build with files - included in the tarball. + included in the tarball. +\end{description} \end{block} \end{frame} @@ -386,6 +386,8 @@ the typical workflow is #!/bin/sh autoreconf -sif \end{verbatim} + + \begin{verbatim} % chmod +x autogen.sh % git add autogen.sh @@ -401,15 +403,14 @@ autoreconf -sif AUTHORS autogen.sh ChangeLog configure.ac COPYING hello.c INSTALL Makefile.am NEWS README \end{verbatim} -'AUTHORS, ChangeLog, COPYING, INSTALL, NEWS' and 'README' are -mandatory text files, that describe the project. - -'autogen.sh' is an (optional) one-liner script - -'Makefile.am' are two lines and even simpler than the inital Makefile - -'configure.ac' a template can be generated with 'autoscan' at least -'AM\_INIT\_AUTOMAKE' needs to be added manually. +\begin{description} +\item[AUTHORS, ChangeLog, COPYING, INSTALL, NEWS, README] are +mandatory text files, that describe the project +\item[autogen.sh] is an (optional) one-liner script +\item[Makefile.am] are two lines and even simpler than the inital Makefile +\item[configure.ac] a template can be generated with 'autoscan' at least +AM\_INIT\_AUTOMAKE needs to be added manually. +\end{description} \end{frame} \begin{frame}[fragile] @@ -444,17 +445,17 @@ int gui_display (char *msg); static WINDOW *mainwin; int gui_init (void) { - mainwin = initscr (); - if (!mainwin) return -ENOMEM; - return 0; + mainwin = initscr (); + if (!mainwin) return -ENOMEM; + return 0; } void gui_free (void) { - delwin (mainwin); endwin (); refresh (); + delwin (mainwin); endwin (); refresh (); } int gui_display (char *msg) { - mvaddstr (strlen (msg), 33, msg); refresh (); + mvaddstr (strlen (msg), 33, msg); refresh (); } \end{verbatim} \end{frame} @@ -471,15 +472,15 @@ int gui_display (char *msg) { int main (int argc, char **argv) { - printf (PACKAGE_STRING "\n\n"); - if (gui_init ()) { - perror("init gui failed:"); - return -1; - } - gui_display ("Hello GUI!"); - sleep (10); - gui_free (); - return ret; + printf (PACKAGE_STRING "\n\n"); + if (gui_init ()) { + perror("init gui failed:"); + return -1; + } + gui_display ("Hello GUI!"); + sleep (10); + gui_free (); + return ret; } \end{verbatim} \end{frame} @@ -523,6 +524,7 @@ we use 'ncurses' so let's retrieve the compiler and linker options: % pkg-config --libs ncurses -lncurses -ltinfo \end{verbatim} +\end{frame} \begin{frame}[fragile] \frametitle{simply add the output to Makefile.am?} @@ -606,9 +608,9 @@ compile and test application: \begin{verbatim} % git status ... - gui.o - hello-gui.o - hello-hello.o + gui.o + hello-gui.o + hello-hello.o ... % echo '*.o' >> .gitignore % git add gui.c gui.h Makefile.am configure.ac hello.c .gitignore @@ -628,7 +630,7 @@ and the gui components are build. \frametitle{implement configure switch} add this in 'configure.ac': \begin{verbatim} -AC_ARG_WITH([gui], AS_HELP_STRING([--with-ncurses-gui], [Build with GUI])) +AC_ARG_WITH([gui], AS_HELP_STRING([--with-ncurses-gui], [build GUI])) if test "x$with_gui" = "xyes"; then PKG_CHECK_MODULES([NCURSES], [ncurses], [AC_DEFINE([HAVE_GUI],[1],["ncurses available"])]) @@ -642,7 +644,7 @@ AM_CONDITIONAL([HAVE_GUI], [test x$with_gui = xyes]) \end{description} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{only build GUI if specified} 'Makefile.am': \begin{verbatim} @@ -656,7 +658,7 @@ endif \end{verbatim} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{only call gui if compiled in} 'hello.c': \begin{verbatim} @@ -666,22 +668,22 @@ endif #endif ... #ifdef HAVE_GUI - ret = gui_init (); - if (ret) { - perror("init gui failed:"); - return ret; - } + ret = gui_init (); + if (ret) { + perror("init gui failed:"); + return ret; + } - gui_display ("Hello GUI!"); - sleep (10); + gui_display ("Hello GUI!"); + sleep (10); - gui_free (); + gui_free (); #endif ... \end{verbatim} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{build with and without gui} \begin{verbatim} % ./configure --with-gui @@ -759,15 +761,17 @@ unsigned int fibonacci (unsigned int fib) { 'fib/Makefile.am': \begin{verbatim} lib_LTLIBRARIES = libfib.la -# 1) If the library source code has changed at all since the last update, then -# increment revision ("c:r:a" becomes "c:r+1:a"). -# 2) If any interfaces have been added, removed, or changed since the last -# update, increment current, and set revision to 0. +# 1) If the library source code has changed at all since the last update, +* then increment revision ("c:r:a" becomes "c:r+1:a"). +# 2) If any interfaces have been added, removed, or changed since the +# last update, increment current, and set revision to 0. # 3) If any interfaces have been added since the last public release, # then increment age. -# 4) If any interfaces have been removed or changed since the last public -# release, then set age to 0. +# 4) If any interfaces have been removed or changed since the last +# public release, then set age to 0. + libfib_la_LDFLAGS = -release @PACKAGE_VERSION@ -version-info 0:0:0 + libfib_la_SOURCES = fib.c include_HEADERS = fib.h \end{verbatim} @@ -819,12 +823,12 @@ Makefile.am: installing './depcomp' \begin{frame}[fragile] \frametitle{what about the m4 macros warnings?} -libtool wants to install its m4 scripts into the project. - -This is useful if you pass the project to other people that might have other +\begin{itemize} +\item libtool wants to install its m4 scripts into the project. +\item This is useful if you pass the project to other people that might have other versions of libtool installed on their machine. - -prepare a directory for these scripts in 'autogen.sh': +\item prepare a directory for these scripts in 'autogen.sh': +\end{itemize} \begin{verbatim} #!/bin/sh mkdir -p m4 @@ -876,11 +880,12 @@ looks sane, but the pkg-config .pc file is missing \begin{frame}[fragile] \frametitle{add a libfib pkg-config .pc file} -Remember, the .pc file contains the paths where the library and headers are +\begin{itemize} +\item Remember, the .pc file contains the paths where the library and headers are installed. - -These paths are defined by './configure' parameters. So we have to generate +\item These paths are defined by './configure' parameters. So we have to generate a template 'fib/fib.pc.in': +\end{itemize} \begin{verbatim} prefix=@prefix@ exec_prefix=@exec_prefix@ |
