1/* sysdep.h -- handle host dependencies for the GNU linker
2   Copyright 1995, 1996, 1997, 1999, 2002, 2003, 2005, 2007
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#include "config.h"
26
27#include <stdio.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <stdarg.h>
31
32#ifdef HAVE_STRING_H
33#include <string.h>
34#else
35#ifdef HAVE_STRINGS_H
36#include <strings.h>
37#else
38extern char *strchr ();
39extern char *strrchr ();
40#endif
41#endif
42
43#ifdef HAVE_STDLIB_H
44#include <stdlib.h>
45#endif
46
47#ifdef HAVE_UNISTD_H
48#include <unistd.h>
49#endif
50
51/* for PATH_MAX */
52#ifdef HAVE_LIMITS_H
53#include <limits.h>
54#endif
55/* for MAXPATHLEN */
56#ifdef HAVE_SYS_PARAM_H
57#include <sys/param.h>
58#endif
59#ifdef PATH_MAX
60# define LD_PATHMAX PATH_MAX
61#else
62# ifdef MAXPATHLEN
63#  define LD_PATHMAX MAXPATHLEN
64# else
65#  define LD_PATHMAX 1024
66# endif
67#endif
68
69#ifdef HAVE_REALPATH
70# define REALPATH(a,b) realpath (a, b)
71#else
72# define REALPATH(a,b) NULL
73#endif
74
75#ifdef HAVE_UNISTD_H
76#include <unistd.h>
77#endif
78
79#ifdef USE_BINARY_FOPEN
80#include "fopen-bin.h"
81#else
82#include "fopen-same.h"
83#endif
84
85#ifdef HAVE_FCNTL_H
86#include <fcntl.h>
87#else
88#ifdef HAVE_SYS_FILE_H
89#include <sys/file.h>
90#endif
91#endif
92
93#ifdef HAVE_DLFCN_H
94#include <dlfcn.h>
95#endif
96
97#ifndef O_RDONLY
98#define O_RDONLY 0
99#endif
100#ifndef O_WRONLY
101#define O_WRONLY 1
102#endif
103#ifndef O_RDWR
104#define O_RDWR 2
105#endif
106#ifndef O_ACCMODE
107#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
108#endif
109/* Systems that don't already define this, don't need it.  */
110#ifndef O_BINARY
111#define O_BINARY 0
112#endif
113
114#ifndef SEEK_SET
115#define SEEK_SET 0
116#endif
117#ifndef SEEK_CUR
118#define SEEK_CUR 1
119#endif
120#ifndef SEEK_END
121#define SEEK_END 2
122#endif
123
124#if !HAVE_DECL_STRSTR
125extern char *strstr ();
126#endif
127
128#if !HAVE_DECL_FREE
129extern void free ();
130#endif
131
132#if !HAVE_DECL_GETENV
133extern char *getenv ();
134#endif
135
136#if !HAVE_DECL_ENVIRON
137extern char **environ;
138#endif
139
140#endif /* ! defined (LD_SYSDEP_H) */
141