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: libgphobos.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 libgphobos_t.a libgphobos.a
73 $(GDC) -o $@ $(CFLAGS) unittest.o -L./ -lgphobos_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 libgphobos_t.a libgphobos.a
79 $(GDC) -o $@ $(ALL_DFLAGS) internal/gc/testgc.o -L./ -lgphobos_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 internal/switch.o gcstats.o \
92 internal/critical.o internal/object.o internal/monitor.o internal/arraycat.o internal/invariant.o \
93 std/outofmemory.o internal/aaA.o internal/adi.o internal/aApply.o internal/aApplyR.o \
94 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/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 std/math2.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
109 # This should not be linked into a shared library.
110 CMAIN_OBJS=internal/cmain.o
112 ZLIB_OBJS= etc/c/zlib/adler32.o etc/c/zlib/compress.o \
113 etc/c/zlib/crc32.o etc/c/zlib/gzio.o \
114 etc/c/zlib/uncompr.o etc/c/zlib/deflate.o \
115 etc/c/zlib/trees.o etc/c/zlib/zutil.o \
116 etc/c/zlib/inflate.o etc/c/zlib/infback.o \
117 etc/c/zlib/inftrees.o etc/c/zlib/inffast.o
119 GC_OBJS= internal/gc/gc.o internal/gc/gcx.o \
121 GC_OBJS += @D_GC_MODULES@
123 GCC_OBJS = gcc/unwind_pe.o gcc/deh.o gcc/threadsem.o \
124 gcc/cbridge_time.o gcc/cbridge_strerror.o
126 # modules which require some kind of operating system
127 OS_OBJS = std/file.o std/mmfile.o std/path.o std/perf.o std/process.o std/socket.o std/socketstream.o
129 # std.c.linux.linux, std.loader, gcc.cbridge*
130 WINDOWS_OBJS=std/c/windows/windows.o std/c/windows/com.o std/c/windows/winsock.o \
131 std/windows/iunknown.o std/windows/registry.o std/windows/syserror.o \
132 std/windows/charset.o
133 # D_EXTRA_OBJS=@D_EXTRA_OBJS@
135 # needed until instrinsics are implemented
136 D_EXTRA_OBJS+=std/intrinsic.o
138 D_EXTRA_OBJS+=gcc/support.o
140 gen_config1: config/gen_config1.o
141 $(CC) $(CFLAGS) -o $@ $^
143 $(config_d_src): frag-ac stamp-tgtdir
146 $(config_libc_d_src): config/libc.x3 $(X3_DEPS) stamp-tgtdir
147 $(X3) $< -o $@ $(X3_GCC_COMMAND)
149 $(config_errno_d_src): config/errno.x3 $(X3_DEPS) stamp-tgtdir
150 $(X3) $< -o $@ $(X3_GCC_COMMAND)
152 $(config_fpcls_d_src): config/fpcls.x3 $(X3_DEPS) stamp-tgtdir
153 $(X3) $< -o $@ $(X3_GCC_COMMAND)
155 $(config_mathfuncs_d_src): frag-math stamp-tgtdir
158 $(config_unix_d_src): config/unix.x3 $(X3_DEPS) stamp-tgtdir
159 $(X3) $< -o $@ $(X3_GCC_COMMAND)
161 # because these are in the $(host_alias) subdir, pattern match rules will not work
162 gcc/config/unix.o: $(config_unix_d_src) $(config_d_src) $(config_libc_d_src)
163 $(GDC) -o $@ $(ALL_DFLAGS) -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
164 gcc/config/unix.t.o: gcc/config/unix.o
167 gcc/config/mathfuncs.o: $(config_mathfuncs_d_src) $(config_d_src) $(config_libc_d_src)
168 $(GDC) -o $@ $(ALL_DFLAGS) -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
169 gcc/config/mathfuncs.t.o: gcc/config/mathfuncs.o
172 gcc/cbridge_math.o: gcc/cbridge_math.c
173 $(CC) -o $@ $(OUR_CFLAGS) $(CFLAGS) -fno-strict-aliasing -c $<
175 std/stream.o: std/stream.d $(D_PREREQ_SRCS)
176 $(GDC) -o $@ $(ALL_DFLAGS) -fdeprecated -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
177 std/stream.t.o: std/stream.d $(D_PREREQ_SRCS)
178 $(GDC) -o $@ $(ALL_DFLAGS) -fdeprecated -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host_alias) -c $<
180 ALL_PHOBOS_OBJS = $(D_EXTRA_OBJS) $(GCC_OBJS) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(WEAK_OBJS)
182 libgphobos.a : $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
183 $(AR) -r $@ $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
186 libgphobos_t.a : $(ALL_PHOBOS_OBJS:.o=.t.o) $(CMAIN_OBJS)
187 $(AR) -r $@ $(ALL_PHOBOS_OBJS:.o=.t.o) $(CMAIN_OBJS)
190 # This has to be an empty file because it is included in the prerequisites of rules
191 # that use "cat $^" to generate their targets.
194 mkdir -p $(host_alias)/gcc/config
197 check-local: unittest testgc
201 install-exec-local: $(D_PREREQ_SRCS) libgphobos.a
202 $(mkinstalldirs) $(DESTDIR)$(toolexeclibdir)
203 $(INSTALL) libgphobos.a $(DESTDIR)$(toolexeclibdir)
204 $(RANLIB) $(DESTDIR)$(toolexeclibdir)/libgphobos.a
206 install-data-local: $(D_PREREQ_SRCS) libgphobos.a
210 std/c/darwin std/c/linux std/c/mach std/c/skyos std/c/unix std/c/windows \
211 std/typeinfo std/windows; do \
212 $(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$$i; \
213 for f in $(srcdir)/$$i/*.[hd]; do $(INSTALL_HEADER) $$f $(DESTDIR)$(gdc_include_dir)/$$i; done; \
215 for i in crc32.d gcstats.d object.d; do \
216 $(INSTALL_HEADER) $(srcdir)/$$i $(DESTDIR)$(gdc_include_dir); done
217 $(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)/gcc/config
218 for i in $(host_alias)/gcc/config/*.d ; \
219 do $(INSTALL_HEADER) $$i $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)/gcc/config; done
220 $(INSTALL) phobos-ver-syms $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)
223 rm -f $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
224 rm -f $(ALL_PHOBOS_OBJS:.o=.t.o)
225 rm -f unittest.o internal/gc/testgc.o
226 rm -f unittest$(EXEEXT) testgc$(EXEEXT)
227 rm -f $(config_d_src) $(config_errno_d_src) $(config_libc_d_src)
228 rm -f $(config_unix_d_src)
233 # Work around what appears to be a GNU make bug handling MAKEFLAGS
234 # values defined in terms of make variables, as is the case for CC and
235 # friends when we are called from the top level Makefile.
237 "AR_FLAGS=$(AR_FLAGS)" \
238 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
239 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
241 "CXXFLAGS=$(CXXFLAGS)" \
242 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
243 "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
244 "INSTALL=$(INSTALL)" \
245 "INSTALL_DATA=$(INSTALL_DATA)" \
246 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
247 "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
248 "LDFLAGS=$(LDFLAGS)" \
249 "LIBCFLAGS=$(LIBCFLAGS)" \
250 "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
252 "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
253 "PICFLAG=$(PICFLAG)" \
254 "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
256 "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
257 "exec_prefix=$(exec_prefix)" \
258 "infodir=$(infodir)" \
260 "includedir=$(includedir)" \
262 "tooldir=$(tooldir)" \
263 "gdc_include_dir=$(gdc_include_dir)" \
269 "NM_FOR_BUILD=$(NM_FOR_BUILD)" \
270 "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
271 "DESTDIR=$(DESTDIR)" \
274 # Subdir rules rely on $(FLAGS_TO_PASS)
275 FLAGS_TO_PASS = $(AM_MAKEFLAGS)