Subject: Naming conventions for variables
To: None <>
From: Roland Illig <>
List: tech-pkg
Date: 10/17/2004 08:55:53
This is a multi-part message in MIME format.
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


I would like to have some naming conventions in written form for pkgsrc, 
so here is my first suggestion to it.


Content-Type: text/x-patch;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

Index: Packages.txt
RCS file: /cvsroot/pkgsrc/Packages.txt,v
retrieving revision 1.362
diff -u -p -r1.362 Packages.txt
--- Packages.txt	16 Oct 2004 00:41:40 -0000	1.362
+++ Packages.txt	17 Oct 2004 06:53:42 -0000
@@ -794,6 +794,38 @@ Please pay attention to the following go
    variable should be the URL for the home page.
  - Please also set the COMMENT variable to a short description of the
    package. The description should start with a capital letter.
+ - Don't use `wip' (work-in-progress) as a package category.  The
+   categories provide an ordering by topic, not by the repository they
+   come from.
+ 4.1.1 Variable names
+ ====================
+Whenever you introduce new variables (in your packages or in the build
+system), please use the following naming conventions to not conflict
+with other work.
+ - Variables that are only used in a package should be all uppercase
+   with a prefix of the package name. Example: for the `unzip' package,
+   all variable names should start with `UNZIP_'.
+ - Variables that are used internally in the build system should start
+   with an underscore.
+ - Multiple inclusion guards for the files in mk/ should be named
+   `_PKG_${filename:C/[^0-9A-Za-z_]/_/g}' (in uppercase).  As all these
+   files end in `.mk', the names of the guards always have the form
+   `_PKG_*_MK`.
+ - Variables that are used as iterators in `for' loops, should be in
+   all lowercase. That way they do not interfere with system defined
+   variables.
+ - Variables that designate a command (like `CC' and `AWK') should
+   be the command name in uppercase. If that is not possible (e.g. the
+   `GZIP' variable is used by gzip for passing command line options),
+   append `_CMD' to the variable name.
+ - Variables that do not designate a command should have at least one
+   underscore to distinguish them from the command variables. Currently
+   there are many exceptions to this rule, and most likely these will
+   stay forever. But if you invent new variables, please use the
+   underscore.
  4.2 distinfo