($(OBJC_O)): Also depend on $(GCC_PASSES).
[gcc.git] / gcc / objc / Make-lang.in
1 # Top level makefile fragment for GNU Objective-C
2 # Copyright (C) 1997 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 # This file provides the language dependent support in the main Makefile.
22 # Each language makefile fragment must provide the following targets:
23 #
24 # foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
25 # foo.info, foo.dvi,
26 # foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
27 # foo.uninstall, foo.distdir,
28 # foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
29 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
30 #
31 # where `foo' is the name of the language.
32 #
33 # It should also provide rules for:
34 #
35 # - making any compiler driver (eg: g++)
36 # - the compiler proper (eg: cc1plus)
37 # - define the names for selecting the language in LANGUAGES.
38 \f
39 # Extra flags to pass to recursive makes.
40 OBJC_FLAGS_TO_PASS = \
41 "OBJC_FOR_BUILD=$(OBJC_FOR_BUILD)" \
42 "OBJCFLAGS=$(OBJCFLAGS)" \
43 "OBJC_FOR_TARGET=$(OBJC_FOR_TARGET)" \
44
45 # Actual names to use when installing a native compiler.
46 #OBJC_INSTALL_NAME = `t='$(program_transform_name)'; echo c++ | sed $$t`
47
48 # Actual names to use when installing a cross-compiler.
49 #OBJC_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++ | sed $$t`
50
51 \f
52 # Define the names for selecting Objective-C in LANGUAGES.
53 OBJC objc: cc1obj objc-runtime
54 OBJECTIVE-C objective-c: cc1obj objc-runtime
55
56 # Tell GNU make to ignore these if they exist.
57 .PHONY: objective-c objc ObjC
58
59 # The Objective C thread file
60 OBJC_THREAD_FILE=thr-$(GCC_THREAD_FILE)
61
62 # C common object files required by Objective C.
63 OBJC_CCOMMON = c-lex.o c-pragma.o c-decl.o c-typeck.o c-convert.o \
64 c-aux-info.o c-common.o c-iterate.o
65
66 # Language-specific object files for Objective C.
67 OBJC_OBJS = objc-parse.o objc-act.o
68
69 cc1obj: $(P) $(OBJC_OBJS) $(OBJC_CCOMMON) $(OBJS) $(BC_OBJS) $(LIBDEPS)
70 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(OBJC_OBJS) $(OBJS) \
71 $(OBJC_CCOMMON) $(BC_OBJS) $(LIBS)
72
73 # Objective C language specific files.
74
75 objc-parse.o : $(srcdir)/objc/objc-parse.c \
76 $(CONFIG_H) $(TREE_H) \
77 $(srcdir)/c-lex.h $(srcdir)/c-tree.h $(srcdir)/input.h \
78 $(srcdir)/flags.h $(srcdir)/objc/objc-act.h
79 $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -I$(srcdir)/objc \
80 -c $(srcdir)/objc/objc-parse.c
81
82 $(srcdir)/objc/objc-parse.c : $(srcdir)/objc/objc-parse.y
83 cd $(srcdir)/objc; \
84 $(BISON) $(BISONFLAGS) objc-parse.y -o objc-parse.c
85
86 $(srcdir)/objc/objc-parse.y: $(srcdir)/c-parse.in
87 echo '/*WARNING: This file is automatically generated!*/' >tmp-objc-prs.y
88 sed -e "/^ifc$$/,/^end ifc$$/d" \
89 -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \
90 $(srcdir)/c-parse.in >>tmp-objc-prs.y
91 $(srcdir)/move-if-change tmp-objc-prs.y $(srcdir)/objc/objc-parse.y
92
93 objc-act.o : $(srcdir)/objc/objc-act.c \
94 $(CONFIG_H) $(TREE_H) $(RTL_H) \
95 $(srcdir)/c-tree.h $(srcdir)/c-lex.h \
96 $(srcdir)/flags.h $(srcdir)/objc/objc-act.h $(srcdir)/input.h \
97 $(srcdir)/function.h $(srcdir)/c-parse.h
98 $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -I$(srcdir)/objc \
99 -c $(srcdir)/objc/objc-act.c
100
101 objc-runtime: objc-headers libobjc.a
102
103 # copy objc header files into build directory
104 objc-headers: stmp-fixinc
105 if [ -d include ]; then true; else mkdir include; fi
106 if [ -d objc ]; then true; else mkdir objc; fi
107 thisdir1=`pwd`; \
108 srcdir1=`cd $(srcdir); pwd`; \
109 cd objc; \
110 if [ -f $${srcdir1}/objc/Makefile ]; then \
111 $(MAKE) -f $${srcdir1}/objc/Makefile copy-headers \
112 srcdir=$${srcdir1} tooldir=$(tooldir) \
113 AR="$(AR)" AR_FLAGS="$(AR_FLAGS)" \
114 GCC_FOR_TARGET="$${thisdir1}/xgcc -B$${thisdir1}/" \
115 GCC_CFLAGS="$(GCC_CFLAGS)" incinstalldir=$${thisdir1}/include; \
116 fi
117 touch objc-headers
118
119 # Objective C runtime library specific files.
120
121 OBJC_O = objc/hash.o objc/sarray.o \
122 objc/class.o objc/sendmsg.o \
123 objc/init.o objc/archive.o \
124 objc/encoding.o objc/selector.o \
125 objc/objects.o objc/misc.o \
126 objc/NXConstStr.o objc/Object.o \
127 objc/Protocol.o objc/nil_method.o \
128 objc/thr.o objc/linking.o \
129 objc/$(OBJC_THREAD_FILE).o
130
131 objc/hash.o: $(srcdir)/objc/hash.c
132 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
133 -c $(srcdir)/objc/hash.c -o $@
134 objc/sarray.o: $(srcdir)/objc/sarray.c
135 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
136 -c $(srcdir)/objc/sarray.c -o $@
137 objc/class.o: $(srcdir)/objc/class.c
138 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
139 -c $(srcdir)/objc/class.c -o $@
140 objc/sendmsg.o: $(srcdir)/objc/sendmsg.c
141 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
142 -c $(srcdir)/objc/sendmsg.c -o $@
143 objc/init.o: $(srcdir)/objc/init.c
144 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
145 -c $(srcdir)/objc/init.c -o $@
146 objc/archive.o: $(srcdir)/objc/archive.c
147 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
148 -c $(srcdir)/objc/archive.c -o $@
149 objc/encoding.o: $(srcdir)/objc/encoding.c
150 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
151 -c $(srcdir)/objc/encoding.c -o $@
152 objc/selector.o: $(srcdir)/objc/selector.c
153 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
154 -c $(srcdir)/objc/selector.c -o $@
155 objc/objects.o: $(srcdir)/objc/objects.c
156 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
157 -c $(srcdir)/objc/objects.c -o $@
158 objc/misc.o: $(srcdir)/objc/misc.c
159 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
160 -c $(srcdir)/objc/misc.c -o $@
161 objc/NXConstStr.o: $(srcdir)/objc/NXConstStr.m
162 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
163 -c $(srcdir)/objc/NXConstStr.m -o $@
164 objc/Object.o: $(srcdir)/objc/Object.m
165 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
166 -c $(srcdir)/objc/Object.m -o $@
167 objc/Protocol.o: $(srcdir)/objc/Protocol.m
168 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
169 -c $(srcdir)/objc/Protocol.m -o $@
170 objc/thr.o: $(srcdir)/objc/thr.h $(srcdir)/objc/thr.c
171 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
172 -c $(srcdir)/objc/thr.c -o $@
173 objc/$(OBJC_THREAD_FILE).o: $(srcdir)/objc/$(OBJC_THREAD_FILE).c
174 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
175 -c $(srcdir)/objc/$(OBJC_THREAD_FILE).c -o $@
176 objc/nil_method.o: $(srcdir)/objc/nil_method.c
177 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
178 -c $(srcdir)/objc/nil_method.c -o $@
179 objc/linking.o: $(srcdir)/objc/linking.m
180 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
181 -c $(srcdir)/objc/linking.m -o $@
182 $(srcdir)/objc/libobjc_entry.o: $(srcdir)/objc/libobjc_entry.c
183 $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
184 -c $(srcdir)/objc/libobjc_entry.c -o $@
185
186 $(OBJC_O): $(GCC_PASSES)
187
188 # Build the Objective C runtime library.
189 libobjc.a: cc1obj specs stmp-int-hdrs libgcc2.ready \
190 $(USE_COLLECT2) $(EXTRA_PARTS) $(OBJC_O)
191 -rm -f libobjc.a
192 $(AR) $(AR_FLAGS) libobjc.a $(OBJC_O)
193 -if $(RANLIB_TEST) ; then $(RANLIB) libobjc.a; else true; fi
194
195 libobjc_s.a: libobjc.a
196 mv libobjc.a libobjc_s.a
197
198 # Create a relocatable DLL
199 libobjc.dll: libobjc_s.a $(srcdir)/objc/libobjc_entry.o
200 $(GCC_FOR_TARGET) -dll -Wl,--base-file -Wl,libobjc.base \
201 -o libobjc.dll libobjc_s.a \
202 $(srcdir)/objc/libobjc_entry.o -lkernel32
203 $(DLLTOOL) --dllname libobjc.dll --def $(srcdir)/objc/libobjc.def \
204 --base-file libobjc.base --output-exp libobjc.exp
205 $(GCC_FOR_TARGET) -dll -Wl,--base-file libobjc.base libobjc.exp \
206 -o libobjc.dll libobjc_s.a \
207 $(srcdir)/objc/libobjc_entry.o -lkernel32
208 $(DLLTOOL) --dllname libobjc.dll --def $(srcdir)/objc/libobjc.def \
209 --base-file libobjc.base --output-exp libobjc.exp
210 $(GCC_FOR_TARGET) libobjc.exp -dll \
211 -o libobjc.dll libobjc_s.a \
212 $(srcdir)/objc/libobjc_entry.o -lkernel32
213 $(DLLTOOL) --dllname libobjc.dll --def $(srcdir)/objc/libobjc.def \
214 --output-lib libobjc.a
215
216 \f
217 # Build hooks:
218
219 objc.all.build:
220 objc.all.cross:
221 objc.start.encap:
222 objc.rest.encap:
223
224 objc.info:
225 objc.dvi:
226
227 \f
228 # Install hooks:
229 # cc1obj is installed elsewhere as part of $(COMPILERS).
230
231 objc.install-normal: installdirs
232 -if [ -f libobjc.a ] ; then \
233 rm -f $(libsubdir)/libobjc.a; \
234 $(INSTALL_DATA) libobjc.a $(libsubdir)/libobjc.a; \
235 if $(RANLIB_TEST) ; then \
236 (cd $(libsubdir); $(RANLIB) libobjc.a); else true; fi; \
237 chmod a-x $(libsubdir)/libobjc.a; \
238 else true; fi
239 -if [ -f libobjc_s.a ] ; then \
240 rm -f $(libsubdir)/libobjc_s.a; \
241 $(INSTALL_DATA) libobjc_s.a $(libsubdir)/libobjc_s.a; \
242 if $(RANLIB_TEST) ; then \
243 (cd $(libsubdir); $(RANLIB) libobjc_s.a); else true; fi; \
244 chmod a-x $(libsubdir)/libobjc_s.a; \
245 else true; fi
246 -if [ -f libobjc.dll ] ; then \
247 rm -f $(bindir)/libobjc.dll; \
248 $(INSTALL_DATA) libobjc.dll $(bindir)/libobjc.dll; \
249 else true; fi
250
251 objc.install-common:
252
253 objc.install-info:
254
255 objc.install-man:
256
257 objc.uninstall:
258 \f
259 # Clean hooks:
260 # A lot of the ancillary files are deleted by the main makefile.
261 # We just have to delete files specific to us.
262 objc.mostlyclean:
263 -rm -f tmp-objc-prs.y
264 -rm -f objc/*$(objext) objc/xforward objc/fflags
265 -rm -f libobjc.a libobjc_s.a libobjc.dll
266 -rm -f libobjc.base libobjc.exp
267 objc.clean: objc.mostlyclean
268 -rm -rf objc-headers
269 objc.distclean:
270 -rm -f objc/Makefile objc/Make-host objc/Make-target
271 -rm -f objc/config.status objc/config.cache
272 -rm -f objc-parse.output
273 objc.extraclean:
274 objc.maintainer-clean:
275 -rm -f objc/objc-parse.y
276 -rm -f objc/objc-parse.c objc/objc-parse.output
277
278 \f
279 # Stage hooks:
280
281 objc.stage1:
282 -mv objc/*$(objext) stage1/objc
283 -mv cc1obj$(exeext) stage1
284 -mv libobjc.a stage1
285 objc.stage2:
286 -mv objc/*$(objext) stage2/objc
287 -mv cc1obj$(exeext) stage2
288 -mv libobjc.a stage2
289 objc.stage3:
290 -mv objc/*$(objext) stage3/objc
291 -mv cc1obj$(exeext) stage3
292 -mv libobjc.a stage3
293 objc.stage4:
294 -mv objc/*$(objext) stage4/objc
295 -mv cc1obj$(exeext) stage4
296 -mv libobjc.a stage4
297
298 \f
299 # Maintenance hooks:
300
301 # This target creates the files that can be rebuilt, but go in the
302 # distribution anyway. It then copies the files to the distdir directory.
303 objc.distdir: