1# Makefile for GCC fixincludes.
2#
3#   Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
4
5#This file is part of GCC.
6
7#GCC is free software; you can redistribute it and/or modify
8#it under the terms of the GNU General Public License as published by
9#the Free Software Foundation; either version 2, or (at your option)
10#any later version.
11
12#GCC is distributed in the hope that it will be useful,
13#but WITHOUT ANY WARRANTY; without even the implied warranty of
14#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#GNU General Public License for more details.
16
17#You should have received a copy of the GNU General Public License
18#along with GCC; see the file COPYING.  If not, write to
19#the Free Software Foundation, 59 Temple Place - Suite 330,
20#Boston, MA 02111-1307, USA.
21
22# The makefile built from this file lives in the fixinc subdirectory.
23# Its purpose is to build the any-platforms fixinc.sh script.
24
25SHELL=@SHELL@
26
27# Some versions of `touch' (such as the version on Solaris 2.8)
28# do not correctly set the timestamp due to buggy versions of `utime'
29# in the kernel.  So, we use `echo' instead.
30STAMP = echo timestamp >
31
32FL_LIST = $(CFLAGS) $(CPPFLAGS) $(WARN_CFLAGS)
33FIXINC_DEFS = -DIN_GCC -DHAVE_CONFIG_H $(FL_LIST) $(INCLUDES)
34
35# Directory where sources are, from where we are.
36srcdir = @srcdir@
37VPATH = $(srcdir)
38subdir = fixinc
39
40# End of variables for you to override.
41
42default : all
43
44# Now figure out from those variables how to compile and link.
45
46# Specify the directories to be searched for header files.
47# Both . and srcdir are used, in that order.
48#
49INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. \
50-I$(srcdir)/../config -I$(srcdir)/../../include
51
52# Always use -I$(srcdir)/config when compiling.
53.c.o:
54	$(CC) -c $(FIXINC_DEFS) $<
55
56# The only suffixes we want for implicit rules are .c and .o.
57.SUFFIXES:
58.SUFFIXES: .c .o
59
60#
61
62## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
63##
64##  Makefile for constructing the "best" include fixer we can
65##
66## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
67
68LIBERTY = ../../libiberty/libiberty.a
69
70ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
71      fixlib.o
72
73TESTOBJ = fixincl.o fixlib.o fixtests.o
74FIXOBJ  = fixfixes.o fixlib.o
75
76HDR = server.h fixlib.h machname.h
77FI  = fixincl@build_exeext@
78AF  = applyfix@build_exeext@
79
80all : $(TARGETS)
81gen : $(srcdir)/fixincl.x
82
83oneprocess : full-stamp
84twoprocess : test-stamp $(AF)
85
86full-stamp : $(ALLOBJ) $(LIBERTY)
87	$(CC) $(FIXINC_DEFS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBERTY)
88	$(STAMP) $@
89
90test-stamp : $(TESTOBJ) $(LIBERTY)
91	$(CC) $(FIXINC_DEFS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBERTY)
92	$(STAMP) $@
93
94$(AF): $(FIXOBJ) $(LIBERTY)
95	$(CC) $(FIXINC_DEFS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBERTY)
96
97# String length warnings
98fixincl.o-warn = -Wno-error
99
100$(ALLOBJ)   : $(HDR)
101fixincl.o   : fixincl.c  $(srcdir)/fixincl.x
102fixtests.o  : fixtests.c
103fixfixes.o  : fixfixes.c $(srcdir)/fixincl.x
104server.o    : server.c
105procopen.o  : procopen.c
106fixlib.o    : fixlib.c
107
108#  'machname.h' is built in the build directory.
109#  'fixincl.x' in the source dir.
110#
111machname.h: ../specs
112	$(SHELL) $(srcdir)/genfixes $@
113
114$(srcdir)/fixincl.x: @MAINT@ fixincl.tpl inclhack.def
115	cd $(srcdir) ; $(SHELL) ./genfixes $@
116
117clean:
118	rm -f *.o *-stamp $(AF) $(FI) machname.h *~
119
120maintainer-clean : clean
121	rm -f $(srcdir)/fixincl.x
122
123#  Build the executable and copy up into gcc dir.
124#  We still copy the script because we still have alternative scripts.
125#
126install-bin : $(TARGETS)
127	./fixincl -v < /dev/null
128	@if [ -f ../fixinc.sh ] ; then rm -f ../fixinc.sh || \
129	    mv -f ../fixinc.sh ../fixinc.sh.$$ || exit 1 ; else : ; fi
130	@cp $(srcdir)/fixincl.sh ../fixinc.sh
131	chmod 755 ../fixinc.sh
132
133Makefile: Makefile.in ../config.status
134	cd .. \
135	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
136	  $(SHELL) ./config.status
137
138check : $(TARGETS)
139	autogen -T $(srcdir)/check.tpl $(srcdir)/inclhack.def
140	$(SHELL) ./check.sh $(srcdir)/tests/base
141	@rm -f ./check.sh
142