home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / build / hcpp < prev   
Encoding:
Text File  |  1998-04-08  |  1.8 KB  |  87 lines

  1. #!/bin/sh
  2. #
  3. # The contents of this file are subject to the Netscape Public License
  4. # Version 1.0 (the "NPL"); you may not use this file except in
  5. # compliance with the NPL.  You may obtain a copy of the NPL at
  6. # http://www.mozilla.org/NPL/
  7. #
  8. # Software distributed under the NPL is distributed on an "AS IS" basis,
  9. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10. # for the specific language governing rights and limitations under the
  11. # NPL.
  12. #
  13. # The Initial Developer of this code under the NPL is Netscape
  14. # Communications Corporation.  Portions created by Netscape are
  15. # Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16. # Reserved.
  17. #
  18.  
  19. #
  20. # Wrapper for brain-damaged compilers that don't understand -o and -c together.
  21. #
  22.  
  23. DUMMY="XxxXxxX"
  24. DASH_C=0
  25. DASH_O=0
  26. GET_OBJECT=0
  27. C_SRC="${DUMMY}"
  28. CC_SRC="${DUMMY}"
  29. CPP_SRC="${DUMMY}"
  30. S_SRC="${DUMMY}"
  31. OBJECT="${DUMMY}"
  32.  
  33. for i in $*
  34. do
  35.     if [ ${GET_OBJECT} -eq 1 ]; then
  36.         OBJECT="$i"
  37.         GET_OBJECT=0
  38.     fi
  39.     case $i in
  40.         -c)
  41.             DASH_C=1
  42.             ;;
  43.         -o)
  44.             DASH_O=1
  45.             GET_OBJECT=1
  46.             ;;
  47.         *.c)
  48.             C_SRC="$i"
  49.             ;;
  50.         +.*)
  51.             ;;
  52.         *.cpp)
  53.             CPP_SRC="$i"
  54.             ;;
  55.         *.cc)
  56.             CC_SRC="$i"
  57.             ;;
  58.         *.s)
  59.             S_SRC="$i"
  60.             ;;
  61.     esac
  62. done
  63.  
  64. CC $* || exit $?
  65.  
  66. # LAME!!!
  67. if [ -f -O ]; then
  68.     mv -f -- -O ${OBJECT}
  69. fi
  70.  
  71. # if there was no -c and -o we're done
  72. [ ${DASH_C} -eq 1 -a ${DASH_O} -eq 1 ] || exit 0
  73.  
  74. # cc always creates the .o from the .c name
  75. if [ "${C_SRC}" != "${DUMMY}" ]; then
  76.     OBJ=`basename ${C_SRC} .c`.o
  77. elif [ "${CPP_SRC}" != "${DUMMY}" ]; then
  78.     OBJ=`basename ${CPP_SRC} .cpp`.o
  79. elif [ "${CC_SRC}" != "${DUMMY}" ]; then
  80.     OBJ=`basename ${CC_SRC} .cc`.o
  81. # or the .o from the .s name
  82. elif [ "${S_SRC}" != "${DUMMY}" ]; then
  83.     OBJ=`basename ${S_SRC} .s`.o
  84. fi
  85.  
  86. [ -f ${OBJECT} ] || [ -f ${OBJ} ] && mv -f ${OBJ} ${OBJECT}
  87.