Diff for /wikisrc/pkgsrc/how_to_use_pkg_options_with_pkgsrc.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/20 20:28:27 version 1.2, 2012/02/05 07:14:36
Line 1 Line 1
 Some folks don't realize that NetBSD provides an easy way to configure many packages. To see if a particular package has such options, while in the /usr/pkgsrc/<category>/<pkgname> directory type  Some folks don't realize that NetBSD provides an easy way to configure many packages. To see if a particular package has such options, while in the /usr/pkgsrc/<category>/<pkgname> directory type
   
     make show-options      make show-options
   
   
 As an example, we'll use uim, an input method for Japanese.  As an example, we'll use uim, an input method for Japanese.
   
     cd /usr/pgksrc/inputmethod/uim      cd /usr/pgksrc/inputmethod/uim
     make show-options      make show-options
   
 I see the following  I see the following
 <pre><code>  <pre><code>
 Any of the following general options may be selected:  Any of the following general options may be selected:
        anthy    Use Anthy as Japanese conversion program.         anthy    Use Anthy as Japanese conversion program.
        canna    Use Canna as Japanese conversion program.         canna    Use Canna as Japanese conversion program.
        eb       Enable EB dictionary library support.         eb       Enable EB dictionary library support.
        gtk      Enable support for GTK.         gtk      Enable support for GTK.
        qt         qt
   
 These options are enabled by default: anthy canna gtk  These options are enabled by default: anthy canna gtk
 These options are currently enabled: anthy canna gtk  These options are currently enabled: anthy canna gtk
 </code></pre>  </code></pre>
 If one only wants the default options, then a simple make install clean; make clean-depends will install them. However I don't want the defaults. I do want anthy and gtk however, I don't want canna and wish to add qt.  If one only wants the default options, then a simple make install clean; make clean-depends will install them. However I don't want the defaults. I do want anthy and gtk however, I don't want canna and wish to add qt.
   
 One can either do this at the command line or put the lines in /etc/mk.conf. Usually, the variable will be called PKG_OPTIONS.pkgname where pkgname is, oddly enough, the name of the package. Most packages that have options will have an options.mk file in their directory. A quick glance at that will show you the name of the variable. (If there is no options.mk file, the name of the variable can be found in the Makefile.) In this case the options.mk file has the line  One can either do this at the command line or put the lines in /etc/mk.conf. Usually, the variable will be called PKG_OPTIONS.pkgname where pkgname is, oddly enough, the name of the package. Most packages that have options will have an options.mk file in their directory. A quick glance at that will show you the name of the variable. (If there is no options.mk file, the name of the variable can be found in the Makefile.) In this case the options.mk file has the line
   
     PKG_OPTIONS_VAR=        PKG_OPTIONS.uim      PKG_OPTIONS_VAR=        PKG_OPTIONS.uim
   
 So, I will type  So, I will type
   
     make PKG_OPTIONS.uim="qt -canna" install clean; make clean-depends.      make PKG_OPTIONS.uim="qt -canna" install clean; make clean-depends. 
   
 This will install gtk, qt and anthy.  This will install gtk, qt and anthy.
   
 Most people will put these options in /etc/mk.conf so that they don't have to remember it each time. In this case, it's only a few options, but for something like /usr/pkgsrc/x11/xorg-server there are about 30 options, most of which you won't want. Typing make show-options in x11/xorg-server's directory gives me (shortened for the reader's sake)  Most people will put these options in /etc/mk.conf so that they don't have to remember it each time. In this case, it's only a few options, but for something like /usr/pkgsrc/x11/xorg-server there are about 30 options, most of which you won't want. Typing make show-options in x11/xorg-server's directory gives me (shortened for the reader's sake)
   
 These options are enabled by default: xorg-server-apm xorg-server-ark xorg-server-ati xorg-server-chips xorg-server-cirrus xorg-server-cyrix xorg-server-dummy xorg-server-glint xorg-server-i128 xorg-server-i740 xorg-server-i810 xorg-server-imstt xorg-server-mga xorg-server-neomagic xorg-server-newport xorg-server-nsc xorg-server-nv xorg-server-rendition xorg-server-s3 xorg-server-s3virge xorg-server-savage xorg-server-siliconmotion xorg-server-sis xorg-server-tdfx xorg-server-tga xorg-server-trident xorg-server-tseng xorg-server-vesa xorg-server-vga xorg-server-via xorg-server-vmware  These options are enabled by default: xorg-server-apm xorg-server-ark xorg-server-ati xorg-server-chips xorg-server-cirrus xorg-server-cyrix xorg-server-dummy xorg-server-glint xorg-server-i128 xorg-server-i740 xorg-server-i810 xorg-server-imstt xorg-server-mga xorg-server-neomagic xorg-server-newport xorg-server-nsc xorg-server-nv xorg-server-rendition xorg-server-s3 xorg-server-s3virge xorg-server-savage xorg-server-siliconmotion xorg-server-sis xorg-server-tdfx xorg-server-tga xorg-server-trident xorg-server-tseng xorg-server-vesa xorg-server-vga xorg-server-via xorg-server-vmware
   
 I don't want to type make PKG_OPTIONS="-xorg-server-ati -xorg-server-cardb -xorg-server-cardc" and all the rest each time I reinstall it so I would definitely put it in /etc/mk.conf.  I don't want to type make PKG_OPTIONS="-xorg-server-ati -xorg-server-cardb -xorg-server-cardc" and all the rest each time I reinstall it so I would definitely put it in /etc/mk.conf.
   
 When adding PKG_OPTIONS.pkgname options to etc/mk.conf, don 't put quotes around them. In our example of uim, I would add this line to /etc/mk.conf  When adding PKG_OPTIONS.pkgname options to etc/mk.conf, don 't put quotes around them. In our example of uim, I would add this line to /etc/mk.conf
   
     PKG_OPTIONS.uim=qt -canna      PKG_OPTIONS.uim=qt -canna
   
 If I write  If I write
   
     PKG_OPTIONS.uim="qt -canna"      PKG_OPTIONS.uim="qt -canna" 
   
 in /etc/mk.conf, I will get an error message when I try to build the package. (Or possibly when I try to build any package.)  in /etc/mk.conf, I will get an error message when I try to build the package. (Or possibly when I try to build any package.)
   
 So, to sum up  So, to sum up
   
 If you want default options, don't do anything. If you want available options that aren't enabled by default add them to the PKG_OPTIONS variable, either quoted on the command line, eg PKG_OPTIONS.uim="qt" or in /etc/mk.conf. If you put them in mk.conf don't use quotes.  If you want default options, don't do anything. If you want available options that aren't enabled by default add them to the PKG_OPTIONS variable, either quoted on the command line, eg PKG_OPTIONS.uim="qt" or in /etc/mk.conf. If you put them in mk.conf don't use quotes.
   
 If you don't want an option enabled by default, use a - in front of it, either quoted on the command line or without quotes in /etc/mk.conf   If you don't want an option enabled by default, use a - in front of it, either quoted on the command line or without quotes in /etc/mk.conf 
   

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb