1 # GDC -- D front-end for GCC
2 # Copyright (C) 2004 David Friedman
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 AUTOMAKE_OPTIONS = 1.9.4 foreign no-dependencies
20 ACLOCAL_AMFLAGS = -I . -I ..
22 OUR_CFLAGS=@DEFS@ -I . -I $(srcdir)/gcc
23 D_EXTRA_DFLAGS=-nostdinc -pipe
24 ALL_DFLAGS = $(DFLAGS) $(D_GC_FLAGS) $(D_EXTRA_DFLAGS) $(MULTIFLAGS)
26 toolexecdir = $(phobos_toolexecdir)
27 toolexeclibdir = $(phobos_toolexeclibdir)
29 config_d_src =$(host_alias)/gcc/config/config.d
30 config_libc_d_src =$(host_alias)/gcc/config/libc.d
31 config_errno_d_src =$(host_alias)/gcc/config/errno.d
32 config_fpcls_d_src =$(host_alias)/gcc/config/fpcls.d
33 config_mathfuncs_d_src=$(host_alias)/gcc/config/mathfuncs.d
34 config_unix_d_src =$(host_alias)/gcc/config/unix.d
36 X3=CC_FOR_BUILD="$(CC_FOR_BUILD) -I $(srcdir)/config" BUILD_LIBIBERTY=$(BUILD_LIBIBERTY) $(srcdir)/config/x3
37 X3_GCC_COMMAND=$(CC) $(OUR_CFLAGS)
38 X3_DEPS=config/x3.o config/x3main.o
40 config/x3.o: config/x3.c config/x3.h
41 $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -g -Wall -I $(LIBIBERTY_H_PATH) -c -o $@ $<
43 config/x3main.o: config/x3main.c config/x3.h
44 $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -g -Wall -c -o $@ $<
46 all-local: libgphobos2.a
50 %.o : %.d $(D_PREREQ_SRCS)
51 $(GDC) -o $@ $(ALL_DFLAGS) \
52 -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
55 # Use .c.o to override Automake
57 $(CC) -o $@ $(OUR_CFLAGS) $(CFLAGS) -c $<
59 # boxer is currently broken
60 std/boxer.t.o: std/boxer.o
63 %.t.o : %.d $(D_PREREQ_SRCS)
64 $(GDC) -o $@ $(ALL_DFLAGS) -fno-release -funittest -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
66 internal/gc/gcx.t.o: $(D_PREREQ_SRCS) $(srcdir)/internal/gc/gcx.d
67 $(GDC) -o $@ $(ALL_DFLAGS) -funittest -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
72 unittest: unittest.o libgphobos2_t.a libgphobos2.a
73 $(GDC) -o $@ $(CFLAGS) unittest.o -L./ -lgphobos2_t $(LIBS)
75 internal/gc/testgc.o: $(config_d_src) $(srcdir)/internal/gc/testgc.d
76 $(GDC) -o $@ $(ALL_DFLAGS) -fno-release -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $(srcdir)/internal/gc/testgc.d
78 testgc: internal/gc/testgc.o libgphobos2_t.a libgphobos2.a
79 $(GDC) -o $@ $(ALL_DFLAGS) internal/gc/testgc.o -L./ -lgphobos2_t $(LIBS)
81 TI=ti_AC.o ti_Ag.o ti_Aint.o ti_Along.o ti_Ashort.o \
83 ti_byte.o ti_cdouble.o ti_cfloat.o ti_char.o ti_creal.o \
84 ti_dchar.o ti_delegate.o ti_double.o ti_float.o ti_idouble.o ti_ifloat.o \
85 ti_int.o ti_ireal.o ti_long.o ti_ptr.o ti_real.o ti_short.o ti_ubyte.o \
86 ti_uint.o ti_ulong.o ti_ushort.o ti_wchar.o \
87 ti_Afloat.o ti_Adouble.o ti_Areal.o \
88 ti_Acfloat.o ti_Acdouble.o ti_Acreal.o \
91 MAIN_OBJS=std/asserterror.o std/hiddenfunc.o internal/switch.o gcstats.o \
92 internal/critical.o internal/object.o internal/monitor.o internal/arraycat.o internal/invariant.o \
93 internal/arrayassign.o internal/aaA.o internal/adi.o internal/aApply.o internal/aApplyR.o \
94 std/outofmemory.o std/compiler.o std/system.o std/moduleinit.o std/md5.o std/base64.o \
95 internal/cast.o std/string.o internal/memset.o std/math.o \
96 std/outbuffer.o std/ctype.o std/regexp.o std/random.o \
97 std/stream.o std/cstream.o std/switcherr.o std/array.o std/gc.o \
98 internal/qsortg.o std/thread.o internal/obj.o std/utf.o std/uri.o \
99 crc32.o std/conv.o internal/arraycast.o errno.o \
100 std/syserror.o std/metastrings.o \
101 std/c/stdarg.o std/c/stdio.o std/stdio.o std/format.o \
102 std/openrj.o std/uni.o std/demangle.o std/bitarray.o \
103 $(subst ti_,std/typeinfo/ti_,$(TI)) \
104 std/date.o std/dateparse.o etc/c/zlib.o std/zlib.o std/zip.o \
105 internal/dgccmain2.o internal/rundmain.o std/stdarg.o \
106 std/signals.o std/cpuid.o std/traits.o std/typetuple.o std/bind.o \
107 gcc/builtins.o gcc/config/mathfuncs.o \
108 std/algorithm.o std/bitmanip.o std/contracts.o std/functional.o \
109 std/getopt.o std/numeric.o std/slist.o std/typecons.o std/variant.o \
110 std/cover.o std/complex.o std/encoding.o std/iterator.o std/xml.o \
113 # This should not be linked into a shared library.
114 CMAIN_OBJS=internal/cmain.o
116 ZLIB_OBJS= etc/c/zlib/adler32.o etc/c/zlib/compress.o \
117 etc/c/zlib/crc32.o etc/c/zlib/gzio.o \
118 etc/c/zlib/uncompr.o etc/c/zlib/deflate.o \
119 etc/c/zlib/trees.o etc/c/zlib/zutil.o \
120 etc/c/zlib/inflate.o etc/c/zlib/infback.o \
121 etc/c/zlib/inftrees.o etc/c/zlib/inffast.o
123 GC_OBJS= internal/gc/gc.o internal/gc/gcx.o \
125 GC_OBJS += @D_GC_MODULES@
127 GCC_OBJS = gcc/unwind_pe.o gcc/deh.o gcc/threadsem.o \
128 gcc/cbridge_time.o gcc/cbridge_strerror.o
130 # modules which require some kind of operating system
131 OS_OBJS = std/file.o std/mmfile.o std/path.o std/perf.o std/process.o std/socket.o std/socketstream.o
133 # std.c.linux.linux, std.loader, gcc.cbridge*
134 WINDOWS_OBJS=std/c/windows/windows.o std/c/windows/com.o std/c/windows/winsock.o \
135 std/windows/iunknown.o std/windows/registry.o std/windows/syserror.o \
136 std/windows/charset.o
137 # D_EXTRA_OBJS=@D_EXTRA_OBJS@
139 # needed until instrinsics are implemented
140 D_EXTRA_OBJS+=std/intrinsic.o
142 D_EXTRA_OBJS+=gcc/support.o
144 gen_config1: config/gen_config1.o
145 $(CC) $(CFLAGS) -o $@ $^
147 $(config_d_src): frag-ac stamp-tgtdir
150 $(config_libc_d_src): config/libc.x3 $(X3_DEPS) stamp-tgtdir
151 $(X3) $< -o $@ $(X3_GCC_COMMAND)
153 $(config_errno_d_src): config/errno.x3 $(X3_DEPS) stamp-tgtdir
154 $(X3) $< -o $@ $(X3_GCC_COMMAND)
156 $(config_fpcls_d_src): config/fpcls.x3 $(X3_DEPS) stamp-tgtdir
157 $(X3) $< -o $@ $(X3_GCC_COMMAND)
159 $(config_mathfuncs_d_src): frag-math stamp-tgtdir
162 $(config_unix_d_src): config/unix.x3 $(X3_DEPS) stamp-tgtdir
163 $(X3) $< -o $@ $(X3_GCC_COMMAND)
165 # because these are in the $(host_alias) subdir, pattern match rules will not work
166 gcc/config/unix.o: $(config_unix_d_src) $(config_d_src) $(config_libc_d_src)
167 $(GDC) -o $@ $(ALL_DFLAGS) -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
168 gcc/config/unix.t.o: gcc/config/unix.o
171 gcc/config/mathfuncs.o: $(config_mathfuncs_d_src) $(config_d_src) $(config_libc_d_src)
172 $(GDC) -o $@ $(ALL_DFLAGS) -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
173 gcc/config/mathfuncs.t.o: gcc/config/mathfuncs.o
176 gcc/cbridge_math.o: gcc/cbridge_math.c
177 $(CC) -o $@ $(OUR_CFLAGS) $(CFLAGS) -fno-strict-aliasing -c $<
179 std/stream.o: std/stream.d $(D_PREREQ_SRCS)
180 $(GDC) -o $@ $(ALL_DFLAGS) -fdeprecated -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
181 std/stream.t.o: std/stream.d $(D_PREREQ_SRCS)
182 $(GDC) -o $@ $(ALL_DFLAGS) -fdeprecated -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
184 ALL_PHOBOS_OBJS = $(D_EXTRA_OBJS) $(GCC_OBJS) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(WEAK_OBJS)
186 libgphobos2.a : $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
187 $(AR) -r $@ $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
190 libgphobos2_t.a : $(ALL_PHOBOS_OBJS:.o=.t.o) $(CMAIN_OBJS)
191 $(AR) -r $@ $(ALL_PHOBOS_OBJS:.o=.t.o) $(CMAIN_OBJS)
194 # This has to be an empty file because it is included in the prerequisites of rules
195 # that use "cat $^" to generate their targets.
198 mkdir -p $(host_alias)/gcc/config
201 check-local: unittest testgc
205 install-exec-local: $(D_PREREQ_SRCS) libgphobos2.a
206 $(mkinstalldirs) $(DESTDIR)$(toolexeclibdir)
207 $(INSTALL) libgphobos2.a $(DESTDIR)$(toolexeclibdir)
208 $(RANLIB) $(DESTDIR)$(toolexeclibdir)/libgphobos2.a
210 install-data-local: $(D_PREREQ_SRCS) libgphobos2.a
214 std/c/darwin std/c/linux std/c/mach std/c/skyos std/c/unix std/c/windows \
215 std/typeinfo std/windows; do \
216 $(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$$i; \
217 for f in $(srcdir)/$$i/*.[hd]; do $(INSTALL_HEADER) $$f $(DESTDIR)$(gdc_include_dir)/$$i; done; \
219 for i in crc32.d gcstats.d object.d; do \
220 $(INSTALL_HEADER) $(srcdir)/$$i $(DESTDIR)$(gdc_include_dir); done
221 $(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)/gcc/config
222 for i in $(host_alias)/gcc/config/*.d ; \
223 do $(INSTALL_HEADER) $$i $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)/gcc/config; done
224 $(INSTALL) phobos-ver-syms $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)
227 rm -f $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
228 rm -f $(ALL_PHOBOS_OBJS:.o=.t.o)
229 rm -f unittest.o internal/gc/testgc.o
230 rm -f unittest$(EXEEXT) testgc$(EXEEXT)
231 rm -f $(config_d_src) $(config_errno_d_src) $(config_libc_d_src)
232 rm -f $(config_unix_d_src)
234 rm -f libgphobos2_t.a
237 # Work around what appears to be a GNU make bug handling MAKEFLAGS
238 # values defined in terms of make variables, as is the case for CC and
239 # friends when we are called from the top level Makefile.
241 "AR_FLAGS=$(AR_FLAGS)" \
242 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
243 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
245 "CXXFLAGS=$(CXXFLAGS)" \
246 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
247 "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
248 "INSTALL=$(INSTALL)" \
249 "INSTALL_DATA=$(INSTALL_DATA)" \
250 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
251 "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
252 "LDFLAGS=$(LDFLAGS)" \
253 "LIBCFLAGS=$(LIBCFLAGS)" \
254 "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
256 "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
257 "PICFLAG=$(PICFLAG)" \
258 "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
260 "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
261 "exec_prefix=$(exec_prefix)" \
262 "infodir=$(infodir)" \
264 "includedir=$(includedir)" \
266 "tooldir=$(tooldir)" \
267 "gdc_include_dir=$(gdc_include_dir)" \
273 "NM_FOR_BUILD=$(NM_FOR_BUILD)" \
274 "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
275 "DESTDIR=$(DESTDIR)" \
278 # Subdir rules rely on $(FLAGS_TO_PASS)
279 FLAGS_TO_PASS = $(AM_MAKEFLAGS)