OSDN Git Service

Merge from fixincl-branch
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / Makefile.in
1 # Makefile for GNU compilers.
2 #   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
3
4 #This file is part of GNU CC.
5
6 #GNU CC is free software; you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation; either version 2, or (at your option)
9 #any later version.
10
11 #GNU CC is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #GNU General Public License for more details.
15
16 #You should have received a copy of the GNU General Public License
17 #along with GNU CC; see the file COPYING.  If not, write to
18 #the Free Software Foundation, 59 Temple Place - Suite 330,
19 #Boston, MA 02111-1307, USA.
20
21 # The makefile built from this file lives in the fixinc subdirectory.
22 # Its purpose is to build the any-platforms fixinc.sh script.
23
24 CFLAGS = -g
25 FIXINC_DEFS = @fixinc_defs@
26
27 CC = @CC@
28 SHELL = /bin/sh
29
30 target=@target@
31 # Directory where sources are, from where we are.
32 srcdir = @srcdir@
33 VPATH = @srcdir@
34
35 # End of variables for you to override.
36
37 default : gen
38
39 # Now figure out from those variables how to compile and link.
40
41 # Specify the directories to be searched for header files.
42 # Both . and srcdir are used, in that order.
43 INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)/../../include
44
45 # Always use -I$(srcdir)/config when compiling.
46 .c.o:
47         $(CC) -c $(CFLAGS) $(FIXINC_DEFS) $(CPPFLAGS) $(INCLUDES) $<
48
49 # The only suffixes we want for implicit rules are .c and .o.
50 .SUFFIXES:
51 .SUFFIXES: .c .o
52
53 #\f
54
55 ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
56 ##
57 ##  Makefile for constructing the "best" include fixer we can
58 ##
59 ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
60
61 OBJ = fixincl.o server.o regex.o
62 HDR = server.h regex.h
63 LIBERTY = ../../libiberty/libiberty.a
64
65 SH_TARGET  = inclhack.sh fixincl.sh
66 BIN_TARGET = fixincl
67 AG_TEXT    = $(SH_TARGET) fixincl.x \
68         inclhack.def inclhack.tpl hackshell.tpl fixincl.tpl
69 TARGETS    = $(SH_TARGET) $(BIN_TARGET)
70
71 all : $(TARGETS)
72 sh  : $(SH_TARGET)
73 gen : $(SH_TARGET) fixincl.x
74
75 $(OBJ): $(HDR)
76
77 fixincl: $(OBJ)
78         @echo $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; \
79         if $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; then : ; else \
80         rm -f $@ ; (echo "#! /bin/sh" ; echo exit 1 ) > $@ ; \
81         chmod 777 $@ ; fi
82
83 regex.o: regex.c
84         -$(CC) $(CFLAGS) $(FIXINC_DEFS) -DSTDC_HEADERS=1 -c $(srcdir)/regex.c
85
86 fixincl.o : fixincl.x fixincl.c
87 server.o : server.c server.h
88
89 fixincl.x: fixincl.tpl inclhack.def
90         @if ( autogen --help > /dev/null 2>&1 ) ; then \
91                 echo autogen -T fixincl.tpl -b fixincl inclhack.def ; \
92                 autogen -T $(srcdir)/fixincl.tpl -b fixincl \
93                         $(srcdir)/inclhack.def ; \
94         else echo You need to install autogen ; \
95                 if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
96                         $(CP) $(srcdir)/$@ . ; \
97                 else touch $@ ; fi ; fi
98
99 inclhack.sh: inclhack.def inclhack.tpl hackshell.tpl
100         @if ( autogen --help > /dev/null 2>&1 ) ; then \
101                 echo autogen inclhack.def ; \
102                 autogen -L$(srcdir) $(srcdir)/inclhack.def ; \
103         else echo You need to install autogen ; \
104                 if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
105                         $(CP) $(srcdir)/$@ . ; \
106                 else touch $@ ; fi ; fi
107
108 fixincl.sh: inclhack.def inclhack.tpl
109         @if ( autogen --help > /dev/null 2>&1 ) ; then \
110                 echo autogen -DPROGRAM=1 -b fixincl inclhack.def ; \
111                 autogen -DPROGRAM=1 -b fixincl -L$(srcdir) \
112                         $(srcdir)/inclhack.def ; touch $@ ; \
113         else echo You need to install autogen ; \
114                 if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
115                         $(CP) $(srcdir)/$@ . ; \
116                 else touch $@ ; fi ; fi
117
118 clean:
119         rm -f *.o $(TARGETS) fixincl.x
120
121 #  Ensure all the targets are built.  If the program "fixincl"
122 #  failed to compile, link or load, then we install the
123 #  "inclhack.sh" script.  Otherwise, we install that program
124 #  plus the wrapper script, "fixincl.sh".
125 #
126 install: $(TARGETS)
127         @rm -f ../fixinc.sh ; \
128         if ( ./fixincl -v > /dev/null 2>&1 ) ; then \
129                 echo cp fixincl.sh ../fixinc.sh ; \
130                 if [ -f ./fixincl.sh ] ; \
131                 then cp fixincl.sh ../fixinc.sh ; \
132                 else cp $(srcdir)/fixincl.sh ../fixinc.sh ; fi ; \
133                 chmod 555 ../fixinc.sh ; \
134                 rm -f ../fixincl ; \
135                 echo cp fixincl .. ; \
136                 cp fixincl .. ; \
137                 chmod 555 ../fixincl ; \
138         else \
139                 echo Could not install binary fixincludes.  ; \
140                 echo Installing shell script instead. ; \
141                 echo cp inclhack.sh ../fixinc.sh ; \
142                 if [ -f ./inclhack.sh ] ; \
143                 then cp inclhack.sh ../fixinc.sh ; \
144                 else cp $(srcdir)/inclhack.sh ../fixinc.sh ; fi ; \
145         fi