home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Languages / python / PyObjC-0.47-MIHS / pyobjc-0.47-src / Misc / Makefile.pre.in < prev    next >
Encoding:
Makefile  |  1996-11-13  |  9.4 KB  |  292 lines

  1. # Universal Unix Makefile for Python extensions
  2. # =============================================
  3.  
  4. # Lele Gaifax on 2 Oct 1996: slightly edited to fit PyObjC needs.
  5. #  - Uses makesetup in the Modules/ directory, since it supports ObjC.
  6. #  - Creates Setup from Modules/Setup.PyObjC.in
  7. #  - Adapted instructions.
  8. #  - Added -I$(srcdir)/Include to CFLAGS.
  9. # On 26 Oct 1996:
  10. #  - Added $(LINKFORSHARED) to the link command.
  11.  
  12. # Short Instructions
  13. # ------------------
  14.  
  15. # 1. Build and install Python (1.4 or newer).
  16. # 2. "make -f Makefile.pre.in boot"
  17. # 3. "make"
  18. # You should now have a shared library.
  19.  
  20. # Long Instructions
  21. # -----------------
  22.  
  23. # Build *and install* the basic Python 1.4 distribution.  See the
  24. # Python README for instructions.
  25.  
  26. # Create a file Setup.in for your extension.  This file follows the
  27. # format of the Modules/Setup.in file; see the instructions there.
  28. # For a simple module called "spam" on file "spammodule.c", it can
  29. # contain a single line:
  30. #   spam spammodule.c
  31. # You can build as many modules as you want in the same directory --
  32. # just have a separate line for each of them in the Setup.in file.
  33.  
  34. # If you want to build your extension as a shared library, insert a
  35. # line containing just the string
  36. #   *shared*
  37. # at the top of Modules/Setup.PyObjC.in file.
  38.  
  39. # Note that the build process copies Modules/Setup.PyObjC.in to Setup,
  40. # and then works with Setup.  It doesn't overwrite Setup when
  41. # Modules/Setup.PyObjC.in is changed, so while you're in the process of
  42. # debugging your Modules/Setup.PyObjC.in file, you may want to edit
  43. # Setup instead, and copy it back to Modules/Setup.PyObjC.in later.
  44. # (All this is done so you can distribute your extension easily and
  45. # someone else can select the modules they actually want to build by
  46. # commenting out lines in the Setup file, without editing the
  47. # original.  Editing Setup is also used to specify nonstandard
  48. # locations for include or library files.)
  49.  
  50. # Copy this file (Misc/Makefile.pre.in) to the directory containing
  51. # your extension.
  52.  
  53. # Run "make -f Makefile.pre.in boot".  This creates Makefile
  54. # (producing Makefile.pre and sedscript as intermediate files) and
  55. # config.c, incorporating the values for sys.prefix, sys.exec_prefix
  56. # and sys.version from the installed Python binary.  For this to work,
  57. # the python binary must be on your path.  If this fails, try
  58. #   make -f Makefile.pre.in Makefile VERSION=1.4 installdir=<prefix>
  59. # where <prefix> is the prefix used to install Python for installdir
  60. # (and possibly similar for exec_installdir=<exec_prefix>).
  61.  
  62. # If you are building your extension as a shared library (your
  63. # Modules/Setup.PyObjC.in file starts with *shared*), run "make" or
  64. # "make sharedmods" to build the shared library files.  If you are
  65. # building a statically linked Python binary (the only solution of your
  66. # platform doesn't support shared libraries, and sometimes handy if you
  67. # want to distribute or install the resulting Python binary), run "make
  68. # python".
  69.  
  70. # Note: Each time you edit Makefile.pre.in or Setup, you must run
  71. # "make Makefile" before running "make".
  72.  
  73. # Hint: if you want to use VPATH, you can start in an empty
  74. # subdirectory and say (e.g.):
  75. #   make -f ../Makefile.pre.in boot srcdir=.. VPATH=..
  76.  
  77.  
  78. # === Bootstrap variables (edited through "make boot") ===
  79.  
  80. # The prefix used by "make inclinstall libainstall" of core python
  81. installdir=    /usr/local
  82.  
  83. # The exec_prefix used by the same
  84. exec_installdir=$(installdir)
  85.  
  86. # Source directory and VPATH in case you want to use VPATH.
  87. # (You will have to edit these two lines yourself -- there is no
  88. # automatic support as the Makefile is not generated by
  89. # config.status.)
  90. srcdir=        .
  91. VPATH=        .
  92.  
  93. # === Variables that you may want to customize (rarely) ===
  94.  
  95. MODULE=        PyObjC
  96.  
  97. # (Static) build target
  98. TARGET=        pyobjc
  99.  
  100. # Add more -I and -D options here
  101. CFLAGS=        $(OPT) -I$(srcdir)/Include -I$(INCLUDEPY) -I$(LIBPL) $(DEFS)
  102.  
  103. # These two variables can be set in Setup to merge extensions.
  104. # See example[23].
  105. BASELIB=    
  106. BASESETUP=    
  107.  
  108. # === Variables set by makesetup ===
  109.  
  110. MODOBJS=    _MODOBJS_
  111. MODLIBS=    _MODLIBS_
  112.  
  113. # === Definitions added by makesetup ===
  114.  
  115. # === Variables from configure (through sedscript) ===
  116.  
  117. VERSION=    @VERSION@
  118. CC=        @CC@
  119. OPT=        @OPT@
  120. LDFLAGS=    @LDFLAGS@
  121. DEFS=        @DEFS@
  122. LIBS=        @LIBS@
  123. LIBM=        @LIBM@
  124. LIBC=        @LIBC@
  125. RANLIB=        @RANLIB@
  126. MACHDEP=    @MACHDEP@
  127. SO=        @SO@
  128. LDSHARED=    @LDSHARED@
  129. CCSHARED=    @CCSHARED@
  130. LINKFORSHARED=    @LINKFORSHARED@
  131.  
  132. # Install prefix for architecture-independent files
  133. prefix=        /usr/local
  134.  
  135. # Install prefix for architecture-dependent files
  136. exec_prefix=    $(prefix)
  137.  
  138. # === Fixed definitions ===
  139.  
  140. # Shell used by make (some versions default to the login shell, which is bad)
  141. SHELL=        /bin/sh
  142.  
  143. # Expanded directories
  144. BINDIR=        $(exec_installdir)/bin
  145. LIBDIR=        $(exec_prefix)/lib
  146. MANDIR=        $(installdir)/man
  147. INCLUDEDIR=    $(installdir)/include
  148. SCRIPTDIR=    $(prefix)/lib
  149.  
  150. # Detailed destination directories
  151. BINLIBDEST=    $(LIBDIR)/python$(VERSION)
  152. LIBDEST=    $(SCRIPTDIR)/python$(VERSION)
  153. INCLUDEPY=    $(INCLUDEDIR)/python$(VERSION)
  154. LIBP=        $(exec_installdir)/lib/python$(VERSION)
  155.  
  156. LIBPL=        $(LIBP)/config
  157.  
  158. PYTHONLIBS=    $(LIBPL)/libModules.a \
  159.         $(LIBPL)/libPython.a \
  160.         $(LIBPL)/libObjects.a \
  161.         $(LIBPL)/libParser.a
  162.  
  163. MAKESETUP=    Modules/makesetup
  164. MAKEFILE=    $(LIBPL)/Makefile
  165. CONFIGC=    $(LIBPL)/config.c
  166. CONFIGCIN=    $(LIBPL)/config.c.in
  167. SETUP=        $(LIBPL)/Setup
  168.  
  169. SYSLIBS=    $(LIBM) $(LIBC)
  170.  
  171. ADDOBJS=    $(LIBPL)/main.o getpath.o config.o
  172.  
  173. # === Fixed rules ===
  174.  
  175. # Default target.  This builds shared libraries only
  176. default:    sharedmods
  177.  
  178. # Build everything
  179. all:        static sharedmods
  180.  
  181. # Build shared libraries from our extension modules
  182. sharedmods:    $(SHAREDMODS)
  183.  
  184. # Build a static Python binary containing our extension modules
  185. static:        $(TARGET)
  186. $(TARGET):    $(ADDOBJS) lib$(MODULE).a $(PYTHONLIBS) Makefile $(BASELIB)
  187.         $(CC) $(LDFLAGS) $(ADDOBJS) lib$(MODULE).a $(PYTHONLIBS) \
  188.          $(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \
  189.          $(LINKFORSHARED) -o $(TARGET)
  190.  
  191. # Build the library containing our extension modules
  192. lib$(MODULE).a:        $(MODOBJS)
  193.         -rm -f lib$(MODULE).a
  194.         ar cr lib$(MODULE).a $(MODOBJS)
  195.         -$(RANLIB) lib$(MODULE).a || \
  196.         echo "don't worry if ranlib fails -- probably SYSV or equiv"
  197.  
  198. # This runs makesetup *twice* to use the BASESETUP definition from Setup
  199. config.c Makefile:    Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
  200.         $(MAKESETUP) \
  201.          -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
  202.         $(MAKE) -f Makefile do-it-again
  203.  
  204. # Internal target to run makesetup for the second time
  205. do-it-again:
  206.         $(MAKESETUP) \
  207.          -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
  208.  
  209. # Make config.o from the config.c created by makesetup
  210. config.o:    config.c
  211.         $(CC) $(CFLAGS) -c config.c
  212.  
  213. # Make our own private getpath.o from the installed source and our PYTHONPATH
  214. getpath.o:    $(LIBPL)/getpath.c Makefile
  215.     $(CC) $(CFLAGS) -DPYTHONPATH=\"$(PYTHONPATH)\" -c $(LIBPL)/getpath.c
  216.  
  217. # Setup is copied from Setup.in *only* if it doesn't yet exist
  218. Setup:
  219.         cp $(srcdir)/Modules/Setup.PyObjC.in Setup
  220.  
  221. # Make the intermediate Makefile.pre from Makefile.pre.in
  222. Makefile.pre: $(srcdir)/Misc/Makefile.pre.in sedscript
  223.         sed -f sedscript $(srcdir)/Misc/Makefile.pre.in >Makefile.pre
  224.  
  225. # Shortcuts to make the sed arguments on one line
  226. P=prefix
  227. E=exec_prefix
  228. H=Generated automatically from Makefile.pre.in by sedscript.
  229. L=LINKFORSHARED
  230.  
  231. # Make the sed script used to create Makefile.pre from Makefile.pre.in
  232. sedscript:    $(MAKEFILE)
  233.     sed -n \
  234.      -e '1s/.*/1i\\/p' \
  235.      -e '2s%.*%# $H%p' \
  236.      -e '/^VERSION=/s/^VERSION=[     ]*\(.*\)/s%@VERSION[@]%\1%/p' \
  237.      -e '/^CC=/s/^CC=[     ]*\(.*\)/s%@CC[@]%\1%/p' \
  238.      -e '/^OPT=/s/^OPT=[     ]*\(.*\)/s%@OPT[@]%\1%/p' \
  239.      -e '/^LDFLAGS=/s/^LDFLAGS=[     ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
  240.      -e '/^DEFS=/s/^DEFS=[     ]*\(.*\)/s%@DEFS[@]%\1%/p' \
  241.      -e '/^LIBS=/s/^LIBS=[     ]*\(.*\)/s%@LIBS[@]%\1%/p' \
  242.      -e '/^LIBM=/s/^LIBM=[     ]*\(.*\)/s%@LIBM[@]%\1%/p' \
  243.      -e '/^LIBC=/s/^LIBC=[     ]*\(.*\)/s%@LIBC[@]%\1%/p' \
  244.      -e '/^RANLIB=/s/^RANLIB=[     ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
  245.      -e '/^MACHDEP=/s/^MACHDEP=[     ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
  246.      -e '/^SO=/s/^SO=[     ]*\(.*\)/s%@SO[@]%\1%/p' \
  247.      -e '/^LDSHARED=/s/^LDSHARED=[     ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
  248.      -e '/^CCSHARED=/s/^CCSHARED=[     ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
  249.      -e '/^$L=/s/^$L=[     ]*\(.*\)/s%@$L[@]%\1%/p' \
  250.      -e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
  251.      -e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
  252.      $(MAKEFILE) >sedscript
  253.     echo "/^installdir=/s%=.*%=    $(installdir)%" >>sedscript
  254.     echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript
  255.     echo "/^srcdir=/s%=.*%=        $(srcdir)%" >>sedscript
  256.     echo "/^VPATH=/s%=.*%=        $(VPATH)%" >>sedscript
  257.     echo "/^LINKPATH=/s%=.*%=    $(LINKPATH)%" >>sedscript
  258.     echo "/^BASELIB=/s%=.*%=    $(BASELIB)%" >>sedscript
  259.     echo "/^BASESETUP=/s%=.*%=    $(BASESETUP)%" >>sedscript
  260.  
  261. # Bootstrap target
  262. boot:    clobber
  263.     VERSION=`python -c "import sys; print sys.version[:3]"`; \
  264.     installdir=`python -c "import sys; print sys.prefix"`; \
  265.     exec_installdir=`python -c "import sys; print sys.exec_prefix"`; \
  266.     $(MAKE) -f $(srcdir)/Misc/Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \
  267.         VERSION=$$VERSION \
  268.         MODULE=MODULE \
  269.         installdir=$$installdir \
  270.         exec_installdir=$$exec_installdir \
  271.         Makefile
  272.  
  273. # Handy target to remove intermediate files and backups
  274. clean:
  275.         -rm -f *.o *~
  276.  
  277. # Handy target to remove everything that is easily regenerated
  278. clobber:    clean
  279.         -rm -f *.a tags TAGS config.c Makefile.pre python sedscript
  280.         -rm -f *.so *.sl so_locations
  281.  
  282.  
  283. # Handy target to remove everything you don't want to distribute
  284. distclean:    clobber
  285.         -rm -f Makefile Setup
  286.  
  287. #
  288. # Local Variables:
  289. # change-log-default-name:"../ChangeLog.PyObjC"
  290. # End:
  291. #
  292.