README.make 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. The Make System
  2. ~~~ ~~~~ ~~~~~~
  3. To compile this program you require GNU Make. In fact you probably need
  4. GNU Make 3.76.1 or newer. The makefiles contained make use of many
  5. GNU Make specific features and will not run on other makes.
  6. The make system has a number of interesting properties that are not found
  7. in other systems such as automake or the GNU makefile standards. In
  8. general some semblance of expectedness is kept so as not to be too
  9. surprising. Basically the following will work as expected:
  10. ./configure
  11. make
  12. or
  13. cd build
  14. ../configure
  15. make
  16. There are a number of other things that are possible that may make software
  17. development and software packaging simpler. The first of these is the
  18. environment.mak file. When configure is run it creates an environment.mak
  19. file in the build directory. This contains -all- configurable parameters
  20. for all of the make files in all of the subdirectories. Changing one
  21. of these parameters will have an immediate effect. The use of makefile.in
  22. and configure substitutions across build makefiles is not used at all.
  23. Furthermore, the make system runs with a current directory equal to the
  24. source directory regardless of the destination directory. This means
  25. #include "" and #include <> work as expected and more importantly
  26. running 'make' in the source directory will work as expected. The
  27. environment variable or make parameter 'BUILD' sets the build directory.
  28. It may be an absolute path or a path relative to the top level directory.
  29. By default build-arch/ then build/ will be used with a fall back to ./ This
  30. means you can get all the advantages of a build directory without having to
  31. cd into it to edit your source code!
  32. The make system also performs dependency generation on the fly as the
  33. compiler runs. This is extremely fast and accurate. There is however
  34. one failure condition that occurs when a header file is erased. In
  35. this case you should run make clean to purge the .o and .d files to
  36. rebuild.
  37. The final significant deviation from normal make practices is
  38. in how the build directory is managed. It is not nearly a mirror of
  39. the source directory but is logically divided in the following manner
  40. bin/
  41. methods/
  42. doc/
  43. examples/
  44. include/
  45. apt-pkg/
  46. obj/
  47. apt-pkg/
  48. cmdline/
  49. [...]
  50. Only .o and .d files are placed in the obj/ subdirectory. The final compiled
  51. binaries are placed in bin, published headers for inter-component linking
  52. are placed in include/ and documentation is generated into doc/. This means
  53. all runnable programs are within the bin/ directory, a huge benefit for
  54. debugging inter-program relationships. The .so files are also placed in
  55. bin/ for simplicity.
  56. By default make is put into silent mode. During operation there should be
  57. no shell or compiler messages only status messages from the makefiles,
  58. if any pop up that indicates there may be a problem with your environment.
  59. For debugging you can disable this by setting NOISY=1, ala
  60. make NOISY=1
  61. Using the makefiles
  62. ~~~~~ ~~~ ~~~~~~~~~
  63. The makefiles for the components are really simple. The complexity is hidden
  64. within the buildlib/ directory. Each makefile defines a set of make variables
  65. for the bit it is going to make then includes a makefile fragment from
  66. the buildlib/. This fragment generates the necessary rules based on the
  67. originally defined variables. This process can be repeated as many times as
  68. necessary for as many programs or libraries as are in the directory.
  69. Many of the make fragments have some useful properties involving sub
  70. directories and other interesting features. They are more completely
  71. described in the fragment code in buildlib. Some tips on writing fragments
  72. are included in buildlib/defaults.mak
  73. The fragments are NEVER processed by configure, so if you make changes to
  74. them they will have an immediate effect.
  75. Autoconf
  76. ~~~~~~~~
  77. Straight out of CVS you have to initialize autoconf. This requires
  78. automake (I really don't know why) and autoconf and requires doing
  79. aclocal -I buildlib
  80. autoconf
  81. [Alternatively you can run make startup in the top level build dir]
  82. Autoconf is configured to do some basic system probes for optional and
  83. required functionality and generate an environment.mak and include/config.h
  84. from it's findings. It will then write a 'makefile' and run make dirs to
  85. create the output directory tree.
  86. It is not my belief that autoconf should be used to generate substantial
  87. source code markup to escape OS problems. If an OS problem does crop up
  88. it can likely be corrected by installing the correct files into the
  89. build include/ dir and perhaps writing some replacement code and
  90. linking it in. To the fullest extent possible the source code should conform
  91. to standards and not cater to broken systems.
  92. Autoconf will also write a makefile into the top level of the build dir,
  93. this simply acts as a wrapper to the main top level make in the source tree.
  94. There is one big warning, you can't use both this make file and the
  95. ones in the top level tree. Make is not able to resolve rules that
  96. go to the same file through different paths and this will confuse the
  97. depends mechanism. I recommend always using the makefiles in the
  98. source directory and exporting BUILD.