<?xml version="1.0"?>
<!DOCTYPE webpage
 PUBLIC "-//NetBSD//DTD Website-based NetBSD Extension//EN"
        "http://www.NetBSD.org/XML/htdocs/lang/share/xml/website-netbsd.dtd">

<webpage id="developers-new-port">
<config param="desc" value="Adding a new port to NetBSD"/>
<config param="cvstag" value="$NetBSD: new-port.xml,v 1.12 2007/08/16 16:00:04 dsieger Exp $"/>
<config param="rcsdate" value="$Date: 2007/08/16 16:00:04 $"/>
<head>
  <!-- Copyright (c) 1994-2005
       The NetBSD Foundation, Inc.  ALL RIGHTS RESERVED. -->

  <title>NetBSD Developer Documentation: Adding a new port</title>
</head>

<para>The following is intended to be a brief list of items that
  need to be addressed when adding a new port to the NetBSD
  tree.</para>
<para>Note the new files should be added with <code>cvs add</code>, not
  <code>cvs import</code>.
  Importing is for vendor branches, whereas this code is to be integrated
  as part of NetBSD, and it's also one more needless tag on each
  file.</para>

<sect1 role="toc">
  <sect2 id="starting-out">
    <title>Steps for those just starting out</title>

    <sect3 id="atfirst">
      <title>Things to try at first</title>

      <para>
	<itemizedlist>
	  <listitem>Try to find as much documentation as you can. 
	    Then try some more. Contact the original vendor, and the 
	    vendors of major chips used  on the boards. Frequently the 
	    source for another vendor's OS (even Linux) can prove a 
	    useful resource.</listitem>
	  <listitem>Copy the sys tree of a similar port.</listitem>
	  <listitem>Setup a cross compiler on another NetBSD machine
	    (something with the same CPU would be ideal, but usually an 
	    i386 should be fine).</listitem>
	  <listitem>Work out how to generate a binary understood by the 
	    boot loader. If there is an existing OS on the target, 
	    you might be better off taking advantage of it.</listitem>
	  <listitem>Try to build a standalone binary which can output to 
	    the console, possibly using PROM drivers, or serial console. 
	    No need for VM.</listitem>
	  <listitem>Build a kernel with memorydisk root.</listitem>
	  <listitem>Add disk and network device support. It may be easier 
	    to start with external cards for which MI drivers already 
	    exist in the NetBSD tree.</listitem>
	</itemizedlist>
      </para>
    </sect3>
  </sect2>

  <sect2 id="addressed-items">
    <title>Items that need to be addressed when adding new port</title>

    <sect3 id="cvssetting">
      <title>CVS setting</title>

      <para>Setting up cvs checkout-update-commit environment.
	<itemizedlist>
	  <listitem>Read <ulink 
	    url="cvs-repos/cvs_intro.html">NetBSD CVS HOWTO</ulink> and 
	    setup CVS commitable environment.</listitem>
	  <listitem><code>cvs checkout {htdocs,htutils,doc}</code></listitem>
	</itemizedlist>
      </para>
    </sect3>

    <sect3 id="htdocs">
      <title>htdocs changes</title>

      <para>Edit and commit information about your new port on 
	www.NetBSD.org. Obviously, you need to create a port page under 
	<filename>htdocs/ports/${MACHINE}/</filename> first. 
	Please do not commit modifications 
	to other htdocs files until this page has been created and is 
	committed. The DocBook/XML format is useful for FAQ-style
	information (see the <ulink 
	url="htdocs.html">htdocs documentation</ulink>).
	
	<itemizedlist>
	  <listitem>Create <filename>htdocs/ports/${MACHINE}/</filename>, 
	    add link from <filename>htdocs/index.html</filename>,
	    <filename>htdocs/ports/index.xml</filename>.
	    You may want to include a copy of this checklist and mark off 
	    items as completed. If you wish to include a logo or a graphic 
	    for your port page, please make sure that you get permission 
	    from the copyright owner (if applicable) before adding a new
	    image to the htdocs tree.</listitem>
	  <listitem>Add details to
	    <filename>htdocs/changes/index.xml</filename> and regenerate 
	    the HTML file with &man.make.1;.
	    See <ulink 
	    url="htdocs.html#adding-news-items">htdocs documentation</ulink> 
	    for details.</listitem>
	  <listitem>Add to tables in
	    <itemizedlist>
	      <listitem>
		<filename>htdocs/about/query-pr.xml</filename> and regenerate
                  the HTML file with &man.make.1;</listitem>
	      <listitem>
		<filename>htutils/cgi-src/gnats/netbsd.def</filename></listitem>
	      <listitem>
		<filename>htutils/changes/changes2html</filename></listitem>
	      <listitem>
		<filename>htutils/changes/code-changes2rss</filename></listitem>
	      <listitem>
		<filename>htutils/changes/cvschanges2html</filename></listitem>
	    </itemizedlist></listitem>
	  <listitem>Add to
	    <filename>htdocs/developers/features/table</filename> and 
	    regenerate.</listitem>
	  <listitem>Add your entry to
	    <filename>htdocs/people/port-maintainers.xml</filename>.</listitem>
	</itemizedlist>
      The list of modified files should be committed in one go. 
      Please contact <email>www@NetBSD.org</email> if you have any 
      questions and remember to announce the new port on other websites 
      once the new html files are online.</para>
    </sect3>

    <sect3 id="gnatsconfig">
      <title>GNATS configration</title>
      
      <para>
	<itemizedlist>
	  <listitem>Add new category to
	    <filename>src/gnu/usr.bin/send-pr/categories</filename></listitem>
	  <listitem>Send mail to <email>admins@NetBSD.org</email> about creating the new category 
	    on the GNATS server.</listitem>
	</itemizedlist>
      </para>
    </sect3>

    <sect3 id="mail">
      <title>Mail changes (requires special privileges)</title>

      <para>
	<itemizedlist>
	  <listitem>Create <code>port-${MACHINE}</code> mailing list. 
	    Send a request to <email>admins@NetBSD.org</email> over it.</listitem>
	  <listitem>Add new <code>port-${MACHINE}</code> list to 
	    <filename>htdocs/mailinglists/index.xml</filename>. Regenerate 
	    with &man.make.1;.</listitem>
	  <listitem>Create <code>port-${MACHINE}-maintainer</code> alias for 
	    the portmaster.</listitem>
	  <listitem>Add portmaster to the port-masters mailing
	    list.</listitem>
	  <listitem>Add <code>port-${MACHINE}-maintainer</code> to bug-managers 
	    mailing list. e.g. add port-hpcmips-maintainer to
	    bug-managers.</listitem>
	  <listitem>If the port uses a shared <code>MACHINE_ARCH</code>, 
	    add <code>port-${MACHINE}-maintainer</code> to the 
	    <code>port-${MACHINE_ARCH}-maintainer</code> mailing list,
	    e.g. add port-hpcmips-maintainer to
	    port-mips-maintainer.</listitem>
	</itemizedlist>
      </para>
    </sect3>
    
    <sect3 id="ftpdirectory">
      <title>Create FTP directory for snapshots of new port</title>

      <para>
	<itemizedlist>
	  <listitem>Update port machinery in
	    <filename>distrib/</filename> to build snapshots and releases.
	    Did you create <filename>src/distrib/${MACHINE}</filename>
	    ?</listitem>
	  <listitem>Make snapshot. See <ulink 
	    url="releng/build-release.html">NetBSD Developer Documentation: Release Engineering</ulink></listitem>
	  <listitem>Make source tarballs. The
	    <filename>src/distrib/sets/makesrctars</filename> script 
	    will help you.</listitem>
	  <listitem>Create
	    <code>ftp.NetBSD.org:/pub/NetBSD/arch/${MACHINE}/snapshot/YYYYMMDD/</code>
	    and put the snapshot there.</listitem>
	</itemizedlist>
      </para>
    </sect3>

    <sect3 id="other">
      <title>Other changes</title>

      <para>
	<itemizedlist>
	  <listitem>Add an entry to
	    <filename>src/doc/CHANGES</filename>.</listitem>
	  <listitem>Add an entry to
	    <filename>src/build.sh</filename>.</listitem>
	  <listitem>Regenerate
	    <filename>src/tools/headerlist</filename>
	    by running
	    <filename>src/tools/mkheaderlist.sh</filename>.</listitem>
	  <listitem>Add an entry to
	    <filename>src/gnu/usr.bin/groff/tmac/mdoc.local</filename>.</listitem>
	  <listitem>Add an entry to
	    <filename>src/distrib/notes/common/main</filename>.</listitem>
	  <listitem>Add an entry to
	    <filename>src/share/man/man7/hier.7</filename>.</listitem>
	  <listitem>Add an entry to
	    <filename>src/sys/arch/README</filename>.</listitem>
	  <listitem>Add an entry to
	    <filename>src/sys/arch/Makefile</filename>.</listitem>
	  <listitem>Add an entry to
	    <filename>src/usr.bin/calendar/calendars/calendar.netbsd</filename>.</listitem>
	  <listitem>Create &man.sup.1; set for new port
	    (current and release collection for
	    <filename>src/sys/arch/${MACHINE}/</filename>,
	    and mirror collection for 
	    <code>ftp.NetBSD.org:/pub/NetBSD/arch/${MACHINE}/</code>).
	    Consult other developers.</listitem>
	  <listitem>Update tarball-building scripts to build tarball for 
	    new <code>${MACHINE}</code>. Consult other
	    developers.</listitem>
	  <listitem>Send email to <email>announce@NetBSD.org</email> 
	    and note the announcement on the WWW news page.</listitem>
	</itemizedlist>
      </para>
    </sect3>
  </sect2>

  <sect2 id="important-tasks">
    <title>Important tasks once port is imported into the tree</title>

    <sect3 id="whatnow">
      <title>You mean there's more?</title>

      <para>
	<itemizedlist>
	  <listitem>Keep adding hardware support.</listitem>
	  <listitem>Get sysinst running.</listitem>
	  <listitem>Produce formal releases.</listitem>
	  <listitem>Write a
	    <code>compat_&lt;original_os&gt;</code>.</listitem>
	  <listitem>Ongoing maintenance. Make sure your port continues
	    to build and run as the NetBSD source tree
	    evolves.</listitem>
	</itemizedlist>
      </para>
    </sect3>
  </sect2>
  
  <sect2 id="other-documents">
    <title>Other related documents</title>

    <sect3 id="related-uwe">
      <title>Valeriy E. Ushakov's papers</title>

      <para>Valeriy a related paper on <ulink
      url="http://snark.ptc.spbu.ru/~uwe/netbsd/euro2002/krups.ps">how to
      get started on a new port</ulink>.
	</para>
    </sect3>

    <sect3 id="related-fvdl">
      <title>Frank van der Linden's papers</title>

      <para>Frank van der Linden's paper <ulink
        url="http://www.usenix.org/publications/library/proceedings/bsdcon02/full_papers/linden/linden_html/">Porting
	NetBSD to the AMD x86-64: a case study in OS portability</ulink>
	from BSDCon 2002.
	</para>
    </sect3>

  </sect2>
</sect1>
<parentsec url="./" text="NetBSD Developer Documentation"/>
</webpage>

