📄 autobook_240.html
字号:
<HTML><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><!-- Created on September, 12 2004 by texi2html 1.64 --><!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) Karl Berry <karl@freefriends.org> Olaf Bachmann <obachman@mathematik.uni-kl.de> and many others.Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> --><HEAD><TITLE>Autoconf, Automake, and Libtool: 24.3 Example: Quick And Dirty</TITLE><META NAME="description" CONTENT="Autoconf, Automake, and Libtool: 24.3 Example: Quick And Dirty"><META NAME="keywords" CONTENT="Autoconf, Automake, and Libtool: 24.3 Example: Quick And Dirty"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META NAME="Generator" CONTENT="texi2html 1.64"><script language="Javascript"><!-- // Check the browser version. function checkVersion() { if (navigator.appVersion.charAt(0)>=3) return true; if (navigator.appVersion.charAt(0)>=4) return true; else return false; } if (checkVersion()) { homeon = new Image(); homeon.src = "homeon.png"; homeoff = new Image(); homeoff.src = "home.png"; tocon = new Image(); tocon.src = "tocon.png"; tocoff = new Image(); tocoff.src = "toc.png"; indexon = new Image(); indexon.src = "indexon.png"; indexoff = new Image(); indexoff.src = "index.png"; helpon = new Image(); helpon.src = "helpon.png"; helpoff = new Image(); helpoff.src = "help.png"; backon = new Image(); backon.src = "backon.png"; backoff = new Image(); backoff.src = "back.png"; forwardon = new Image(); forwardon.src = "forwardon.png"; forwardoff = new Image(); forwardoff.src = "forward.png"; prevon = new Image(); prevon.src = "prevon.png"; prevoff = new Image(); prevoff.src = "prev.png"; nexton = new Image(); nexton.src = "nexton.png"; nextoff = new Image(); nextoff.src = "next.png"; upon = new Image(); upon.src = "upon.png"; upoff = new Image(); upoff.src = "up.png"; } function img_act(imgName) { if (checkVersion()) { imgOn = eval(imgName + "on.src"); document [imgName].src = imgOn; } } function img_inact(imgName) { if (checkVersion()) { imgOff = eval(imgName + "off.src"); document [imgName].src = imgOff; } }// --></SCRIPT></HEAD><BODY LANG="EN" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#6688AA" VLINK="#336688" ALINK="#808080"><A NAME="SEC240"></A><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=10><TR VALIGN="TOP"><TD ALIGN="MIDDLE" WIDTH=50 BGCOLOR="#e6e6e6"><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_239.html#SEC239" onMouseover="img_act('prev')" onMouseout="img_inact('prev')"><IMG SRC="prev.png" BORDER="0" ALT="Back: 24.2 Overview of the Two Approaches" ALIGN="MIDDLE" NAME="prev"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_241.html#SEC241" onMouseover="img_act('next')" onMouseout="img_inact('next')"><IMG SRC="next.png" BORDER="0" ALT="Forward: 24.4 Example: The Full Pull" ALIGN="MIDDLE" NAME="next"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_241.html#SEC241" onMouseover="img_act('back')" onMouseout="img_inact('back')"><IMG SRC="back.png" BORDER="0" ALT="FastBack: 24.4 Example: The Full Pull" ALIGN="MIDDLE" NAME="back"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_237.html#SEC237" onMouseover="img_act('up')" onMouseout="img_inact('up')"><IMG SRC="up.png" BORDER="0" ALT="Up: Migrating Existing Packages" ALIGN="MIDDLE" NAME="up"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_242.html#SEC242" onMouseover="img_act('forward')" onMouseout="img_inact('forward')"><IMG SRC="forward.png" BORDER="0" ALT="FastForward: Integration with Cygnus Cygwin" ALIGN="MIDDLE" NAME="forward"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook.html#SEC_Top" onMouseover="img_act('home')" onMouseout="img_inact('home')"><IMG SRC="home.png" BORDER="0" ALT="Top: Autoconf, Automake, and Libtool" ALIGN="MIDDLE" NAME="home"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_toc.html#SEC_Contents" onMouseover="img_act('toc')" onMouseout="img_inact('toc')"><IMG SRC="toc.png" BORDER="0" ALT="Contents: Table of Contents" ALIGN="MIDDLE" NAME="toc"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_285.html#SEC285" onMouseover="img_act('index')" onMouseout="img_inact('index')"><IMG SRC="index.png" BORDER="0" ALT="Index: Index" ALIGN="MIDDLE" NAME="index"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_abt.html#SEC_About" onMouseover="img_act('help')" onMouseout="img_inact('help')"><IMG SRC="help.png" BORDER="0" ALT="About: About this document" ALIGN="MIDDLE" NAME="help"></A></TD></TR></TABLE></TD><TD ALIGN="LEFT"><H2> 24.3 Example: Quick And Dirty </H2><!--docid::SEC240::--><P>As part of the <CODE>libgcj</CODE> project <A NAME="DOCF55" HREF="autobook_fot.html#FOOT55">(55)</A>, I had to incorporate the<CODE>zip</CODE> program into our source tree. Since this particular programis only used in one part of the build, and since this program wasalready fairly portable, I decided to take a quick-and-dirty approach toautoconfiscation.</P><P>First I read through the <TT>`README'</TT> and <TT>`install.doc'</TT> files tosee how <CODE>zip</CODE> is ordinarily built. From there I learned that<CODE>zip</CODE> came with a <TT>`Makefile'</TT> used to build all Unix ports(and, for the initial autoconfiscation, Unix was all I was interestedin), so I read that. This file indicated that <CODE>zip</CODE> had fewconfigurability options.</P><P>Running <CODE>ifnames</CODE> on the sources, both Unix and generic, confirmedthat the <CODE>zip</CODE> sources were mostly self-configuring, usingsystem-specific <SAMP>`#defines'</SAMP>---a practice which we recommend against;however for a quicky-and-dirty port it is not worth cleaning up:</P><P><TABLE width=100%><tr><td> </td><td class=example bgcolor=#6688aa><br><pre>$ ifnames *.[ch] unix/*.[ch] | grep ^__ | head__386BSD__ unix/unix.c__CYGWIN32__ unix/osdep.h__CYGWIN__ unix/osdep.h__DATE__ unix/unix.c zipcloak.c zipnote.c zipsplit.c__DEBUG_ALLOC__ zip.c__ELF__ unix/unix.c__EMX__ fileio.c ttyio.h util.c zip.c__FreeBSD__ unix/unix.c__G ttyio.h__GNUC__ unix/unix.c zipcloak.c zipnote.c zipsplit.c</pre></td></tr></table></P><P>Based on this information I wrote my initial <TT>`configure.in'</TT>, whichis the one still in use today:</P><P><TABLE width=100%><tr><td> </td><td class=example bgcolor=#6688aa><br><pre>AC_INIT(ziperr.h)AM_INIT_AUTOMAKE(zip, 2.1)AM_MAINTAINER_MODEAC_PROG_CCAC_HEADER_DIRENTAC_DEFINE(UNIX)AC_LINK_FILES(unix/unix.c, unix.c)AC_OUTPUT(Makefile)</pre></td></tr></table></P><P>The one mysterious part of this <TT>`configure.in'</TT> is the define of the<SAMP>`UNIX'</SAMP> preprocessor macro. This define came directly from<CODE>zip</CODE>'s <TT>`unix/Makefile'</TT> file; <CODE>zip</CODE> uses this define toenable certain Unix-specific pieces of code.</P><P>In this particular situation, I lucked out. <CODE>zip</CODE> was unusuallyeasy to autoconficate. Typically more actual checks are required in<TT>`configure.in'</TT>, and more than a single iteration is required to geta workable configuration system.</P><P>From <TT>`unix/Makefile'</TT> I also learned which files were expected to bebuilt in order to produce the <CODE>zip</CODE> executable. This informationlet me write my <TT>`Makefile.am'</TT>:</P><P><TABLE width=100%><tr><td> </td><td class=example bgcolor=#6688aa><br><pre>## Process this file with automake to create Makefile.in.## NOTE: this file doesn't really try to be complete. In particular## `make dist' won't work at all. We're just aiming to get the## program built. We also don't bother trying to assemble code, or## anything like that.AUTOMAKE_OPTIONS = no-dependenciesINCLUDES = -I$(srcdir)/unixbin_PROGRAMS = zipzip_SOURCES = zip.c zipfile.c zipup.c fileio.c util.c globals.c \ crypt.c ttyio.c unix.c crc32.c crctab.c deflate.c trees.c bits.c## This isn't really correct, but we don't care.$(zip_OBJECTS) : zip.h ziperr.h tailor.h unix/osdep.h crypt.h \ revision.h ttyio.h unix/zipup.h</pre></td></tr></table></P><P>This file provides a good look at some of the tradeoffs involved. In mycase, I didn't care about full correctness of the resulting<TT>`Makefile.am'</TT> -- I wasn't planning to maintain the project, I justwanted it to build in my particular set of environments.</P><P>So, I sacrificed <SAMP>`dist'</SAMP> capability to make my work easier. Also, Idecided to disable dependency tracking and instead make all theresulting object files depend on all the headers in the project. Thisapproach is inefficient, but in my situation perfectly reasonable, as Iwasn't planning to do any actual development on this package -- I wassimply looking to make it build so that it could be used to build theparts of the package I was actually hacking.</P><P></TR></TABLE><BR> <FONT SIZE="-1">This document was generatedby <I>Gary V. Vaughan</I> on <I>September, 12 2004</I>using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html"><I>texi2html</I></A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -