home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Extensions / example3 / Makefile.pre.in next >
Encoding:
Makefile  |  1994-10-11  |  6.0 KB  |  199 lines  |  [TEXT/R*ch]

  1. # Universal Makefile to build Python extensions.
  2. #
  3. # Instructions:
  4. #
  5. # 0) Build and install the basic Python 1.0.2 distribution.  You must
  6. # also install the headers ("make inclinstall") and the binary library
  7. # files ("make libainstall").
  8. #
  9. # 1) Edit Makefile.pre.in (not any other file!!!) to change the
  10. # definition of installdir (and possibly exec_installdir).  These
  11. # should match the prefix and exec_prefix used when installing Python.
  12. # Alternatively, you can specify a value for installdir on the
  13. # "make -f Makefile.pre.in Makefile" command line (see below).  This
  14. # is probably easier since it avoids editing Makefile.pre.in at all...
  15. #
  16. # 2) Copy Setup.in to Setup and edit Setup to change the selection of
  17. # modules you want to use.  Read the comments in the core Python's
  18. # Modules/Setup.in for more detailed instructions.
  19. #
  20. # 3) Run "make Makefile -f Makefile.pre.in".  This creates Makefile
  21. # (producing Makefile.pre and sedscript as intermediate files) and
  22. # config.c.  Values for installdir, srcdir, VPATH, LINKPATH, OPT,
  23. # BASELIB and BASESETUP on the make command line will be incorporated
  24. # in the final Makefile.
  25. #
  26. # 4) Run "make".  This creates a Python executable.  The set of
  27. # built-in modules and features is a superset of that of the basic
  28. # Python -- additions are taken from ./Setup.
  29. #
  30. # If you don't actually want to install the Python headers and
  31. # binary library files, you can edit the "Fixed definitions" section
  32. # below to point directly into the source and/or build tree.
  33. #
  34. # Note: Each time you edit Makefile.pre.in or Setup, you must run
  35. # "make Makefile" before running "make".
  36. #
  37. # Hint: if you want to use VPATH, you can start in an empty
  38. # subdirectory and say (e.g.):
  39. # make -f ../Makefile.pre.in srcdir=.. VPATH=.. Makefile
  40.  
  41.  
  42. # === Variables that you just *have* to customize manually ===
  43.  
  44. # (You can also specify their values on the command line for
  45. # "make -f Makefile.pre.in Makefile".)
  46.  
  47. # The prefix used by "make inclinstall libainstall" of core python
  48. installdir=    /usr/local
  49.  
  50. # The exec_prefix used by the same
  51. exec_installdir=$(installdir)
  52.  
  53. # Source directory and VPATH in case you want to use VPATH.
  54. # (You will have to edit these two lines yourself -- there is no
  55. # automatic support as the Makefile is not generated by
  56. # config.status.)
  57. srcdir=        .
  58. VPATH=        .
  59.  
  60. # === Variables that you may want to customize ===
  61.  
  62. # Add possible -L options here
  63. LINKPATH=    
  64.  
  65. # You may want to change this to -O
  66. OPT=        -g
  67.  
  68. # Add more -I and -D options here
  69. CFLAGS=        $(OPT) -I$(INCLUDEPY) -I$(LIBPL) $(DEFS)
  70.  
  71. # These two variables can be set in Setup to merge extensions.
  72. # See example[23].
  73. BASELIB=    
  74. BASESETUP=    
  75.  
  76. # === Variables set by makesetup ===
  77.  
  78. MODOBJS=    @MODOBJS@
  79. MODLIBS=    @MODLIBS@
  80.  
  81. # === Definitions added by makesetup ===
  82.  
  83. # === Variables from configure (through sedscript) ===
  84.  
  85. CC=        @CC@
  86. DEFS=        @DEFS@
  87. LIBS=        @LIBS@
  88. LIBM=        @LIBM@
  89. LIBC=        @LIBC@
  90. RANLIB=        @RANLIB@
  91. MACHDEP=    @MACHDEP@
  92. SO=        @SO@
  93. LDSHARED=    @LDSHARED@
  94. CCSHARED=    @CCSHARED@
  95. LINKFORSHARED=    @LINKFORSHARED@
  96.  
  97. # Install prefix for architecture-independent files
  98. prefix=        /usr/local
  99.  
  100. # Install prefix for architecture-dependent files
  101. exec_prefix=    $(prefix)
  102.  
  103. # === Fixed definitions ===
  104.  
  105. INCLUDEPY=    $(installdir)/include/Py
  106. LIBP=        $(exec_installdir)/lib/python
  107. LIBPL=        $(LIBP)/lib
  108.  
  109. PYTHONLIBS=    $(LIBPL)/libModules.a \
  110.         $(LIBPL)/libPython.a \
  111.         $(LIBPL)/libObjects.a \
  112.         $(LIBPL)/libParser.a
  113.  
  114. MAKESETUP=    $(LIBPL)/makesetup
  115. MAKEFILE=    $(LIBPL)/Makefile
  116. CONFIGC=    $(LIBPL)/config.c
  117. CONFIGCIN=    $(LIBPL)/config.c.in
  118. SETUP=        $(LIBPL)/Setup
  119.  
  120. SYSLIBS=    $(LIBM) $(LIBC)
  121.  
  122. # === Fixed rules ===
  123.  
  124. all:        python
  125.  
  126. sharedmods:    $(SHAREDMODS)
  127.  
  128. python:        config.o lib.a $(PYTHONLIBS) Makefile
  129.         $(CC) config.o lib.a $(PYTHONLIBS) \
  130.          $(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python
  131.  
  132. lib.a:        $(MODOBJS)
  133.         -rm -f lib.a
  134.         ar cr lib.a $(MODOBJS)
  135.         -$(RANLIB) lib.a || \
  136.         echo "don't worry if ranlib fails -- probably SYSV or equiv"
  137.  
  138. # This runs makesetup *twice* to use the BASESETUP definition from Setup
  139. config.c Makefile:    Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
  140.         $(MAKESETUP) \
  141.          -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
  142.         $(MAKE) -f Makefile do-it-again
  143.  
  144. do-it-again:
  145.         $(MAKESETUP) \
  146.          -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
  147.  
  148. config.o:    config.c Makefile
  149.         $(CC) $(CFLAGS) -DPYTHONPATH=\"$(PYTHONPATH)\" -c config.c
  150.  
  151. # Setup is copied from Setup.in *only* if it doesn't yet exist
  152. Setup:
  153.         cp $(srcdir)/Setup.in Setup
  154.  
  155. Makefile.pre: Makefile.pre.in sedscript
  156.         sed -f sedscript $(srcdir)/Makefile.pre.in >Makefile.pre
  157.  
  158. # Shortcuts to make the sed arguments on one line
  159. P=prefix
  160. E=exec_prefix
  161. H=Generated automatically from Makefile.pre.in by sedscript.
  162. sedscript:    $(MAKEFILE)
  163.         sed -n \
  164.           -e '1s/.*/1i\\/p' \
  165.           -e '2s%.*%# $H%p' \
  166.           -e '/^CC=/s/^CC=[     ]*\(.*\)/s%@CC[@]%\1%/p' \
  167.           -e '/^DEFS=/s/^DEFS=[     ]*\(.*\)/s%@DEFS[@]%\1%/p' \
  168.           -e '/^LIBS=/s/^LIBS=[     ]*\(.*\)/s%@LIBS[@]%\1%/p' \
  169.           -e '/^LIBM=/s/^LIBM=[     ]*\(.*\)/s%@LIBM[@]%\1%/p' \
  170.           -e '/^LIBC=/s/^LIBC=[     ]*\(.*\)/s%@LIBC[@]%\1%/p' \
  171.           -e '/^RANLIB=/s/^RANLIB=[     ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
  172.           -e '/^MACHDEP=/s/^MACHDEP=[     ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
  173.           -e '/^SO=/s/^SO=[     ]*\(.*\)/s%@SO[@]%\1%/p' \
  174.           -e '/^LDSHARED=/s/^LDSHARED=[     ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
  175.           -e '/^CCSHARED=/s/^CCSHARED=[     ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
  176.           -e '/^LINKFORSHARED=/s/^LINKFORSHARED=[     ]*\(.*\)/s%@LINKFORSHARED[@]%\1%/p' \
  177.           -e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
  178.           -e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
  179.           $(MAKEFILE) >sedscript
  180.         ( \
  181.           echo "/^installdir=/s%=.*%=    $(installdir)%"; \
  182.           echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%"; \
  183.           echo "/^srcdir=/s%=.*%=        $(srcdir)%"; \
  184.           echo "/^VPATH=/s%=.*%=        $(VPATH)%"; \
  185.           echo "/^LINKPATH=/s%=.*%=    $(LINKPATH)%"; \
  186.           echo "/^OPT=/s%=.*%=        $(OPT)%"; \
  187.           echo "/^BASELIB=/s%=.*%=    $(BASELIB)%"; \
  188.           echo "/^BASESETUP=/s%=.*%=    $(BASESETUP)%"; \
  189.         ) >>sedscript
  190.  
  191. clean:
  192.         -rm -f *.o *~
  193.  
  194. clobber:    clean
  195.         -rm -f python lib.a sedscript config.c Makefile.pre
  196.  
  197. distclean:    clobber
  198.         -rm -f Makefile Setup
  199.