File: config-cpp

package info (click to toggle)
cxref 1.4-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,392 kB
  • ctags: 1,519
  • sloc: ansic: 16,776; sh: 2,233; yacc: 1,906; lex: 377; lisp: 256; makefile: 249; perl: 70
file content (152 lines) | stat: -rwxr-xr-x 3,897 bytes parent folder | download | duplicates (2)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh
#$Header: /home/amb/cxref/cpp/RCS/config-cpp 1.3 1996/11/16 16:03:01 amb Exp $
#
# C Cross Referencing & Documentation tool. Version 1.3
#
# Automatic cxref-cpp Configuration program.
#
# Written by Andrew M. Bishop
#
# This file Copyright 1995,96 Andrew M. Bishop
# It may be distributed under the GNU Public License, version 2, or
# any higher version.  See section COPYING of the GNU Public license
# for conditions under which this file may be redistributed.
#

# Create the Makefile.cpp header.

cat > Makefile.cpp << End-Of-Header
#
# C Cross Referencing & Documentation tool. Version 1.3
#
# CPP Configuration Makefile.
#
# Generated by config-cpp
#
# This file Copyright 1995,96 Andrew M. Bishop
# It may be distributed under the GNU Public License, version 2, or
# any higher version.  See section COPYING of the GNU Public license
# for conditions under which this file may be redistributed.
#
End-Of-Header


# Check that the C compiler is gcc

ok_gcc=yes

[ $CC ] || CC=gcc

echo Checking C compiler CC = $CC for compatability

if hash $CC 2> /dev/null ; then
    $CC -E -v - < /dev/null 2> /tmp/config-cpp.$$ > /dev/null
    ident=`egrep '^GNU CPP' /tmp/config-cpp.$$`

    if [ "$ident" ]; then
        echo '        ' Yes ... $CC looks like GNU C \'$ident\'
    else
        echo '        ' No ... $CC does not look like GNU C
        ok_gcc=no
    fi
else
    echo '        ' Error ... Cannot find command $CC
    ok_gcc=no
fi


# Work out the gcc predefined definitions to compile in.

echo Working out C compiler built in predefines

cat >> Makefile.cpp << End-Of-Predefines

# The predefined macros and answers to questions
# e.g PREDEFINES = -D__GNUC__=2 -D__GNUC_MINOR__=6 -Dunix -D__unix__ -D__unix -Asystem(unix)

End-Of-Predefines

if [ $ok_gcc = yes ]; then
    echo PREDEFINES = `egrep -e -lang-c /tmp/config-cpp.$$ | tr ' ' '\012' | egrep -e '^-[AD]' | tr '\012' ' '` >> Makefile.cpp
else
    echo PREDEFINES = '' >> Makefile.cpp
fi


# Work out the gcc predefined include directories to compile in.

echo Working out C compiler built in include paths

cat >> Makefile.cpp << End-Of-Search-Includes

# The predefined include search directories

End-Of-Search-Includes

if [ $ok_gcc = yes ]; then
    awk '/include <.+> search/,/End of search/ {if(i>0 && i<4)printf("INCLUDE_DIR%d = %s\n",i,$1);i++}' /tmp/config-cpp.$$ >> Makefile.cpp
else
    awk 'BEGIN{for(i=1;i<4;i++)printf("INCLUDE_DIR%d = \n",i);i++}' /dev/null >> Makefile.cpp
fi


# A check of whether we need SVR4 string functions.

echo Checking if the system has the bzero function

svr4_strings=no

cat > test-svr4.c << End-Of-SVR4-String-Test-Program

int main()
{
 bzero(0,0);
}

End-Of-SVR4-String-Test-Program

$CC test-svr4.c -o test-svr4 2> /dev/null || svr4_strings=yes

rm -f test-svr4.c test-svr4

cat >> Makefile.cpp << End-Of-SVR4-Strings

# Set if replacements for bzero, bcmp, bcopy and index, rindex are needed

End-Of-SVR4-Strings

if [ $svr4_strings = yes ]; then
    echo '        ' No ... the bzero function is not present
    echo SVR4_STRINGS = 1 >> Makefile.cpp
else
    echo '        ' Yes ... the bzero function is present
    echo SVR4_STRINGS = 0 >> Makefile.cpp
fi

# A flag to indicate the the configuration status.

cat >> Makefile.cpp << End-Of-Configuration-Status

# The status of the configuration
# Set CONFIG_STATUS to a null value if cxref-cpp is to be built.

End-Of-Configuration-Status

if [ $ok_gcc = yes ]; then
    echo CONFIG_STATUS = >> Makefile.cpp
else
    echo CONFIG_STATUS = \'Configuration Failed\' >> Makefile.cpp
fi


# Tidy up at the end.

if [ $ok_gcc = yes ]; then
    rm /tmp/config-cpp.$$
else
    echo ''
    echo You will need to configure cxref-cpp by hand if you want to use it.
    echo Read cpp/README file for help and edit cpp/Makefile.cpp yourself.
    echo Meanwhile the build of cxref can continue without cxref-cpp.
    exit 1
fi