View | Details | Raw Unified | Return to bug 101365
Collapse All | Expand All

(-)book.sgml (-5 / +70 lines)
Lines 3942-3947 Link Here
3942
      <para>There are some more things you have to take into account when you
3942
      <para>There are some more things you have to take into account when you
3943
	create a port.  This section explains the most common of those.</para>
3943
	create a port.  This section explains the most common of those.</para>
3944
3944
3945
      <sect1 id="building-in-jails">
3946
        <title>Building in jails</title>
3947
3948
	<para>Note, that the behavior of <makevar>OSVERSION</makevar> has been
3949
	  changed recently.  Now, it gets the <link
3950
	   linkend="freebsd-versions"><literal>__FreeBSD_version</literal></link>
3951
	  from the userland, since it makes more sense for the ports, than the
3952
	  kernel.  You can still override it, if you really have to get it from
3953
	  the kernel.</para>
3954
3955
      </sect1>
3956
3945
      <sect1 id="porting-shlibs">
3957
      <sect1 id="porting-shlibs">
3946
	<title>Shared Libraries</title>
3958
	<title>Shared Libraries</title>
3947
3959
Lines 4758-4764 Link Here
4758
	    <row>
4770
	    <row>
4759
	      <entry><makevar>USE_X_PREFIX</makevar></entry>
4771
	      <entry><makevar>USE_X_PREFIX</makevar></entry>
4760
4772
4761
	      <entry>The port installs in <makevar>X11BASE</makevar>, not
4773
	      <entry>The port installs in <makevar>X11BASE_REL</makevar>, not
4762
		<makevar>PREFIX</makevar>.</entry>
4774
		<makevar>PREFIX</makevar>.</entry>
4763
	    </row>
4775
	    </row>
4764
4776
Lines 6779-6795 Link Here
6779
      </sect1>
6791
      </sect1>
6780
6792
6781
      <sect1 id="porting-prefix">
6793
      <sect1 id="porting-prefix">
6782
	<title><makevar>PREFIX</makevar></title>
6794
	<title><makevar>PREFIX</makevar> and <makevar>DESTDIR</makevar></title>
6783
6795
6796
	<para>Firstly, you should completely unerstand what these two
6797
	  variables are for.  <makevar>PREFIX</makevar> determines the
6798
	  location where all ports should install in the current environemt.
6799
	  This is usually <filename>/usr/local</filename>, or
6800
	  <filename>/opt</filename> in other operating systems.   You
6801
	  can set <makevar>PREFIX</makevar> to everything you want, See the
6802
	  <a href="http://www.pathname.com/fhs/2.2/>Filesystem Hierarchy
6803
	  Standard</a> for making a good decision.  <makevar>DESTDIR</makevar>
6804
	  determines the whole environment you want to use the package from.
6805
	  This environment can be a jail, or an installed system mounted
6806
	  elsewhere than <filename>/</filename>.  This means a port will
6807
	  actually install to <makevar>DESTDIR</makevar>/<makevar>PREFIX</makevar>,
6808
	  and registered in the package database of the given environment.
6809
	  It is very important that you write such ports that respect this,
6810
	  thus you can find some guidelines below to do so.</para>
6811
	 
6784
	<para>Do try to make your port install relative to
6812
	<para>Do try to make your port install relative to
6785
	  <makevar>PREFIX</makevar>.  The value of this variable will be set
6813
	  <makevar>PREFIX</makevar>.  The value of this variable will be set
6786
	  to <makevar>LOCALBASE</makevar> (default
6814
	  to <makevar>LOCALBASE_REL</makevar> (default
6787
	  <filename>/usr/local</filename>).  If
6815
	  <filename>/usr/local</filename>).  If
6788
	  <makevar>USE_X_PREFIX</makevar> or <makevar>USE_IMAKE</makevar> is
6816
	  <makevar>USE_X_PREFIX</makevar> or <makevar>USE_IMAKE</makevar> is
6789
	  set, <makevar>PREFIX</makevar> will be <makevar>X11BASE</makevar> (default
6817
	  set, <makevar>PREFIX</makevar> will be <makevar>X11BASE_REL</makevar> (default
6790
	  <filename>/usr/X11R6</filename>).  If
6818
	  <filename>/usr/X11R6</filename>).  If
