freebsd60-20050708
[openafs.git] / README.DEVEL
1 Notes on Coding Standards/Requirements for OpenAFS Source
2 ---------------------------------------------------------
3
4 Do not use $< in any cross-platform dir as it requires a reasonable
5 make that is not available on all systems.
6
7 Do not have build rules that build multiple targets. Make doesn't seem able
8 to handle this, and it interferes with -j builds. (In particular, build the
9 rxgen targets individually and not using the flags for building all the files
10 in one shot.)
11
12 Try to test builds using gmake -j # MAKE="gmake -j #", it seems like a good
13 way to find missing or order-dependent dependency rules. (Is there a better
14 way to do this?)
15
16 -- Prototyping and Style --
17 Prototypes for all source files in a given dir DDD should be placed
18 int the file DDD/DDD_prototypes.h. All externally used (either API
19 or used by other source files) routines and variables should be
20 prototyped in this file.
21
22 The prototypes should be a full prototype, with argument and return
23 types. (Should not generate a warning with gcc -Wstrict-prototypes.)
24
25 Format of the prototype files should look like:
26
27         Standard Copyright Notice
28
29         #ifndef AFS_SRC_DDD_PROTO_H
30         #define AFS_SRC_DDD_PROTO_H
31         
32         /* filename.c */
33         prototypes
34
35         /* filename.c */
36         prototypes
37
38         #endif /* AFS_SRC_DDD_PROTO_H */
39
40 In most of the existing prototypes, the define is DDD_PROTOTYPES_H, which is
41 probably ok as well.
42
43 The declaration of the routines should be done in ANSI style. If at some
44 later date, it is determined that prototypes don't work on some platform 
45 properly, we can use ansi2knr during the compile.
46
47         rettype routine(argtype arg)
48         {
49
50         }
51
52 All routines should have a return type specified, void if nothing returned,
53 and should have (void) if no arguments are taken.
54
55 Header files should not contain macros or other definitions unless they
56 are used across multiple source files.
57
58 All routines should be declared static if they are not used outside that 
59 source file.
60
61 Compiles on gcc-using machines should strive to handle using
62 -Wstrict-prototypes -Werror. (this may take a while)
63
64 Routines shall be defined in source prior to use if possible, and 
65 prototyped in block at top of file if static.
66
67 If you make a routine or variable static, be sure and remove it from
68 the AIX .exp files.
69
70 Suggested compiler flags:
71         gcc: -Wall -Wstrict-prototypes
72         Solaris Workshop CC: -fd -v
73                 (You might not want the -fd, it isn't really useful, just complains about the
74                 K&R style functions, but -v gives useful info.)