summaryrefslogtreecommitdiff
path: root/bootstrap.sh
blob: 4d0a0bd7bbdd9b6fb2d0f0432dcacd051af3f7e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#! /bin/sh

# edit this to taste; note that you can also override via the environment:
case "$CC" in
  "") CC=cc
esac

if test -f config.h; then :; else
  echo "Creating basic config.h..."
  cat >config.h <<'END_OF_CONFIG_H'
/* A bootstrap version of config.h, for systems which can't
   auto-configure due to a lack of a working sed.  If you are on
   a sufficiently odd machine you may need to hand-tweak this file.

   Regardless, once you get a working version of sed you really should
   re-build starting with a run of "configure", as the bootstrap
   version is almost certainly more crippled than it needs to be on
   your machine.
*/

#define PACKAGE "sed"
#define VERSION "4.1c-boot"
#define SED_FEATURE_VERSION "4.2"
#define BOOTSTRAP 1

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

/* Define if your compiler/headers don't support const. */
#undef const
#define __getopt_argv_const const

/* Define if headers have no definition.  */
/* #define mbstate_t int */
#define HAVE_WCHAR_H 1
#define HAVE_MBRTOWC 1

/* Toggle if you encounter errors in lib/mkstemp.c.  */
#define HAVE_UNISTD_H 1
#define HAVE_FCNTL_H 1
#undef HAVE_SYS_FILE_H
#undef HAVE_IO_H

/* All other config.h.in options intentionally omitted.  Report as a
   bug if you need extra "#define"s in here. */
END_OF_CONFIG_H

  cat > conftest.c << \EOF
#define size_t unsigned
#include <sys/types.h>
#include <stdio.h>

size_t s;
EOF
  if $CC -c conftest.c -o conftest.o > /dev/null 2>&1 ; then
    echo '#define size_t unsigned' >> config.h
    echo checking for size_t... no
  else
    echo checking for size_t... yes
  fi

  cat > conftest.c << \EOF
#define ssize_t int
#include <sys/types.h>
#include <stdio.h>

ssize_t s;
EOF
  if $CC -c conftest.c -o conftest.o > /dev/null 2>&1 ; then
    echo '#define ssize_t int' >> config.h
    echo checking for ssize_t... no
  else
    echo checking for ssize_t... yes
  fi

  cat > conftest.c << \EOF
void *foo;

EOF
  if $CC -c conftest.c -o conftest.o > /dev/null 2>&1 ; then
    echo checking for void *... yes
  else
    echo '#define VOID char' >> config.h
    echo checking for void *... no
  fi

  rm -f conftest.*
fi

# tell the user what we're doing from here on...
set -x -e

# the ``|| exit 1''s are for fail-stop; set -e doesn't work on some systems

rm -f lib/*.o sed/*.o sed/sed
cd lib || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c acl.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c alloca.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c error.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c exitfail.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c getdelim.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c getline.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c getopt.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c getopt1.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c malloc.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c mbchar.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c memchr.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c memcmp.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c memmove.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c mkstemp.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c obstack.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c quote.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c quotearg.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c regex.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c strcasecmp.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c strerror.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c strncasecmp.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c strnlen1.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c strverscmp.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c tempname.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c xalloc-die.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c xmalloc.c || exit 1

cd ../sed || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c sed.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c fmt.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c compile.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c execute.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c mbcs.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regexp.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c utils.c || exit 1

${CC} -o sed *.o ../lib/*.o || exit 1