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.
36 # End of variables for you to override.
40 # Now figure out from those variables how to compile and link.
42 # Specify the directories to be searched for header files.
43 # Both . and srcdir are used, in that order.
44 INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)/../../include
46 # Always use -I$(srcdir)/config when compiling.
48 $(CC) -c $(CFLAGS) $(FIXINC_DEFS) $(CPPFLAGS) $(INCLUDES) $<
50 # The only suffixes we want for implicit rules are .c and .o.
56 ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
58 ## Makefile for constructing the "best" include fixer we can
60 ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
62 OBJ = fixincl.o server.o gnu-regex.o procopen.o
63 HDR = server.h gnu-regex.h
64 LIBERTY = ../../libiberty/libiberty.a
66 SH_TARGET = inclhack.sh fixincl.sh
68 AG_TEXT = $(SH_TARGET) fixincl.x \
69 inclhack.def inclhack.tpl hackshell.tpl fixincl.tpl
70 TARGETS = $(SH_TARGET) $(BIN_TARGET)
74 gen : $(SH_TARGET) fixincl.x
79 @echo $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; \
80 if $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; then : ; else \
81 rm -f $@ ; (echo "#! /bin/sh" ; echo exit 1 ) > $@ ; \
84 gnu-regex.o: gnu-regex.c
85 -$(CC) $(CFLAGS) $(FIXINC_DEFS) $(INCLUDES) -DREGEX_MALLOC \
86 -c $(srcdir)/gnu-regex.c
88 fixincl.o : fixincl.x fixincl.c
89 server.o : server.c server.h
90 procopen.o : procopen.c server.h
92 fixincl.x: fixincl.tpl inclhack.def
93 @if ( autogen --help > /dev/null 2>&1 ) ; then \
94 echo autogen -T fixincl.tpl -b fixincl inclhack.def ; \
95 autogen -T $(srcdir)/fixincl.tpl -b fixincl \
96 $(srcdir)/inclhack.def ; \
97 else echo You need to install autogen ; \
98 if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
100 else touch $@ ; fi ; fi
102 inclhack.sh: inclhack.def inclhack.tpl hackshell.tpl
103 @if ( autogen --help > /dev/null 2>&1 ) ; then \
104 echo autogen inclhack.def ; \
105 autogen -L$(srcdir) $(srcdir)/inclhack.def ; \
106 else echo You need to install autogen ; \
107 if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
108 cp $(srcdir)/$@ . ; \
109 else touch $@ ; fi ; fi
111 fixincl.sh: inclhack.def inclhack.tpl
112 @if ( autogen --help > /dev/null 2>&1 ) ; then \
113 echo autogen -DPROGRAM=1 -b fixincl inclhack.def ; \
114 autogen -DPROGRAM=1 -b fixincl -L$(srcdir) \
115 $(srcdir)/inclhack.def ; touch $@ ; \
116 else echo You need to install autogen ; \
117 if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
118 cp $(srcdir)/$@ . ; \
119 else touch $@ ; fi ; fi
122 rm -f *.o $(TARGETS) fixincl.x
124 # Ensure all the targets are built. If the program "fixincl"
125 # failed to compile, link or load, then we install the
126 # "inclhack.sh" script. Otherwise, we install that program
127 # plus the wrapper script, "fixincl.sh".
130 @rm -f ../fixinc.sh ; \
131 if ( ./fixincl -v > /dev/null 2>&1 ) ; then \
132 echo cp fixincl.sh ../fixinc.sh ; \
133 if [ -f ./fixincl.sh ] ; \
134 then cp fixincl.sh ../fixinc.sh ; \
135 else cp $(srcdir)/fixincl.sh ../fixinc.sh ; fi ; \
136 chmod 555 ../fixinc.sh ; \
138 echo cp fixincl .. ; \
140 chmod 555 ../fixincl ; \
142 echo Could not install binary fixincludes. ; \
143 echo Installing shell script instead. ; \
144 echo cp inclhack.sh ../fixinc.sh ; \
145 if [ -f ./inclhack.sh ] ; \
146 then cp inclhack.sh ../fixinc.sh ; \
147 else cp $(srcdir)/inclhack.sh ../fixinc.sh ; fi ; \
150 Makefile: Makefile.in ../config.status
152 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status