6791
	  <makevar>USE_LINUX_PREFIX</makevar> is set, <makevar>PREFIX</makevar>
6819
	  <makevar>USE_LINUX_PREFIX</makevar> is set, <makevar>PREFIX</makevar>
6792
	  will be <makevar>LINUXBASE</makevar> (default
6820
	  will be <makevar>LINUXBASE_REL</makevar> (default
6793
	  <filename>/compat/linux</filename>).</para>
6821
	  <filename>/compat/linux</filename>).</para>
6794
6822
6795
	<para>Avoiding the hard-coding of <filename>/usr/local</filename> or
6823
	<para>Avoiding the hard-coding of <filename>/usr/local</filename> or
Lines 6840-6845 Link Here
6840
	  <literal>-DPAGER=\"/usr/local/bin/less\"</literal>. This way it will
6868
	  <literal>-DPAGER=\"/usr/local/bin/less\"</literal>. This way it will
6841
	  have a better chance of working if the system administrator has
6869
	  have a better chance of working if the system administrator has
6842
	  moved the whole <filename>/usr/local</filename> tree somewhere else.</para>
6870
	  moved the whole <filename>/usr/local</filename> tree somewhere else.</para>
6871
6872
	<para>For writing <makevar>DESTDIR</makevar>-compliant ports, note that
6873
	  <makevar>LOCALBASE</makevar>, <makevar>LINUXBASE</makevar>,
6874
	  <makevar>X11BASE</makevar>, <makevar>DOCSDIR</makevar>,
6875
	  <makevar>EXAMPLESDIR</makevar>, <makevar>DATADIR</makevar>, 
6876
	  <makevar>DESKTOPDIR</makevar> variables already contain
6877
	  <makevar>DESTDIR</makevar>, so
6878
	  <makevar>DESTDIR</makevar>/<makevar>LOCALBASE</makevar> is
6879
	  definitely wrong, but you can use <makevar>LOCALBASE_REL</makevar> if
6880
	  you need a variable relative to <makevar>DESTDIR</makevar>.
6881
	  Similarly, you can use <makevar>LINUXBASE_REL</makevar> and
6882
	  <makevar>X11BASE_REL</makevar> variables as well.
6883
	  <makevar>PREFIX</makevar> is an absolute path. but relative
6884
	  to <makewar>DESTDIR</makevar>.  If you want to refer to the
6885
	  fully qualified destination you can use <makevar>TARGETDIR</makevar>,
6886
	  which resolves to <makevar>DESTDIR</makevar>/<makevar>PREFIX</makevar>.</para>
6887
6888
	<para>You have to use these variables correctly
6889
	  in your ports <filename>Makefile</filename>, esepecially in
6890
	  custom targets, to ensure each files are installed to the
6891
	  corect place.  For dependencies, using <makevar>LOCALBASE</makevar>
6892
	  is still correct, since we want to check for dependencies
6893
	  in <makevar>DESTDIR</makevar>.</para>
6894
6895
	<para>In packing lists, or in <filename>pkg-*</filename> scripts you
6896
	  can still use <literal>%%LOCALBASE%%</literal>,
6897
	  <literal>%%LINUXBASE%%</literal> and <literal>%%X11BASE%%</literal>
6898
	  expansions, since they represent relative paths there.  This ambiguity
6899
	  can be frustrating at first, but this actually simplifies the process
6900
	  of writing <makevar>DESTDIR</makevar>-compliant ports.  We did not use to
6901
	  have <makevar>DESTDIR</makevar> support by our ports infrastructure,
6902
	  and one of the major goals was to avoid modifying a tons of ports,
6903
	  so we just changed <makevar>LOCALBASE</makevar> in the
6904
	  infrastructure instead of changing that in tons of individual ports.
6905
	  With a little workaround, <makevar>LOCALBASE</makevar>,
6906
	  <makevar>LINUXBASE</makevar> and <makevar>X11BASE</makevar>
6907
	  are still overrideable, though.</para>
6843
      </sect1>
6908
      </sect1>
6844
  </chapter>
6909
  </chapter>

Return to bug 101365