1 # Makefile for GNU compilers.
2 # Copyright (C) 1998, 1999 Free Software Foundation, Inc.
4 #This file is part of GNU CC.
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)
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.
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.
21 # The makefile built from this file lives in the fixinc subdirectory.
22 # Its purpose is to build the any-platforms fixinc.sh script.
25 FIXINC_DEFS = @fixinc_defs@
31 # Directory where sources are, from where we are.
35 # End of variables for you to override.
39 # Now figure out from those variables how to compile and link.
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
45 # Always use -I$(srcdir)/config when compiling.
47 $(CC) -c $(CFLAGS) $(FIXINC_DEFS) $(CPPFLAGS) $(INCLUDES) $<
49 # The only suffixes we want for implicit rules are .c and .o.
55 ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
57 ## Makefile for constructing the "best" include fixer we can
59 ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
61 OBJ = fixincl.o server.o regex.o
62 HDR = server.h regex.h
63 LIBERTY = ../../libiberty/libiberty.a
65 SH_TARGET = inclhack.sh fixincl.sh
67 AG_TEXT = $(SH_TARGET) fixincl.x \
68 inclhack.def inclhack.tpl hackshell.tpl fixincl.tpl
69 TARGETS = $(SH_TARGET) $(BIN_TARGET)
73 gen : $(SH_TARGET) fixincl.x
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 ) > $@ ; \
84 -$(CC) $(CFLAGS) $(FIXINC_DEFS) -DSTDC_HEADERS=1 -c $(srcdir)/regex.c
86 fixincl.o : fixincl.x fixincl.c
87 server.o : server.c server.h
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
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
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
119 rm -f *.o $(TARGETS) fixincl.x
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".
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 ; \
135 echo cp fixincl .. ; \
137 chmod 555 ../fixincl ; \
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 ; \