| 1 | /* sysdep.h -- handle host dependencies for the GNU linker |
| 2 | Copyright 1995, 1996, 1997, 1999, 2002, 2003, 2005, 2007, 2012 |
| 3 | Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of the GNU Binutils. |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
| 20 | MA 02110-1301, USA. */ |
| 21 | |
| 22 | #ifndef LD_SYSDEP_H |
| 23 | #define LD_SYSDEP_H |
| 24 | |
| 25 | #ifdef PACKAGE |
| 26 | #error sysdep.h must be included in lieu of config.h |
| 27 | #endif |
| 28 | |
| 29 | #include "config.h" |
| 30 | |
| 31 | #include <stdio.h> |
| 32 | #include <sys/types.h> |
| 33 | #include <sys/stat.h> |
| 34 | #include <stdarg.h> |
| 35 | |
| 36 | #ifdef STRING_WITH_STRINGS |
| 37 | #include <string.h> |
| 38 | #include <strings.h> |
| 39 | #else |
| 40 | #ifdef HAVE_STRING_H |
| 41 | #include <string.h> |
| 42 | #else |
| 43 | #ifdef HAVE_STRINGS_H |
| 44 | #include <strings.h> |
| 45 | #else |
| 46 | extern char *strchr (); |
| 47 | extern char *strrchr (); |
| 48 | #endif |
| 49 | #endif |
| 50 | #endif |
| 51 | |
| 52 | #ifdef HAVE_STDLIB_H |
| 53 | #include <stdlib.h> |
| 54 | #endif |
| 55 | |
| 56 | #ifdef HAVE_UNISTD_H |
| 57 | #include <unistd.h> |
| 58 | #endif |
| 59 | |
| 60 | /* for PATH_MAX */ |
| 61 | #ifdef HAVE_LIMITS_H |
| 62 | #include <limits.h> |
| 63 | #endif |
| 64 | /* for MAXPATHLEN */ |
| 65 | #ifdef HAVE_SYS_PARAM_H |
| 66 | #include <sys/param.h> |
| 67 | #endif |
| 68 | #ifdef PATH_MAX |
| 69 | # define LD_PATHMAX PATH_MAX |
| 70 | #else |
| 71 | # ifdef MAXPATHLEN |
| 72 | # define LD_PATHMAX MAXPATHLEN |
| 73 | # else |
| 74 | # define LD_PATHMAX 1024 |
| 75 | # endif |
| 76 | #endif |
| 77 | |
| 78 | #ifdef HAVE_REALPATH |
| 79 | # define REALPATH(a,b) realpath (a, b) |
| 80 | #else |
| 81 | # define REALPATH(a,b) NULL |
| 82 | #endif |
| 83 | |
| 84 | #ifdef HAVE_UNISTD_H |
| 85 | #include <unistd.h> |
| 86 | #endif |
| 87 | |
| 88 | #ifdef USE_BINARY_FOPEN |
| 89 | #include "fopen-bin.h" |
| 90 | #else |
| 91 | #include "fopen-same.h" |
| 92 | #endif |
| 93 | |
| 94 | #ifdef HAVE_FCNTL_H |
| 95 | #include <fcntl.h> |
| 96 | #else |
| 97 | #ifdef HAVE_SYS_FILE_H |
| 98 | #include <sys/file.h> |
| 99 | #endif |
| 100 | #endif |
| 101 | |
| 102 | #ifdef HAVE_DLFCN_H |
| 103 | #include <dlfcn.h> |
| 104 | #endif |
| 105 | |
| 106 | #ifndef O_RDONLY |
| 107 | #define O_RDONLY 0 |
| 108 | #endif |
| 109 | #ifndef O_WRONLY |
| 110 | #define O_WRONLY 1 |
| 111 | #endif |
| 112 | #ifndef O_RDWR |
| 113 | #define O_RDWR 2 |
| 114 | #endif |
| 115 | #ifndef O_ACCMODE |
| 116 | #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) |
| 117 | #endif |
| 118 | /* Systems that don't already define this, don't need it. */ |
| 119 | #ifndef O_BINARY |
| 120 | #define O_BINARY 0 |
| 121 | #endif |
| 122 | |
| 123 | #ifndef SEEK_SET |
| 124 | #define SEEK_SET 0 |
| 125 | #endif |
| 126 | #ifndef SEEK_CUR |
| 127 | #define SEEK_CUR 1 |
| 128 | #endif |
| 129 | #ifndef SEEK_END |
| 130 | #define SEEK_END 2 |
| 131 | #endif |
| 132 | |
| 133 | #if !HAVE_DECL_STRSTR |
| 134 | extern char *strstr (); |
| 135 | #endif |
| 136 | |
| 137 | #if !HAVE_DECL_FREE |
| 138 | extern void free (); |
| 139 | #endif |
| 140 | |
| 141 | #if !HAVE_DECL_GETENV |
| 142 | extern char *getenv (); |
| 143 | #endif |
| 144 | |
| 145 | #if !HAVE_DECL_ENVIRON |
| 146 | extern char **environ; |
| 147 | #endif |
| 148 | |
| 149 | #endif /* ! defined (LD_SYSDEP_H) */ |