home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rximc175.zip / Make < prev    next >
Text File  |  2000-11-01  |  15KB  |  455 lines

  1. #!/bin/sh
  2.  
  3. # export variables
  4. # set -a
  5. # set -a doesn't always work, so export them explicitly instead...
  6.  
  7. export BINDIR CC CCFLAG COMPILEFLAG DEBUG DLLFLAG LD LDL LIBDIR LIBRARIES
  8. export LINK LINKFLAG LREXX MAKE MAKEFILE MANDIR MATH OPTFLAG PIC PREFIX RANLIB
  9. export REXXIMC REXXLIB REXXLIBDIR RUNLIBS RXDAY RXMONTH RXYEAR SMALL SOFLAG
  10. export SOLINK SRC STRIPFLAG USEDLLFLAG VER VERBOSE
  11.  
  12. #######################################################################
  13. # These are things which you might reasonably expect to fiddle with...
  14. SRC=.                      # directory containing the source of REXX/imc
  15. MAKE=make
  16. MAKEFILE=Makefile.REXXimc
  17. CC=gcc                     # compiler and linker for programs
  18. LD=ld                      # linker for shared objects
  19. COMPILEFLAG=""             # general compilation flags for cc
  20. LINKFLAG=""                # general linker flags *for cc*
  21. #STUFF="-DSTUFF_STACK"     # uncomment if you like queuing stack to keyboard
  22.                            # (not guaranteed to work on all systems)
  23. SMALL=false                # true if you like small executables (not guaranteed
  24.                            # and not for ELF executables either)
  25.  
  26. # See below for destinations of files.
  27. #######################################################################
  28.  
  29. # The above things and the destination directories may be supplied as
  30. # parameters on the command line, as in 'make'.
  31. while case $1 in
  32.    *=*) eval "$1";;
  33.      *) false;;
  34. esac
  35. do shift; done
  36.  
  37. if [ ! -f $SRC/rexx.c ]; then
  38.    echo "Where are the source files?  Can't find rexx.c in $SRC" >&2
  39.    exit 1
  40. fi
  41.  
  42. # The REXX/imc version
  43. VER=1.7
  44.  
  45. # Development use only - get today's date, remove leading zeros
  46. # RXDAY=`date +%d`
  47. # RXMONTH=`date +%m`
  48. # RXYEAR=`date +%y`
  49. # RXDAY=`expr $RXDAY + 0`
  50. # RXMONTH=`expr $RXMONTH + 0`
  51. # RXYEAR=`expr $RXYEAR + 0`
  52.  
  53. # The date of this release
  54. RXDAY=1
  55. RXMONTH=1
  56. RXYEAR=100
  57.  
  58. #######################################################################
  59. # Where will the binary and library eventually end up?
  60. #
  61. # If "install" is not specified then all files end up in the current
  62. # directory; but it is useful (though not essential) to know where
  63. # the executable will be when it is installed.  If "install" is
  64. # specified then the binaries and shared library file will be placed
  65. # in their destinations.  The ".o" files remain in the current directory.
  66. #
  67. # If REXXIMC is set then this is assumed to be the final resting place
  68. # of the executable, for information purposes only.  Otherwise it is
  69. # computed as described below.  
  70. #
  71. # The path which Rexx searches for function libraries can be set at compile
  72. # time in the variable REXXLIB [actually REXXLIBDIR - the value will be
  73. # copied because the REXXLIB variable is reused later for the name of the
  74. # librexx file].  The default value of REXXLIB is the same as LIBDIR (see
  75. # below).  At compile time REXXLIB can be a colon-separated path, or the
  76. # special value "" which means to search the binary directory determined
  77. # at run time (while searching for the rxque program).  At install time
  78. # REXXLIB must name a directory, which is where the math library will be
  79. # installed.
  80. #
  81. # If BINDIR is set then this assumed to be the installation directory
  82. # for the binaries.  Similarly, LIBDIR is the installation directory for
  83. # the shared library.  Otherwise, if PREFIX is set then $PREFIX/bin and
  84. # $PREFIX/lib are used.  If PREFIX is not set then it is calculated
  85. # by the following code.  On Solaris it ends up as /opt/REXXimc and
  86. # on other systems it ends up as /usr/local.
  87. #
  88. # Manual pages will be installed in MANDIR, default $PREFIX/man/man1.
  89. #######################################################################
  90. # [May need to add more system types here; this was started as part of
  91. #  adding support for Solaris2.N's (SunOS 5.N) use of "/opt/<pkg>"]
  92.  
  93. UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R=unknown
  94. UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S=unknown
  95.  
  96. if [ "x$PREFIX" = "x" ]; then
  97.     case $UNAME_S:$UNAME_R in
  98.         SunOS:5.*)
  99.             PREFIX="/opt/REXXimc"
  100.             ;;
  101.         *|unknown)
  102.             PREFIX="/usr/local"
  103.             ;;
  104.     esac
  105. fi
  106.  
  107. : ${BINDIR=$PREFIX/bin}
  108. : ${LIBDIR=$PREFIX/lib}
  109. : ${MANDIR=$PREFIX/man/man1}
  110. : ${REXXIMC=$BINDIR}
  111. : ${REXXLIB=$LIBDIR}
  112. : ${REXXLIBDIR=$REXXLIB}
  113. REXXLIB=""
  114. # BINDIR and LIBDIR are set to the current dir later unless installing.
  115. #######################################################################
  116. # Get generic compilation flags based on commandline option
  117.  
  118. OPTFLAG=""            # generic -O or -g etc type flags
  119. STRIPFLAG=""          # -s flag for linking
  120. DEBUG=""              # special object files for debugging
  121. LDL="-ldl"            # sometimes this is not used even when available
  122.  
  123. # The first parameter may be a single letter, indicating the type of
  124. # compilation required.
  125.  
  126. VERBOSE="@#"  # default to quiet in $MAKEFILE
  127. if [ "x$1" = xv -o "x$1" = x-v ]
  128. then VERBOSE="@echo";shift
  129. fi
  130.  
  131. case ${1:-nothing} in
  132.    g)   # g (debug)
  133.         OPTFLAG=-g
  134.         shift
  135.         ;;
  136.    a)   # a (profile)
  137.         OPTFLAG=-a
  138.         CC=cc
  139.         shift
  140.         ;;
  141.    p)   # p (profile with prof)
  142.         OPTFLAG="-p -DNO_LDL"
  143.         LDL=""
  144.         shift
  145.         ;;
  146.   pg)   # pg (profile with gprof)
  147.         OPTFLAG="-pg -DNO_LDL"
  148.         LDL=""
  149.         shift
  150.         ;;
  151.    d)   # d (really debug)
  152.         OPTFLAG="-g -DDEBUG"
  153.         DEBUG="" 
  154.         if [ -f /usr/lib/debug/malloc.o -a -f /usr/lib/debug/mallocmap.o ]; then
  155.            DEBUG="/usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o"
  156.            OPTFLAG="$OPTFLAG -DMALLOC_DEBUG"
  157.         fi
  158.         shift
  159.         ;;
  160.    o)   # o (optimise)
  161.         OPTFLAG="-O2"
  162.         STRIPFLAG="-s"
  163.         shift
  164.         ;;
  165.    n)   # n (no flags)
  166.         OPTFLAG=""
  167.         STRIPFLAG=""
  168.         shift
  169.         ;;
  170.    v)   # v (make the Makefile verbose)
  171.         VERBOSE="@echo"
  172.         shift
  173.         ;;
  174.    *)   # <default>
  175.         OPTFLAG="-O2"
  176.         STRIPFLAG="-s"
  177.         ;;
  178. esac
  179.  
  180. if $SMALL
  181. then LINK="LD_OPTIONS='-n -Bdynamic' $CC"
  182. else LINK=$CC
  183. fi
  184.  
  185. #######################################################################
  186. # Now calculate system dependent variables for Makefile
  187. # Note: if OPTFLAG is -O2 it can be changed to suit the compiler.
  188.  
  189. echo "Processing REXX/imc for $UNAME_S $UNAME_R"
  190.  
  191. LREXX="-lrexx"   # we could name the object file explicitly instead
  192. SOLINK=""        # usually don't link librexx.so.version to librexx.so
  193.  
  194. case $UNAME_S:$UNAME_R in
  195.     SunOS:5.*)   # Solaris 2.N
  196. #       if [ x`echo $LD_LIBRARY_PATH` != x ]; then
  197. #           echo "Under Solaris 2.N, the use of:  " \
  198. #               LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
  199. #               "  is NOT recommended..." >&2
  200. #           exit 1
  201. #       fi
  202.         RANLIB="@true"
  203.         LIBRARIES=$LDL
  204.         REXXLIB="librexx.so"
  205.         SOLINK="librexx.so"
  206.         MATH="rxmathfn.rxfn"
  207.         case $CC in
  208.             gcc)
  209.                 CCFLAG="-DFSTAT_FOR_CHARS -DHAS_MALLOPT -DDECLARE_RANDOM -DDECLARE_TIMEZONE"
  210.                 PIC="-fPIC"
  211.                 SOFLAG="-G"
  212.                 DLLFLAG="-G"
  213.                 RUNLIBS='-R$(LIBDIR)'
  214.                 LIBRARIES="$LIBRARIES -lsocket -lnsl -lmalloc"
  215.                 ;;
  216.             cc)
  217.                 CCFLAG="-DFSTAT_FOR_CHARS -DHAS_MALLOPT -DDECLARE_RANDOM -DDECLARE_TIMEZONE"
  218.                 [ "x$OPTFLAG" = x-O2 ] && OPTFLAG="-fast"
  219.                 PIC="-KPIC"
  220.                 SOFLAG="-G"
  221.                 DLLFLAG="-G"
  222.                 RUNLIBS='-R$(LIBDIR)'
  223.                 LIBRARIES="$LIBRARIES -lsocket -lnsl -lmalloc"
  224.                 ;;
  225.             *)  echo "Warning: I don't know the options for $CC"\
  226.                      "- trying the cc ones" >&2
  227.                 CCFLAG="-DFSTAT_FOR_CHARS -DHAS_MALLOPT -DDECLARE_RANDOM  -DDECLARE_TIMEZONE"
  228.                 PIC="-KPIC"
  229.                 SOFLAG="-G"
  230.                 DLLFLAG="-G"
  231.                 RUNLIBS='-R$(LIBDIR)'
  232.                 LIBRARIES="$LIBRARIES -lsocket -lnsl -lmalloc"
  233.                 ;;
  234.         esac
  235.         ;;
  236.     SunOS:*)   # All other SunOS versions
  237.         LIBRARIES="-ldl"
  238.         REXXLIB="librexx.so"
  239.         RANLIB=ranlib
  240.         MATH="rxmathfn.rxfn"
  241.         CCFLAG="-DHAS_TTYCOM -DHAS_MALLOPT -DDECLARE_RANDOM  -DHAS_GMTOFF"
  242.         DLLFLAG="-assert pure-text"
  243.         case $CC in
  244.             gcc)
  245.                 PIC="-fPIC"
  246.                 ;;
  247.             cc)
  248.                 PIC="-PIC"
  249.                 [ "x$OPTFLAG" = x-O2 ] && OPTFLAG="-O4"
  250.                 ;;
  251.             *)  echo "Warning: I don't know the options for $CC"\
  252.                       "- trying the cc ones" >&2
  253.                 PIC="-PIC"
  254.                 ;;
  255.         esac
  256.         ;;
  257.     AIX:3*)
  258.         LIBRARIES="-lbsd"
  259.         REXXLIB="librexx.a"
  260.         RANLIB=ranlib
  261.         MATH=""
  262.         case $CC in
  263.             gcc)
  264.                 CCFLAG="-DNO_LDL -fsigned-char"
  265.                 PIC=""
  266.                 ;;
  267.             cc)
  268.                 CCFLAG="-DNO_LDL -qchars=signed"
  269.                 PIC=""
  270.                 ;;
  271.             *)  echo "Warning: I don't know the options for $CC"\
  272.                       "- trying the cc ones" >&2
  273.                 CCFLAG="-DNO_LDL -qchars=signed"
  274.                 PIC=""
  275.                 ;;
  276.         esac
  277.         ;;
  278.     HP-UX:*)
  279.         RANLIB="@true"
  280.         LIBRARIES=""
  281.         REXXLIB="librexx.a"
  282.         MATH=""
  283.         PIC=""
  284.         [ "x$OPTFLAG" = x-O2 ] && OPTFLAG="+O2"
  285.         case $CC in
  286.             cc)
  287.                 CCFLAG="-DHAS_MALLOPT -D_HPUX_SOURCE -DNO_LDL"
  288.                 ;;
  289.             c89)
  290.                 CCFLAG="-D_HPUX_SOURCE -DHAS_MALLOPT -DNO_LDL"
  291.                 ;;
  292.             *)  echo "Warning: I don't know the options for $CC"\
  293.                       "- trying the cc ones" >&2
  294.                 CCFLAG="-DHAS_MALLOPT -D_HPUX_SOURCE -DNO_LDL"
  295.                 ;;
  296.         esac
  297.         ;;
  298.     IRIX:*|IRIX64:*)
  299.         RANLIB="@true"
  300.         LIBRARIES=""
  301.         REXXLIB="librexx.so"
  302.         SOLINK="librexx.so"
  303.         MATH=rxmathfn.rxfn
  304.         PIC=""
  305.         SOFLAG='-shared -ignore_unresolved'
  306.         DLLFLAG='-shared -soname $(SONAME) -ignore_unresolved'
  307.         USEDLLFLAG='-call_shared -Wl,-rpath,$(LIBDIR)'
  308.         case $CC in
  309.             cc) case $UNAME_S in
  310.                 IRIX)   CCFLAG="-signed -Olimit 1400"
  311.                         ;;
  312.                 IRIX64) CCFLAG="-signed -OPT:Olimit=2700 -woff all -DPOINTER64"
  313.                         ;;
  314.                 esac
  315.                 ;;
  316.             gcc)CCFLAG="-fsigned-char"
  317.                 SOFLAG="$SOFLAG -n32"
  318.                 DLLFLAG="$DLLFLAG -n32"
  319.                 STRIPFLAG=""
  320.                 ;;
  321.             *)  echo "Warning: I don't know the options for $CC"\
  322.                       "- trying the cc ones" >&2
  323.                 CCFLAG="-signed -Olimit 1400"
  324.                 ;;
  325.         esac
  326.         ;;
  327.     OSF1:*)
  328.         LIBRARIES="-lbsd"
  329.         REXXLIB="librexx.so"
  330.         SOLINK="librexx.so"
  331.         RANLIB="@true"
  332.         MATH="rxmathfn.rxfn"
  333.         PIC=""
  334.         SOFLAG='-shared -expect_unresolved "*"'
  335.         DLLFLAG='-shared -soname $(SONAME) -expect_unresolved "*"'
  336.         USEDLLFLAG='-call_shared -Wl,-rpath,$(LIBDIR)'
  337.         CCFLAG="-DHAS_MALLOPT -DHAS_GMTOFF -DPOINTER64"
  338.         case $CC in
  339.             cc) 
  340.                 CCFLAG="$CCFLAG -Olimit 1400"
  341.                 [ "x$OPTFLAG" = x-O2 ] && OPTFLAG="-O3"
  342.                 ;;
  343.             gcc) # already OK
  344.                 ;;
  345.             *)  echo "Warning: I don't know the options for $CC"\
  346.                       "- trying the gcc ones" >&2
  347.                 ;;
  348.         esac
  349.         ;;
  350.     Linux:1*)
  351.         REXXLIB="librexx.a"
  352.         RANLIB=ranlib
  353.         MATH=""
  354.         PIC=""
  355.         LIBRARIES=""
  356.         case $CC in
  357.             gcc)
  358.                 CCFLAG="-DNO_LDL -DFSTAT_FOR_CHARS"
  359.                 ;;
  360.             *)  echo "Warning: I don't know the options for $CC"\
  361.                       "- trying the gcc ones" >&2
  362.                 CCFLAG="-DNO_LDL -DFSTAT_FOR_CHARS"
  363.                 ;;
  364.         esac
  365.         ;;
  366.     Linux:2*)
  367.         REXXLIB="librexx.so"
  368.         SOLINK="librexx.so"
  369.         DLLFLAG="-shared"
  370.         SOFLAG="-shared"
  371.         : ${RUNLIBS='-Wl,-rpath,$(LIBDIR)'} # can be overridden by environment
  372.         RANLIB=ranlib
  373.         MATH="rxmathfn.rxfn"
  374.         PIC="-fpic"
  375.         LIBRARIES="$LDL"
  376.         case $CC in
  377.             gcc)
  378.                 CCFLAG="-DFSTAT_FOR_CHARS"
  379.                 ;;
  380.             *)  echo "Warning: I don't know the options for $CC"\
  381.                       "- trying the gcc ones" >&2
  382.                 CCFLAG="-DFSTAT_FOR_CHARS"
  383.                 ;;
  384.         esac
  385.         egrep -q tm_gmtoff /usr/include/time.h && CCFLAG="$CCFLAG -DHAS_GMTOFF"
  386.         ;;
  387.     FreeBSD:*)
  388.         REXXLIB="librexx.so"
  389.         RANLIB=ranlib
  390.         MATH=rxmathfn.rxfn
  391.         LIBRARIES=""
  392.         SOFLAG="-Bshareable"
  393.         DLLFLAG="-Bshareable"
  394. #       LREXX='$(LIBDIR)/$(SONAME)'
  395. #       Uncomment above line if you have problems with LD_LIBRARY_PATH
  396.         case $CC in
  397.             gcc)
  398.                 CCFLAG="-DHAS_TTYCOM -D_REQUIRED -DRENAME_UNDELETE -DHAS_GMTOFF"
  399.                 PIC="-fPIC"
  400.                 ;;
  401.             *)  echo "Warning: I don't know the options for $CC"\
  402.                       "- trying the gcc ones" >&2
  403.                 CCFLAG="-DHAS_TTYCOM -D_REQUIRED -DRENAME_UNDELETE -DHAS_GMTOFF"
  404.                 PIC="-fPIC"
  405.                 ;;
  406.         esac
  407.         ;;
  408.     unknown:*|*:*)
  409.         echo "I am not configured for this platform - guessing some options" >&2
  410.         echo "(You will not be able to use shared libraries)" >&2
  411.         REXXLIB="librexx.a"
  412.         RANLIB=ranlib
  413.         MATH=""
  414.         LIBRARIES=""
  415.         PIC=""
  416.         if [ -f /usr/include/sys/ttycom.h ]
  417.         then CCFLAG="-DHAS_TTYCOM -DNO_LDL -DFSTAT_FOR_CHARS"
  418.         else CCFLAG="-DNO_LDL -DFSTAT_FOR_CHARS"
  419.         fi
  420.         ;;
  421. esac
  422.  
  423. CCFLAG="$COMPILEFLAG $STUFF $CCFLAG"
  424. LINKFLAG="$LINKFLAG $STRIPFLAG"
  425. [ "x$SOLINK" != x ] && SOLINK='$(LIBDIR)'/"$SOLINK"
  426.  
  427. #######################################################################
  428. # If installing, make sure the destination directories exist.
  429. # Otherwise, the destination is the current directory.
  430.  
  431. case "x$1" in
  432.     xinstall*|xuninstall*)
  433.         if [ -d $BINDIR ] || mkdir -p $BINDIR; then :;
  434.         else echo "Unable to make binary directory" >&2; exit 1
  435.         fi
  436.         if [ -d $LIBDIR ] || mkdir -p $LIBDIR; then :;
  437.         else echo "Unable to make library directory" >&2; exit 1
  438.         fi
  439.         if [ -d $REXXLIBDIR ] || mkdir -p $REXXLIBDIR; then :;
  440.         else echo "Unable to make Rexx library directory" >&2; exit 1
  441.         fi
  442.         ;;
  443.     *)
  444.         BINDIR=.
  445.         LIBDIR=`pwd`
  446. esac
  447.  
  448. # Variables are exported above
  449. MAKE_PARMS=${*:-all}
  450. if [ "x$1" = xtest ]; then
  451.     $MAKE -n -f $SRC/$MAKEFILE all
  452. else
  453.     $MAKE -f $SRC/$MAKEFILE $MAKE_PARMS
  454. fi
  455.