home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / scheme2c / rec-28se.pat / shlibs / shlibsc / makefile
Encoding:
Makefile  |  1994-06-30  |  7.6 KB  |  233 lines

  1. ##
  2. ## Build shared library for Scheme->C and versions of sci and sccomp which
  3. ## use the shared libraries.
  4. ##
  5. ## Built under ISC 386/ix 2.0.2 with the host based tcp/ip package
  6. ## and the software development package, but using gcc as compiler.
  7. ##
  8. ## First, make port in scrt and scsc to build libsc.a and the objects for
  9. ## sccomp.  The CFLAGS used to compile scrt/scinit.c must include -DI386SHLIB
  10. ## but all the other objects are the same as the ones used for the unshared
  11. ## libraries.
  12. ##
  13. ## Second, edit the directory names in this file to reflect your own system
  14. ## conventions.
  15. ##
  16. ## Third, if you aren't using gcc, then find the lines marked NO-GCC and
  17. ## fix them according to the supplied instructions.
  18. ##
  19. ## Third and a half - stiff upper lip - become root and use emacs to edit
  20. ## /usr/lib/libinet.a.  There are three modules which define errno as Common
  21. ## rather than Undefined and we need to fix them.  Search for the string
  22. ##    errno^@^@^@^D
  23. ## with ^S, remembering that the ^@ and ^D will need to be quoted with ^Q.
  24. ## Delete the ^D and insert a ^@ in its place.  You need to do this three
  25. ## times, then write the file out with ^X^S.  (You might want to make an extra
  26. ## backup of libinet.a before you do this.  :-)  Finally, you should run
  27. ## ranlib, ie ar rs, on the updated archive to get its symbol table fixed.
  28. ##
  29. ## Fourth, try make all to see if everything comes together correctly.
  30. ## The library build makes subdirectories and extracts needed objects
  31. ## from archives.  This can take up a lot of space, but not nearly as
  32. ## much as the shared x11 libraries will.
  33. ##
  34. ## Fifth, become a privileged user and try make install.  Note that
  35. ## sci_s and sccomp_s will not run until the target shared library has
  36. ## been installed in its declared home.  So make sure that #target
  37. ## specifies a directory that you can modify.
  38. ##
  39.  
  40. #NO-GCC then change this macro to use cc
  41. CC=gcc
  42.  
  43. BINDIR = /usr/local/bin
  44. LIBDIR = /usr/local/lib
  45. CPUDIR = /home/28sep90~
  46.  
  47. #NO-GCC then delete gnulib from this list
  48. libraries = libsc libinet libm libc gnulib
  49.  
  50. libsc_a = ${CPUDIR}/scrt/libsc.a
  51. libinet_a = /usr/lib/libinet.a
  52. libm_a = /lib/libm.a
  53. libc_a = /lib/libc.a
  54. gnulib_a = ${LIBDIR}/gcc-gnulib
  55. libc_s_a = /lib/libc_s.a
  56.  
  57. sci_o = ../scrt/sci.o
  58.  
  59. sccomp_o= ../scsc/main.o ../scsc/closeana.o ../scsc/lambdaexp.o\
  60.     ../scsc/plist.o ../scsc/transform.o ../scsc/expform.o\
  61.     ../scsc/readtext.o ../scsc/miscexp.o ../scsc/macros.o\
  62.     ../scsc/compile.o ../scsc/lap.o ../scsc/gencode.o\
  63.     ../scsc/callcode.o ../scsc/lambdacode.o ../scsc/misccode.o
  64.  
  65. all: sci_s sccomp_s libsc_s
  66.  
  67. sci_s: ${sci_o} libsc_s
  68.     ${CC} -o sci_s ${sci_o} libsc_s.a -lc_s
  69.     @echo target shared library must be installed before sci_s can run.
  70.  
  71. sccomp_s: ${sccomp_o} libsc_s
  72.     ${CC} -o sccomp_s ${sccomp_o} libsc_s.a -lc_s
  73.     @echo target shared library must be installed before sccomp_s can run.
  74.  
  75. install: all
  76.     -mkdir ${LIBDIR}/schemetoc
  77.     -rm ${LIBDIR}/schemetoc/libsc_s
  78.     cp libsc_s ${LIBDIR}/schemetoc
  79.     strip ${LIBDIR}/schemetoc/libsc_s
  80.     -rm ${LIBDIR}/schemetoc/libsc_s.a
  81.     -rm ${LIBDIR}/schemetoc/libsc.a
  82.     cp libsc_s.a ${LIBDIR}/schemetoc/libsc_s.a
  83.     ln ${LIBDIR}/schemetoc/libsc_s.a ${LIBDIR}/schemetoc/libsc.a
  84.     -rm ${BINDIR}/sci_s
  85.     -rm ${BINDIR}/sci
  86.     cp sci_s ${BINDIR}/sci_s
  87.     ln ${BINDIR}/sci_s ${BINDIR}/sci
  88.     strip ${BINDIR}/sci_s
  89.     cp ${CPUDIR}/scrt/predef.sc ${LIBDIR}/schemetoc
  90.     cp ${CPUDIR}/scrt/objects.h ${LIBDIR}/schemetoc
  91.     -rm ${BINDIR}/sccomp_s
  92.     -rm ${BINDIR}/sccomp
  93.     cp sccomp_s ${BINDIR}
  94.     ln ${BINDIR}/sccomp_s ${BINDIR}/sccomp
  95.     strip ${BINDIR}/sccomp_s
  96.     ${BINDIR}/sccomp_s \
  97.         -sch 4 \
  98.         ${LIBDIR}/schemetoc/predef.sc \
  99.             ${LIBDIR}/schemetoc/objects.h \
  100.         ${LIBDIR}/schemetoc/libsc_s.a \
  101.         ${LIBDIR}/schemetoc/libsc_s.a \
  102.         I386 \
  103.         ${LIBDIR}/schemetoc/sccomp_s.heap
  104.     chmod +r ${LIBDIR}/schemetoc/sccomp_s.heap
  105.     chmod -x ${LIBDIR}/schemetoc/sccomp_s.heap
  106.     -rm ${BINDIR}/scc
  107.     echo "#!/bin/sh" > ${BINDIR}/scc
  108.     echo SCC=${BINDIR}/sccomp >> ${BINDIR}/scc
  109.     echo SCH=${LIBDIR}/schemetoc/sccomp_s.heap >> ${BINDIR}/scc
  110.     echo LIB='"'${LIBDIR}/schemetoc/libsc_s.a -lc_s'"' >> ${BINDIR}/scc
  111.     echo '$${SCC} -cc $${CC} -schf $${SCH} $$* $${LIB}' >> ${BINDIR}/scc
  112.     chmod +x ${BINDIR}/scc
  113.  
  114. ##
  115. ## Interpreter runtime library modules.
  116. ##
  117. libsc = libsc/apply.o libsc/callcc.o libsc/cio.o libsc/heap.o\
  118.     libsc/objects.o libsc/scdebug.o libsc/sceval.o libsc/scexpand.o\
  119.     libsc/scexpand1.o libsc/scexpand2.o libsc/scinit.o libsc/scqquote.o\
  120.     libsc/screp.o libsc/scrt1.o libsc/scrt2.o libsc/scrt3.o libsc/scrt4.o\
  121.     libsc/scrt5.o libsc/scrt6.o libsc/scrt7.o libsc/signal.o
  122.  
  123. ##
  124. ## Additional libinet support.
  125. ##
  126. libinet = libinet/bcopy.o libinet/bzero.o libinet/connect.o\
  127.   libinet/byteorder.o libinet/ghostnamad.o libinet/ghostname.o\
  128.   libinet/inet_addr.o libinet/select.o libinet/setsockopt.o libinet/socket.o\
  129.   libinet/bcmp.o libinet/res_comp.o libinet/res_mkqury.o libinet/res_send.o\
  130.   libinet/sockack.o libinet/recv.o libinet/res_init.o libinet/send.o
  131.  
  132. ##
  133. ## Math library modules.
  134. ##
  135. libm = libm/floor.o libm/exp.o libm/log.o libm/sin.o libm/tan.o libm/asin.o\
  136.     libm/atan.o libm/sqrt.o libm/pow.o libm/matherr.o
  137.  
  138. ##
  139. ## C library modules not in shared c library.
  140. ##
  141. libc =  libc/setjmp.o libc/poll.o libc/printf.o libc/abort.o\
  142.     libc/scanf.o libc/modf.o libc/doscan.o libc/ctype.o\
  143.     libc/link.o libc/geteuid.o libc/mknod.o\
  144.     libc/rew.o libc/strtol.o libc/sysi86.o\
  145.     libc/errlst.o libc/tolower.o \
  146.     libc/data.o libc/cuexit.o \
  147.     libc/putmsg.o libc/uname.o libc/getmsg.o
  148.  
  149. ##
  150. ## Gnu c compiler run time support modules.
  151. ##
  152. gnulib = gnulib/_divsi3.o gnulib/_fixdfsi.o gnulib/_fixunsdfsi.o\
  153.     gnulib/_muldi3.o gnulib/_moddi3.o gnulib/_cmpdi2.o gnulib/_negdi2.o\
  154.     gnulib/_umoddi3.o gnulib/_bdiv.o gnulib/_udivsi3.o
  155.  
  156. ##
  157. ## The whole kit
  158. ##
  159. #NO-GCC then delete ${gnulib} from this list
  160. library_objects =  ${libsc} ${libinet} ${libm} ${local} ${libc} ${gnulib}
  161. ##
  162. ## Scheme interpreter runtime library.
  163. ##
  164. libsc_s: libsc.sl
  165.     -rm libsc_s libsc_s.a
  166.     mkshlib -s libsc.sl -t libsc_s -h libsc_s.a 2> libsc.err
  167. libsc.sl: libsc.o
  168.     echo '##'                    > libsc.sl
  169.     echo '## libsc.sl - scheme->c library'        >> libsc.sl
  170.     echo '#address .text 0xB0000000'        >> libsc.sl
  171.     echo '#address .data 0xB0400000'        >> libsc.sl
  172.     echo '#target ${LIBDIR}/schemetoc/libsc_s'    >> libsc.sl
  173.     echo '#branch'                    >> libsc.sl
  174.     nm -px libsc.o |\
  175.       sort |\
  176.       nawk '/ T .*__init/{print "  " $$3 "  " ++nbt}'>> libsc.sl
  177.     echo '#objects'                    >> libsc.sl
  178.     echo '  libsc.o'                >> libsc.sl
  179.     echo '#objects noload'                >> libsc.sl
  180.     echo /lib/libc_s.a                >> libsc.sl
  181.     echo '#init libsc.o'                >> libsc.sl
  182.     echo '  sc__etext etext'            >> libsc.sl
  183.     echo '#hide linker *'                >> libsc.sl
  184.     echo '#export linker'                >> libsc.sl
  185.     nm -px libsc.o |\
  186.       sort |\
  187.       nawk '/ [DT] /{print "    " $$3}'            >> libsc.sl
  188.  
  189. libsc.o: ${libraries} ${library_objects}
  190.     ld -x -r -o tmp.o ${library_objects}
  191.     nm -p tmp.o | \
  192.       nawk '/ C /{ print "int " $$3 "[" int(($$1+3)/4) "]={0};" }'\
  193.       > tmp_defs.c
  194.     ${CC} -c tmp_defs.c
  195.     ld -x -r -o libsc.o tmp_defs.o tmp.o
  196.  
  197. libsc: ${libsc_a}
  198.     -mkdir libsc
  199.     cd libsc; ar x ${libsc_a} `echo ${libsc} | sed s/libsc.//gp`
  200.  
  201. libinet:
  202.     -mkdir libinet
  203.     cd libinet; ar x ${libinet_a} `echo ${libinet} | sed s/libinet.//gp`
  204.  
  205. libm: ${libm_a}
  206.     -mkdir libm
  207.     cd libm; ar x ${libm_a} `echo ${libm} | sed s/libm.//gp`
  208.  
  209. libc: ${libc_a}
  210.     -mkdir libc
  211.     cd libc; ar x ${libc_a} `echo ${libc} | sed s/libc.//gp`
  212.  
  213. gnulib: ${gnulib_a}
  214.     -mkdir gnulib
  215.     cd gnulib; ar x ${gnulib_a} `echo ${gnulib} | sed s/gnulib.//gp`
  216.  
  217. libsc.get: libsc.o
  218.     nm -p ${libc_s_a} | nawk '/ A [_a-zA-Z]/{ print $$3 }' | sort > absolute
  219.     nm -p libsc.o | nawk '/ U /{ print $$3 }' | sort > undefined
  220.     comm -13 absolute undefined > libsc.get
  221.  
  222. ##
  223. ## Miscellaneous
  224. ##
  225. clean:
  226.     -rm libsc.o libsc.err libsc.sl libsc.get
  227.     -rm tmp.o tmp_defs.c tmp_defs.o undefined absolute
  228. all-clean:
  229.     -rm libsc_s libsc_s.a sci_s sccomp_s
  230.     -rm -fr ${libraries}
  231.  
  232.  
  233.