README.makefiles 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. PURPOSE : To explain the makefile system in firebird2.
  2. STATUS: Still a work in progress (both the makefiles, and this document)
  3. AUTHORS: Mark O'Donohue [email protected]
  4. COPYRIGHT: All rights retained by authors.
  5. For distribution with Firebird source
  6. (Someone who knows this legal stuff will update it later)
  7. OVERVIEW
  8. The new makefiles were created to fit in with autoconf, to place the object
  9. files in seperate directories to the source files and to simplify the build
  10. process.
  11. It really does rely on using gnu make so that is the best version to use.
  12. THE REALLY QUICK INTRO
  13. For linux this is how I do a compile (classic is only one currently)
  14. autoconf
  15. ./configure
  16. $cd src
  17. $make > make.log 2>&1 ; cat make.log | grep -v warning > make2.log ; vi make2.log
  18. For an install checkout
  19. $make install
  20. it will list your options - but also needs some work.
  21. MAKEFILE
  22. Makefiles are found in builds/posix
  23. make.rules
  24. make.defaults
  25. make.shared.variables
  26. prefix.xxx (where xxx = platform)
  27. In src/make.new there are a number of Makefile.in.xxx files and some make.xxx
  28. STRUCTURE OF MAKEFILE.IN.XXX
  29. Each Makefile.in.xxx has the following somewhere near the top:
  30. include make.defaults
  31. include make.platform
  32. include make.rules
  33. include make.shared.variables
  34. ...
  35. ...
  36. These are:
  37. make.defaults
  38. This contains default values for macros that it is likely that the user may
  39. want to override.
  40. make.platform
  41. This file is created from the prefix.xxx where xxx=linux/darwin/freebsd etc.
  42. It provides a spot for the user to override or repalce macros that have been
  43. defined in make.defaults. In addition extra dependancies can be added to
  44. build extra targets.
  45. make.rules
  46. This contains the default rules for compiling the system components. Such as
  47. directory macros CXX etc.
  48. make.shared.variables
  49. This file contains the defintion of macros that are shared across all of the
  50. modules. The only set that are needed are those files that are contained in
  51. the libgds.a/so library since files from many modules contribute to the library.
  52. CREATING OBJECT FILES
  53. In the makefiles the object files are of two sorts .o static and .lo
  54. which are suitable for shared libraries. On most systems the source
  55. files need to be compiled twice to create both .o and .lo files. F
  56. Fortunately the program libtool can help work with this.
  57. The general format of .o file dependancies is:
  58. SERVER_Sources = server.cpp
  59. SERVER_Objects = $(SERVER_Sources:%.cpp=$(OBJ)/%.o)
  60. So the .o files live in $(OBJ) where:
  61. OBJ = $(ROOT)/gen/$ModuleName
  62. Each Makefile also specifies an AllObjects and Dependancies macro which
  63. identified all the objects that this Makefile is to create and the name
  64. of the dependency files generated for those objects.
  65. AllObjects = $(Alice_Objects)
  66. FILE DEPENDANCIES
  67. Include file dependancy information is automatically generated by the gcc
  68. compiler.
  69. The gcc compiler has a flag -MMD which will generate in addition to the
  70. .o file a .d file which contains the dependancy chain of #includes required
  71. for the program. These are then edited and stored in the $(OBJ) directory and
  72. are included in the bottom line of the makefile with
  73. Dependencies = $(All_Objects:.o=.d)
  74. include $(Dependancies)
  75. PLATFORM SUBDIRS OF JRD
  76. Please, forget about jrd/os/* in makefiles! Pretend that all files from
  77. there are placed in jrd/ itself. A little trick in make.rules will find
  78. files for your platform automatically.