Annotation of htdocs/docs/pkgsrc/examples.html, revision 1.181
1.120 sevan 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1.1 dsieger 2: <html>
3: <head>
4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5: <title>Appendix A. A simple example package: bison</title>
1.26 spz 6: <link rel="stylesheet" type="text/css" href="/global.css">
1.1 dsieger 7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
1.15 rillig 8: <link rel="home" href="index.html" title="The pkgsrc guide">
1.1 dsieger 9: <link rel="up" href="index.html" title="The pkgsrc guide">
1.154 rillig 10: <link rel="prev" href="porting.html" title="Chapter 28. Porting pkgsrc">
1.1 dsieger 11: <link rel="next" href="logs.html" title="Appendix B. Build logs">
12: </head>
13: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14: <div class="navheader">
15: <table width="100%" summary="Navigation header">
16: <tr><th colspan="3" align="center">Appendix A. A simple example package: bison</th></tr>
17: <tr>
18: <td width="20%" align="left">
19: <a accesskey="p" href="porting.html">Prev</a> </td>
20: <th width="60%" align="center"> </th>
21: <td width="20%" align="right"> <a accesskey="n" href="logs.html">Next</a>
22: </td>
23: </tr>
24: </table>
25: <hr>
26: </div>
1.42 asau 27: <div class="appendix">
28: <div class="titlepage"><div><div><h1 class="title">
29: <a name="examples"></a>Appendix A. A simple example package: bison</h1></div></div></div>
1.1 dsieger 30: <div class="toc">
31: <p><b>Table of Contents</b></p>
1.100 leot 32: <dl class="toc">
1.1 dsieger 33: <dt><span class="sect1"><a href="examples.html#example-files">A.1. files</a></span></dt>
34: <dd><dl>
35: <dt><span class="sect2"><a href="examples.html#example-Makefile">A.1.1. Makefile</a></span></dt>
36: <dt><span class="sect2"><a href="examples.html#example-descr">A.1.2. DESCR</a></span></dt>
37: <dt><span class="sect2"><a href="examples.html#example-plist">A.1.3. PLIST</a></span></dt>
1.172 rillig 38: <dt><span class="sect2"><a href="examples.html#checking-package-with-pkglint">A.1.4. Checking a package with pkglint</a></span></dt>
1.1 dsieger 39: </dl></dd>
40: <dt><span class="sect1"><a href="examples.html#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
41: </dl>
42: </div>
43: <p>We checked to find a piece of software that wasn't in the packages
44: collection, and picked GNU bison. Quite why someone would want to have
1.10 hubertf 45: <span class="command"><strong>bison</strong></span> when Berkeley <span class="command"><strong>yacc</strong></span> is already
1.1 dsieger 46: present in the tree is beyond us, but it's useful for the purposes of
47: this exercise.</p>
1.42 asau 48: <div class="sect1">
1.1 dsieger 49: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
50: <a name="example-files"></a>A.1. files</h2></div></div></div>
1.42 asau 51: <div class="sect2">
1.1 dsieger 52: <div class="titlepage"><div><div><h3 class="title">
53: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
54: <pre class="programlisting">
55: # $NetBSD$
56: #
57:
58: DISTNAME= bison-1.25
59: CATEGORIES= devel
1.171 rillig 60: MASTER_SITES= ${MASTER_SITE_GNU:=bison/}
1.1 dsieger 61:
1.30 dholland 62: MAINTAINER= pkgsrc-users@NetBSD.org
1.174 leot 63: HOMEPAGE= https://www.gnu.org/software/bison/bison.html
1.1 dsieger 64: COMMENT= GNU yacc clone
65:
66: GNU_CONFIGURE= yes
1.47 wiz 67: INFO_FILES= yes
1.1 dsieger 68:
69: .include "../../mk/bsd.pkg.mk"
70: </pre>
71: </div>
1.42 asau 72: <div class="sect2">
1.1 dsieger 73: <div class="titlepage"><div><div><h3 class="title">
74: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
75: <pre class="programlisting">
76: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.174 leot 77: improvements. Why you would want this when Berkeley <a class="citerefentry" href="https://netbsd.gw.com/cgi-bin/man-cgi?yacc+1.i386+NetBSD-9.0"><span class="citerefentry"><span class="refentrytitle">yacc</span>(1)</span></a> is part
1.1 dsieger 78: of the NetBSD source tree is beyond me.
79: </pre>
80: </div>
1.42 asau 81: <div class="sect2">
1.1 dsieger 82: <div class="titlepage"><div><div><h3 class="title">
83: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
84: <pre class="programlisting">
85: @comment $NetBSD$
86: bin/bison
87: man/man1/bison.1.gz
88: share/bison.simple
89: share/bison.hairy
90: </pre>
91: </div>
1.42 asau 92: <div class="sect2">
1.1 dsieger 93: <div class="titlepage"><div><div><h3 class="title">
1.172 rillig 94: <a name="checking-package-with-pkglint"></a>A.1.4. Checking a package with pkglint</h3></div></div></div>
1.1 dsieger 95: <p>The NetBSD package system comes with
1.137 leot 96: <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
1.1 dsieger 97: which helps to check the contents of these
98: files. After installation it is quite easy to use, just change to the
1.171 rillig 99: directory of the package you wish to examine and run
1.10 hubertf 100: <span class="command"><strong>pkglint</strong></span>:</p>
1.1 dsieger 101: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
1.171 rillig 102: ERROR: Makefile: Each package must define its LICENSE.
103: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
104: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
105: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
106: 1 error, 2 warnings and 1 note found.
107: (Run "pkglint -e" to show explanations.)
108: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172 rillig 109: (Run "pkglint -F" to automatically fix some issues.)</pre>
1.1 dsieger 110: <p>Depending on the supplied command line arguments (see pkglint(1)),
1.170 rillig 111: more checks will be performed. Use e.g. <span class="command"><strong>pkglint
1.1 dsieger 112: -Wall</strong></span> for a very thorough check.</p>
113: </div>
114: </div>
1.42 asau 115: <div class="sect1">
1.1 dsieger 116: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
117: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
118: <p>Create the directory where the package lives,
119: plus any auxiliary directories:</p>
120: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
121: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
122: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
123: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
124: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.154 rillig 125: <code class="filename">PLIST</code> (see <a class="xref" href="components.html" title="Chapter 13. Package components - files, directories and contents">Chapter 13, <i>Package components - files, directories and contents</i></a>)
1.1 dsieger 126: then continue with fetching the distfile:</p>
127: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
128: >> bison-1.25.tar.gz doesn't seem to exist on this system.
129: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
130: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
131: ftp: Error retrieving file: 500 Internal error
132:
133: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
134: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
135: ftp: Error retrieving file: 500 Internal error
136:
137: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
138: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
139: Successfully retrieved file.</pre>
140: <p>Generate the checksum of the distfile into
141: <code class="filename">distinfo</code>:</p>
142: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
143: <p>Now compile:</p>
144: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
145: >> Checksum OK for bison-1.25.tar.gz.
146: ===> Extracting for bison-1.25
147: ===> Patching for bison-1.25
148: ===> Ignoring empty patch directory
149: ===> Configuring for bison-1.25
150: creating cache ./config.cache
151: checking for gcc... cc
152: checking whether we are using GNU C... yes
153: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
154: checking how to run the C preprocessor... cc -E
155: checking for minix/config.h... no
156: checking for POSIXized ISC... no
157: checking whether cross-compiling... no
158: checking for ANSI C header files... yes
159: checking for string.h... yes
160: checking for stdlib.h... yes
161: checking for memory.h... yes
162: checking for working const... yes
163: checking for working alloca.h... no
164: checking for alloca... yes
165: checking for strerror... yes
166: updating cache ./config.cache
167: creating ./config.status
168: creating Makefile
169: ===> Building for bison-1.25
170: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g LR0.c
171: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g allocate.c
172: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g closure.c
173: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g conflicts.c
174: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g derives.c
175: cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\" -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -g ./files.c
176: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getargs.c
177: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g gram.c
178: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lalr.c
179: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lex.c
180: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g main.c
181: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g nullable.c
182: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g output.c
183: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g print.c
184: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reader.c
185: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reduce.c
186: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g symtab.c
187: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g warshall.c
188: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g version.c
189: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt.c
190: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt1.c
191: cc -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o getargs.o gram.o lalr.o lex.o main.o nullable.o output.o print.o reader.o reduce.o symtab.o warshall.o version.o getopt.o getopt1.o
192: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
193: rm -f bison.s1
194: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
195: <p>Everything seems OK, so install the files:</p>
196: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
197: >> Checksum OK for bison-1.25.tar.gz.
198: ===> Installing for bison-1.25
199: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
200: rm -f /usr/pkg/bin/bison
201: cd /usr/pkg/share; rm -f bison.simple bison.hairy
202: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
203: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
204: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
205: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
206: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
207: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
208: ===> Registering installation for bison-1.25</pre>
209: <p>You can now use bison, and also - if you decide so - remove it with
1.10 hubertf 210: <span class="command"><strong>pkg_delete bison</strong></span>. Should you decide that you want a
1.1 dsieger 211: binary package, do this now:</p>
212: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
213: >> Checksum OK for bison-1.25.tar.gz.
214: ===> Building package for bison-1.25
215: Creating package bison-1.25.tgz
216: Registering depends:.
217: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
218: <p>Now that you don't need the source and object files
219: any more, clean up:</p>
220: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
221: ===> Cleaning for bison-1.25</pre>
222: </div>
223: </div>
224: <div class="navfooter">
225: <hr>
226: <table width="100%" summary="Navigation footer">
227: <tr>
228: <td width="40%" align="left">
229: <a accesskey="p" href="porting.html">Prev</a> </td>
230: <td width="20%" align="center"> </td>
231: <td width="40%" align="right"> <a accesskey="n" href="logs.html">Next</a>
232: </td>
233: </tr>
234: <tr>
1.154 rillig 235: <td width="40%" align="left" valign="top">Chapter 28. Porting pkgsrc </td>
1.1 dsieger 236: <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
237: <td width="40%" align="right" valign="top"> Appendix B. Build logs</td>
238: </tr>
239: </table>
240: </div>
241: </body>
242: </html>
CVSweb <webmaster@jp.NetBSD.org>