FreeBSD Porter's Handbook

The FreeBSD Documentation Project FreeBSD Porter's Handbook by Revision: 50842 2017-09-15 02:20:06 by marius. Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 The FreeBSD Documentation Project

Copyright

Redistribution and use in source (XML DocBook) and 'compiled' forms (XML, HTML, PDF, PostScript, RTF and so forth) with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code (XML DocBook) must retain the above copyright notice, this list of conditions and the following dis- claimer as the rst lines of this le unmodified.

2. Redistributions in compiled form (transformed to other DTDs, converted to PDF, PostScript, RTF and other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Important

THIS DOCUMENTATION IS PROVIDED BY THE FREEBSD DOCUMENTATION PROJECT "AS IS" AND ANY EX- PRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREE- BSD DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FreeBSD is a registered trademark of the FreeBSD Foundation.

UNIX is a registered trademark of The Open Group in the United States and other countries.

Sun, Sun Microsystems, Java, Java Virtual Machine, JDK, JRE, JSP, JVM, Netra, OpenJDK, Solaris, StarOffice, SunOS and VirtualBox are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this document, and the FreeBSD Project was aware of the trademark claim, the designations have been followed by the “™” or the “®” symbol.

ii Table of Contents

1. Introduction ...... 1 2. Making a New Port ...... 3 3. Quick Porting ...... 5 3.1. Writing the Makefile ...... 5 3.2. Writing the Description Files ...... 6 3.3. Creating the Checksum File ...... 7 3.4. Testing the Port ...... 8 3.5. Checking the Port with portlint ...... 8 3.6. Submitting the New Port ...... 8 4. Slow Porting ...... 11 4.1. How Things Work ...... 11 4.2. Getting the Original Sources ...... 12 4.3. Modifying the Port ...... 12 4.4. Patching ...... 13 4.5. Configuring ...... 15 4.6. Handling User Input ...... 15 5. Configuring the Makefile ...... 17 5.1. The Original Source ...... 17 5.2. Naming ...... 17 5.3. Categorization ...... 25 5.4. The Distribution Files ...... 30 5.5. MAINTAINER ...... 48 5.6. COMMENT ...... 49 5.7. Licenses ...... 49 5.8. PORTSCOUT ...... 57 5.9. Dependencies ...... 58 5.10. Slave Ports and MASTERDIR ...... 63 5.11. Man Pages ...... 64 5.12. Info Files ...... 64 5.13. Makefile Options ...... 64 5.14. Specifying the Working Directory ...... 79 5.15. Conflict Handling ...... 79 5.16. Installing Files ...... 80 6. Special Considerations ...... 85 6.1. Staging ...... 85 6.2. Bundled Libraries ...... 86 6.3. Shared Libraries ...... 87 6.4. Ports with Distribution Restrictions or Legal Concerns ...... 88 6.5. Building Mechanisms ...... 89 6.6. Using GNU Autotools ...... 92 6.7. Using GNU gettext ...... 93 6.8. Using Perl ...... 94 6.9. Using X11 ...... 95 6.10. Using GNOME ...... 97 6.11. GNOME Components ...... 99 6.12. Using ...... 103 6.13. Using KDE ...... 106 6.14. Using LXQt ...... 107 6.15. Using Java ...... 107 6.16. Web Applications, Apache and PHP ...... 110 6.17. Using Python ...... 112 6.18. Using Tcl/Tk ...... 114 6.19. Using Emacs ...... 114 6.20. Using Ruby ...... 114 6.21. Using SDL ...... 115 6.22. Using wxWidgets ...... 116 Table of Contents

6.23. Using Lua ...... 121 6.24. Using iconv ...... 122 6.25. Using Xfce ...... 123 6.26. Using Mozilla ...... 124 6.27. Using Databases ...... 125 6.28. Starting and Stopping Services (rc Scripts) ...... 125 6.29. Adding Users and Groups ...... 127 6.30. Ports That Rely on Kernel Sources ...... 128 7. Advanced pkg-plist Practices ...... 129 7.1. Changing pkg-plist Based on Variables ...... 129 7.2. Empty Directories ...... 130 7.3. Configuration Files ...... 130 7.4. Dynamic Versus Static Package List ...... 131 7.5. Automated Package List Creation ...... 131 7.6. Expanding Package List with Keywords ...... 132 8. pkg-* ...... 139 8.1. pkg-message ...... 139 8.2. pkg-install ...... 139 8.3. pkg-deinstall ...... 139 8.4. Changing the Names of pkg-* ...... 139 8.5. Making Use of SUB_FILES and SUB_LIST ...... 140 9. Testing the Port ...... 141 9.1. Running make describe ...... 141 9.2. Portlint ...... 141 9.3. Port Tools ...... 141 9.4. PREFIX and DESTDIR ...... 141 9.5. Poudriere ...... 142 9.6. Tinderbox ...... 149 10. Upgrading a Port ...... 151 10.1. Using Subversion to Make Patches ...... 152 10.2. UPDATING and MOVED ...... 153 11. Security ...... 155 11.1. Why Security is So Important ...... 155 11.2. Fixing Security Vulnerabilities ...... 155 11.3. Keeping the Community Informed ...... 155 12. Dos and Don'ts ...... 161 12.1. Introduction ...... 161 12.2. WRKDIR ...... 161 12.3. WRKDIRPREFIX ...... 161 12.4. Differentiating Operating Systems and OS Versions ...... 161 12.5. Writing Something After bsd.port.mk ...... 161 12.6. Use the exec Statement in Wrapper Scripts ...... 162 12.7. Do Things Rationally ...... 163 12.8. Respect Both CC and CXX ...... 163 12.9. Respect CFLAGS ...... 163 12.10. Verbose Build Logs ...... 164 12.11. Feedback ...... 164 12.12. README.html ...... 164 12.13. Marking a Port as Architecture Neutral ...... 164 12.14. Marking a Port Not Installable with BROKEN, FORBIDDEN, or IGNORE ...... 164 12.15. Marking a Port for Removal with DEPRECATED or EXPIRATION_DATE ...... 166 12.16. Avoid Use of the .error Construct ...... 166 12.17. Usage of sysctl ...... 167 12.18. Rerolling Distfiles ...... 167 12.19. Use POSIX Standards ...... 167 12.20. Miscellanea ...... 168 13. A Sample Makefile ...... 169 14. Order of Variables in Port Makefiles ...... 171 iv Table of Contents

14.1. PORTNAME Block ...... 171 14.2. PATCHFILES Block ...... 172 14.3. MAINTAINER Block ...... 172 14.4. LICENSE Block ...... 172 14.5. Generic BROKEN/IGNORE/DEPRECATED Messages ...... 173 14.6. The Dependencies Block ...... 173 14.7. USES and USE_x ...... 174 14.8. Standard bsd.port.mk Variables ...... 174 14.9. Options and Helpers ...... 174 14.10. The Rest of the Variables ...... 174 14.11. The Targets ...... 175 15. Keeping Up ...... 177 15.1. FreshPorts ...... 177 15.2. The Web Interface to the Source Repository ...... 177 15.3. The FreeBSD Ports Mailing List ...... 177 15.4. The FreeBSD Port Building Cluster ...... 177 15.5. Portscout: the FreeBSD Ports Distfile Scanner ...... 177 15.6. The FreeBSD Ports Monitoring System ...... 178 16. Using USES Macros ...... 179 16.1. An Introduction to USES ...... 179 16.2. 7z ...... 179 16.3. ada ...... 179 16.4. autoreconf ...... 180 16.5. blaslapack ...... 180 16.6. bdb ...... 180 16.7. bison ...... 181 16.8. charsetfix ...... 181 16.9. ...... 181 16.10. compiler ...... 181 16.11. cpe ...... 181 16.12. cran ...... 182 16.13. desktop-file-utils ...... 182 16.14. desthack ...... 182 16.15. display ...... 182 16.16. dos2unix ...... 182 16.17. drupal ...... 183 16.18. execinfo ...... 183 16.19. fakeroot ...... 183 16.20. fam ...... 183 16.21. firebird ...... 183 16.22. fmake ...... 183 16.23. fonts ...... 184 16.24. fortran ...... 184 16.25. fuse ...... 184 16.26. gecko ...... 184 16.27. gem ...... 184 16.28. gettext ...... 184 16.29. gettext-runtime ...... 184 16.30. gettext-tools ...... 185 16.31. ghostscript ...... 185 16.32. gmake ...... 185 16.33. gnome ...... 185 16.34. go ...... 188 16.35. gperf ...... 188 16.36. grantlee ...... 188 16.37. groff ...... 188 16.38. gssapi ...... 188 16.39. horde ...... 189

v Table of Contents

16.40. iconv ...... 189 16.41. imake ...... 190 16.42. ...... 190 16.43. kmod ...... 190 16.44. lha ...... 190 16.45. libarchive ...... 190 16.46. libedit ...... 191 16.47. libtool ...... 191 16.48. ...... 191 16.49. localbase ...... 193 16.50. lua ...... 193 16.51. ...... 194 16.52. makeinfo ...... 194 16.53. makeself ...... 194 16.54. mate ...... 194 16.55. ...... 195 16.56. metaport ...... 195 16.57. mysql ...... 195 16.58. mono ...... 195 16.59. motif ...... 195 16.60. ncurses ...... 196 16.61. ninja ...... 196 16.62. objc ...... 196 16.63. openal ...... 196 16.64. pathfix ...... 196 16.65. pear ...... 196 16.66. perl5 ...... 196 16.67. pgsql ...... 197 16.68. php ...... 197 16.69. pkgconfig ...... 198 16.70. pure ...... 198 16.71. ...... 198 16.72. python ...... 200 16.73. qmail ...... 200 16.74. qmake ...... 200 16.75. readline ...... 200 16.76. samba ...... 200 16.77. scons ...... 201 16.78. shared-mime-info ...... 201 16.79. shebangfix ...... 201 16.80. sqlite ...... 203 16.81. ssl ...... 203 16.82. tar ...... 204 16.83. tcl ...... 204 16.84. terminfo ...... 204 16.85. tk ...... 204 16.86. twisted ...... 205 16.87. uidfix ...... 205 16.88. uniquefiles ...... 205 16.89. varnish ...... 205 16.90. webplugin ...... 205 16.91. xfce ...... 206 16.92. zip ...... 206 16.93. zope ...... 206 17. __FreeBSD_version Values ...... 207 17.1. FreeBSD 12 Versions ...... 207 17.2. FreeBSD 11 Versions ...... 210 17.3. FreeBSD 10 Versions ...... 220 vi Table of Contents

17.4. FreeBSD 9 Versions ...... 230 17.5. FreeBSD 8 Versions ...... 236 17.6. FreeBSD 7 Versions ...... 248 17.7. FreeBSD 6 Versions ...... 254 17.8. FreeBSD 5 Versions ...... 259 17.9. FreeBSD 4 Versions ...... 267 17.10. FreeBSD 3 Versions ...... 271 17.11. FreeBSD 2.2 Versions ...... 271 17.12. FreeBSD 2 Before 2.2-RELEASE Versions ...... 272

vii

List of Tables

5.1. Examples of DISTVERSION and the Derived PORTVERSION ...... 18 5.2. Package Naming Examples ...... 24 5.3. Shortcuts for MASTER_SITE_ * Macros ...... 33 5.4. Magic MASTER_SITES Macros ...... 34 5.5. USE_GITHUB Description ...... 35 5.6. Predefined License List ...... 50 5.7. USE_* ...... 61 6.1. Variables for Ports That Use configure ...... 90 6.2. Variables for Ports That Use cmake ...... 90 6.3. Variables the Users Can Define for cmake Builds ...... 91 6.4. Variables for Ports That Use scons ...... 91 6.5. Read-Only Variables for Ports That Use Perl ...... 94 6.6. Variables for Ports That Use X ...... 96 6.7. GNOME Components ...... 99 6.8. GNOME Macro Components ...... 101 6.9. GNOME Legacy Components ...... 101 6.10. Deprecated Components: Do Not Use ...... 103 6.11. Variables Provided to Ports That Use Qt ...... 103 6.12. Available Qt Library Components ...... 104 6.13. Available Qt Tool Components ...... 104 6.14. Available Qt Plugin Components ...... 104 6.15. Variables for Ports That Use qmake ...... 105 6.16. Available KDE 4 Components ...... 106 6.17. Available LXQt Components ...... 107 6.18. Variables Which May be Set by Ports That Use Java ...... 108 6.19. Variables Provided to Ports That Use Java ...... 108 6.20. Constants Defined for Ports That Use Java ...... 109 6.21. Variables for Ports That Use Apache ...... 110 6.22. Useful Variables for Porting Apache Modules ...... 111 6.23. Most Useful Variables for Ports That Use Python ...... 113 6.24. The Most Useful Read-Only Variables for Ports That Use Tcl/Tk ...... 114 6.25. Useful Variables for Ports That Use Ruby ...... 114 6.26. Selected Read-Only Variables for Ports That Use Ruby ...... 115 6.27. Variables to Select wxWidgets Versions ...... 117 6.28. Available wxWidgets Versions ...... 117 6.29. wxWidgets Version Specifications ...... 117 6.30. Variables to Select Preferred wxWidgets Versions ...... 117 6.31. Available wxWidgets Components ...... 117 6.32. Available wxWidgets Dependency Types ...... 118 6.33. Default wxWidgets Dependency Types ...... 118 6.34. Variables to Select Unicode in wxWidgets Versions ...... 118 6.35. Variables Defined for Ports That Use wxWidgets ...... 119 6.36. Legal Values for WX_CONF_ARGS ...... 120 6.37. Variables Defined for Ports That Use Lua ...... 121 6.38. Variables for Ports That Use Mozilla ...... 124 6.39. Variables for Ports Using Databases ...... 125 10.1. Subversion Update File Prefixes ...... 153 17.1. FreeBSD 12 __FreeBSD_version Values ...... 207 17.2. FreeBSD 11 __FreeBSD_version Values ...... 210 17.3. FreeBSD 10 __FreeBSD_version Values ...... 220 17.4. FreeBSD 9 __FreeBSD_version Values ...... 230 17.5. FreeBSD 8 __FreeBSD_version Values ...... 236 17.6. FreeBSD 7 __FreeBSD_version Values ...... 248 17.7. FreeBSD 6 __FreeBSD_version Values ...... 254 17.8. FreeBSD 5 __FreeBSD_version Values ...... 259 17.9. FreeBSD 4 __FreeBSD_version Values ...... 267 List of Tables

17.10. FreeBSD 3 __FreeBSD_version Values ...... 271 17.11. FreeBSD 2.2 __FreeBSD_version Values ...... 271 17.12. FreeBSD 2 Before 2.2-RELEASE __FreeBSD_version Values ...... 272

x