1 #
   2 # Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 #
  27 # Shared variables for standard unix utilties on all platforms.
  28 #
  29 # Assumes Platform.gmk has been included before this file.
  30 #
  31 # These input UTILS_* variables can be defined at anytime, ideally once.
  32 #         Unix Commands: Normally /bin/, /usr/bin/. or C:/mksnt/mksnt/
  33 #            UTILS_COMMAND_PATH
  34 #         /usr/bin/
  35 #            UTILS_USR_BIN_PATH
  36 #         /usr/ccs/bin/ (sccs, m4, lex, yacc, as, ar, strip, mcs)
  37 #            UTILS_CCS_BIN_PATH
  38 #         Dev Tools: zip, unzip, etc that we may have special versions of
  39 #            UTILS_DEVTOOL_PATH
  40 #
  41 # WARNING:  This file cannot assume that any of these utilties are available
  42 #           to be run via their variable names defined here.
  43 #           The paths inside the UTILS_* variables may not be defined yet.
  44 #
  45 # Note: There is no guarantee that all these exist on all platforms.
  46 #       Some only make sense for one platform, but are harmless.
  47 #
  48 
  49 ifeq ($(PLATFORM),linux)
  50   UTILS_COMMAND_PATH=$(UNIXCOMMAND_PATH)
  51   UTILS_USR_BIN_PATH=$(USRBIN_PATH)
  52   UTILS_CCS_BIN_PATH=$(USRBIN_PATH)
  53   UTILS_DEVTOOL_PATH=$(USRBIN_PATH)
  54 endif
  55 
  56 ifeq ($(PLATFORM),bsd)
  57   UTILS_COMMAND_PATH=$(UNIXCOMMAND_PATH)
  58   UTILS_USR_BIN_PATH=$(USRBIN_PATH)
  59   UTILS_CCS_BIN_PATH=$(USRBIN_PATH)
  60   UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH)
  61 endif
  62 
  63 ifeq ($(PLATFORM),solaris)
  64   UTILS_COMMAND_PATH=$(UNIXCOMMAND_PATH)
  65   UTILS_USR_BIN_PATH=$(UNIXCOMMAND_PATH)
  66   UTILS_CCS_BIN_PATH=$(UNIXCCS_PATH)
  67   UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH)
  68 endif
  69 
  70 ifeq ($(PLATFORM),windows)
  71   UTILS_COMMAND_PATH=$(UNIXCOMMAND_PATH)
  72   UTILS_USR_BIN_PATH=$(UNIXCOMMAND_PATH)
  73   UTILS_CCS_BIN_PATH=$(UNIXCOMMAND_PATH)
  74   UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH)
  75 endif
  76 
  77 # Utilities
  78 ADB            = $(UTILS_COMMAND_PATH)adb
  79 AR             = $(UTILS_CCS_BIN_PATH)ar
  80 AS             = $(UTILS_CCS_BIN_PATH)as
  81 BASENAME       = $(UTILS_COMMAND_PATH)basename
  82 CAT            = $(UTILS_COMMAND_PATH)cat
  83 CHMOD          = $(UTILS_COMMAND_PATH)chmod
  84 CMP            = $(UTILS_USR_BIN_PATH)cmp
  85 COMM           = $(UTILS_USR_BIN_PATH)comm
  86 COMPRESS       = $(UTILS_USR_BIN_PATH)compress
  87 CP             = $(UTILS_COMMAND_PATH)cp
  88 CPIO           = $(UTILS_COMMAND_PATH)cpio
  89 CUT            = $(UTILS_USR_BIN_PATH)cut
  90 DATE           = $(UTILS_COMMAND_PATH)date
  91 DF             = $(UTILS_COMMAND_PATH)df
  92 DIFF           = $(UTILS_USR_BIN_PATH)diff
  93 DIRNAME        = $(UTILS_USR_BIN_PATH)dirname
  94 ECHO           = $(UTILS_COMMAND_PATH)echo
  95 EGREP          = $(UTILS_COMMAND_PATH)egrep
  96 EXPR           = $(UTILS_USR_BIN_PATH)expr
  97 FILE           = $(UTILS_USR_BIN_PATH)file
  98 FIND           = $(UTILS_USR_BIN_PATH)find
  99 FMT            = $(UTILS_COMMAND_PATH)fmt
 100 GDB            = $(UTILS_USR_BIN_PATH)gdb
 101 GREP           = $(UTILS_COMMAND_PATH)grep
 102 GUNZIP         = $(UTILS_COMMAND_PATH)gunzip
 103 HEAD           = $(UTILS_USR_BIN_PATH)head
 104 ID             = $(UTILS_COMMAND_PATH)id
 105 ISAINFO        = $(UTILS_COMMAND_PATH)isainfo
 106 KSH            = $(UTILS_COMMAND_PATH)ksh
 107 LD             = $(UTILS_CCS_BIN_PATH)ld
 108 LEX            = $(UTILS_CCS_BIN_PATH)lex
 109 LN             = $(UTILS_COMMAND_PATH)ln
 110 LS             = $(UTILS_COMMAND_PATH)ls
 111 MCS            = $(UTILS_CCS_BIN_PATH)mcs
 112 M4             = $(UTILS_CCS_BIN_PATH)m4
 113 MKDIR          = $(UTILS_COMMAND_PATH)mkdir
 114 MKSINFO        = $(UTILS_COMMAND_PATH)mksinfo
 115 MSGFMT         = $(UTILS_USR_BIN_PATH)msgfmt
 116 MV             = $(UTILS_COMMAND_PATH)mv
 117 NAWK           = $(UTILS_USR_BIN_PATH)nawk
 118 NM             = $(UTILS_CCS_BIN_PATH)nm
 119 PKGMK          = $(UTILS_COMMAND_PATH)pkgmk
 120 PRINTF         = $(UTILS_USR_BIN_PATH)printf
 121 PWD            = $(UTILS_COMMAND_PATH)pwd
 122 RC             = $(UTILS_COMMAND_PATH)rc
 123 RMDIR          = $(UTILS_COMMAND_PATH)rmdir
 124 RPM            = $(UTILS_COMMAND_PATH)rpm
 125 RPMBUILD       = $(UTILS_COMMAND_PATH)rpmbuild
 126 SED            = $(UTILS_COMMAND_PATH)sed
 127 SH             = $(UTILS_COMMAND_PATH)sh
 128 SHOWREV        = $(UTILS_USR_BIN_PATH)showrev
 129 SORT           = $(UTILS_COMMAND_PATH)sort
 130 STRIP          = $(UTILS_CCS_BIN_PATH)strip
 131 TAIL           = $(UTILS_USR_BIN_PATH)tail
 132 TAR            = $(UTILS_COMMAND_PATH)tar
 133 TEST           = $(UTILS_USR_BIN_PATH)test
 134 TOUCH          = $(UTILS_COMMAND_PATH)touch
 135 TR             = $(UTILS_USR_BIN_PATH)tr
 136 TRUE           = $(UTILS_COMMAND_PATH)true
 137 UNAME          = $(UTILS_COMMAND_PATH)uname
 138 UNIQ           = $(UTILS_USR_BIN_PATH)uniq
 139 UNZIP          = $(UTILS_USR_BIN_PATH)unzip
 140 UNZIPSFX       = $(UTILS_DEVTOOL_PATH)unzipsfx
 141 WC             = $(UTILS_USR_BIN_PATH)wc
 142 WHICH          = $(UTILS_USR_BIN_PATH)which
 143 YACC           = $(UTILS_CCS_BIN_PATH)yacc
 144 ZIPEXE         = $(UTILS_DEVTOOL_PATH)zip
 145 
 146 # Special cases
 147 #RM   is defined by GNU Make as 'rm -f'
 148 CD             = cd # intrinsic unix command
 149 
 150 # Windows specific
 151 ifeq ($(PLATFORM),windows)
 152   ifdef USING_CYGWIN
 153     # Intrinsic unix command, with backslash-escaped character interpretation
 154     ECHO = $(UNIXCOMMAND_PATH)echo -e
 155     ZIPEXE = $(UNIXCOMMAND_PATH)zip
 156     UNZIP  = $(UNIXCOMMAND_PATH)unzip
 157   else
 158     ZIPEXE = $(UTILS_DEVTOOL_PATH)zip
 159     UNZIP  = $(UTILS_DEVTOOL_PATH)unzip
 160   endif
 161   # Re-define some utilities
 162   LEX            =# override GNU Make intrinsic: no lex on windows
 163   NAWK           = $(UNIXCOMMAND_PATH)awk
 164 endif
 165 
 166 # Linux specific
 167 ifeq ($(PLATFORM),linux)
 168   # A few redefines
 169   # Allows for builds on Debian GNU Linux, basename is in a different place
 170   BASENAME=$(firstword $(wildcard $(UTILS_COMMAND_PATH)basename) \
 171                        $(wildcard $(UTILS_USR_BIN_PATH)basename))
 172   # RPM 4 has replaced "rpm -b" with an entirely new utility "rpmbuild".
 173   # Also, some distribution (Ubuntu, Debian, others?) place the rpm command
 174   # itself in /usr/bin rather than it's traditional home in /bin.
 175   RPM=$(firstword $(wildcard $(UTILS_COMMAND_PATH)rpm) \
 176                   $(wildcard $(UTILS_USR_BIN_PATH)rpm))
 177   RPMBUILD=$(firstword $(wildcard $(UTILS_COMMAND_PATH)rpmbuild) \
 178                        $(wildcard $(UTILS_USR_BIN_PATH)rpmbuild) \
 179                        $(wildcard $(UTILS_COMMAND_PATH)rpm) \
 180                        $(wildcard $(UTILS_USR_BIN_PATH)rpm))
 181   # Most Linux distros have "sort" in /bin.  Ubuntu, Debian and perhaps
 182   # others have it in /usr/bin.
 183   SORT=$(firstword $(wildcard $(UTILS_COMMAND_PATH)sort) \
 184                    $(wildcard $(UTILS_USR_BIN_PATH)sort))
 185   NAWK           = $(USRBIN_PATH)gawk
 186   # Intrinsic unix command, with backslash-escaped character interpretation
 187   ECHO           = /bin/echo -e
 188   # These are really in UTILS_USR_BIN_PATH on Linux (only sccs is not)
 189   AR             = $(UTILS_USR_BIN_PATH)ar
 190   AS             = $(UTILS_USR_BIN_PATH)as
 191   LD             = $(UTILS_USR_BIN_PATH)ld
 192   LEX            = $(UTILS_USR_BIN_PATH)lex
 193   MCS            = $(UTILS_USR_BIN_PATH)mcs
 194   M4             = $(UTILS_USR_BIN_PATH)m4
 195   NM             = $(UTILS_USR_BIN_PATH)nm
 196   STRIP          = $(UTILS_USR_BIN_PATH)strip
 197   YACC           = $(UTILS_USR_BIN_PATH)yacc
 198 endif
 199 
 200 # Solaris specific
 201 ifeq ($(PLATFORM),solaris)
 202   # Intrinsic unix command, with backslash-escaped character interpretation
 203   #   (not using -e  will cause build failure when using /bin/bash)
 204   #   (using -e breaks something else)
 205   ECHO           = /usr/bin/echo
 206 endif
 207 
 208 # BSD specific
 209 ifeq ($(PLATFORM),bsd)
 210   BASENAME     = $(UTILS_USR_BIN_PATH)basename
 211   EGREP        = $(UTILS_USR_BIN_PATH)egrep
 212   EXPR         = $(UTILS_COMMAND_PATH)expr
 213   FMT          = $(UTILS_USR_BIN_PATH)fmt
 214   GREP         = $(UTILS_USR_BIN_PATH)grep
 215   GUNZIP       = $(UTILS_USR_BIN_PATH)gunzip
 216   ID           = $(UTILS_USR_BIN_PATH)id
 217   MSGFMT       = $(UTILS_DEVTOOL_PATH)msgfmt
 218   SED          = $(UTILS_USR_BIN_PATH)sed
 219   SORT         = $(UTILS_USR_BIN_PATH)sort
 220   TEST         = $(UTILS_COMMAND_PATH)test
 221   TOUCH        = $(UTILS_USR_BIN_PATH)touch
 222   TRUE         = $(UTILS_USR_BIN_PATH)true
 223   UNAME        = $(UTILS_USR_BIN_PATH)uname
 224   # BSD OS_VENDOR specific
 225   ifeq ($(OS_VENDOR), Apple)
 226     NAWK       = $(UTILS_USR_BIN_PATH)awk
 227     UNZIPSFX   = $(UTILS_USR_BIN_PATH)unzipsfx
 228     ZIPEXE     = $(UTILS_USR_BIN_PATH)zip
 229   else
 230     UNZIP      = $(UTILS_DEVTOOL_PATH)unzip
 231   endif
 232   ifeq ($(OS_VENDOR), OpenBSD)
 233     NAWK       = $(UTILS_USR_BIN_PATH)awk
 234   else
 235     CPIO       = $(UTILS_USR_BIN_PATH)cpio
 236     TAR        = $(UTILS_USR_BIN_PATH)tar
 237   endif
 238 endif