Scan dynamic libraries for GC roots
[delight/core.git] / phobos2 / Makefile.am
blobbb565100c33dc3cd8de10bfc7af0e0ec09a8487d
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=-fPIC @DEFS@ -I . -I $(srcdir)/gcc
23 D_EXTRA_DFLAGS=-fPIC -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)/gcc/config/config.d
30 config_libc_d_src     =$(host)/gcc/config/libc.d
31 config_errno_d_src    =$(host)/gcc/config/errno.d
32 config_fpcls_d_src    =$(host)/gcc/config/fpcls.d
33 config_mathfuncs_d_src=$(host)/gcc/config/mathfuncs.d
34 config_unix_d_src     =$(host)/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.so
48 SUFFIXES = .d
50 %.o : %.d $(D_PREREQ_SRCS)
51         $(GDC) -o $@ $(ALL_DFLAGS)  \
52         -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host) -c $<
54 # %.o : %.c
55 # Use .c.o to override Automake
56 .c.o:
57         $(CC) -o $@ $(OUR_CFLAGS) $(CFLAGS) -c $<
59 # boxer is currently broken
60 std/boxer.t.o: std/boxer.o
61         cp $< $@
63 %.t.o : %.d $(D_PREREQ_SRCS)
64         $(GDC) -o $@ $(ALL_DFLAGS) -fno-release -funittest -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host) -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) -c $<
69 %.t.o : %.o
70         cp $< $@
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) -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 \
82         ti_C.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 \
89         ti_void.o
91 INTERNAL_OBJS= internal/critical.o internal/object.o internal/monitor.o \
92         internal/arraycat.o internal/invariant.o \
93         internal/switch.o internal/arrayassign.o \
94         internal/aaA.o internal/adi.o internal/aApply.o internal/aApplyR.o \
95         internal/cast.o internal/memset.o internal/qsortg.o internal/obj.o \
96         internal/arraycast.o internal/dgccmain2.o internal/rundmain.o \
97         errno.o
99 MAIN_OBJS=std/asserterror.o std/hiddenfunc.o gcstats.o \
100         std/outofmemory.o std/compiler.o std/system.o std/moduleinit.o std/md5.o std/base64.o \
101         std/string.o std/math.o \
102         std/outbuffer.o std/ctype.o std/regexp.o std/random.o \
103         std/stream.o std/cstream.o std/switcherr.o std/array.o std/gc.o \
104         std/thread.o std/utf.o std/uri.o \
105         crc32.o std/conv.o \
106         std/syserror.o std/metastrings.o \
107         std/c/stdarg.o std/c/stdio.o std/stdio.o std/format.o \
108         std/openrj.o std/uni.o std/demangle.o std/bitarray.o \
109         $(subst ti_,std/typeinfo/ti_,$(TI)) \
110         std/date.o std/dateparse.o etc/c/zlib.o std/zlib.o std/zip.o \
111         std/stdarg.o \
112         std/signals.o std/cpuid.o std/traits.o std/typetuple.o std/bind.o \
113         gcc/config/mathfuncs.o \
114         std/algorithm.o std/bitmanip.o std/contracts.o std/functional.o \
115         std/getopt.o std/numeric.o std/slist.o std/typecons.o std/variant.o \
116         std/cover.o std/complex.o std/encoding.o std/iterator.o std/xml.o \
117         std/bigint.o
119 # This should not be linked into a shared library.
120 # TAL: Then how does the program start? I guess the compiler should add this
121 # itself when it detects it is compiling the main function.
122 CMAIN_OBJS=internal/cmain.o
123 # Unused (get duplicate symbol errors if we link this)
124 BUILTINS=gcc/builtins.o
125 ZLIB_OBJS= etc/c/zlib/adler32.o etc/c/zlib/compress.o \
126         etc/c/zlib/crc32.o etc/c/zlib/gzio.o \
127         etc/c/zlib/uncompr.o etc/c/zlib/deflate.o \
128         etc/c/zlib/trees.o etc/c/zlib/zutil.o \
129         etc/c/zlib/inflate.o etc/c/zlib/infback.o \
130         etc/c/zlib/inftrees.o etc/c/zlib/inffast.o
132 GC_OBJS= internal/gc/gc.o internal/gc/gcx.o \
133         internal/gc/gcbits.o
134 GC_OBJS += @D_GC_MODULES@
136 GCC_OBJS = gcc/unwind_pe.o gcc/deh.o gcc/threadsem.o \
137         gcc/cbridge_time.o gcc/cbridge_strerror.o
139 # modules which require some kind of operating system   
140 OS_OBJS = std/file.o std/mmfile.o std/path.o std/perf.o std/process.o std/socket.o std/socketstream.o 
142 # std.c.linux.linux, std.loader, gcc.cbridge*
143 WINDOWS_OBJS=std/c/windows/windows.o std/c/windows/com.o std/c/windows/winsock.o \
144         std/windows/iunknown.o std/windows/registry.o std/windows/syserror.o \
145         std/windows/charset.o
146 # D_EXTRA_OBJS=@D_EXTRA_OBJS@
148 # needed until instrinsics are implemented
149 D_EXTRA_OBJS+=std/intrinsic.o
151 D_EXTRA_OBJS+=gcc/support.o
153 gen_config1: config/gen_config1.o
154         $(CC) $(CFLAGS) -o $@ $^
156 $(config_d_src): frag-ac stamp-tgtdir
157         cp $< $@
159 $(config_libc_d_src): config/libc.x3 $(X3_DEPS) stamp-tgtdir
160         $(X3) $< -o $@ $(X3_GCC_COMMAND)
162 $(config_errno_d_src): config/errno.x3 $(X3_DEPS) stamp-tgtdir
163         $(X3) $< -o $@ $(X3_GCC_COMMAND)
165 $(config_fpcls_d_src): config/fpcls.x3 $(X3_DEPS) stamp-tgtdir
166         $(X3) $< -o $@ $(X3_GCC_COMMAND)
168 $(config_mathfuncs_d_src): frag-math stamp-tgtdir
169         cp $< $@
171 $(config_unix_d_src): config/unix.x3 $(X3_DEPS) stamp-tgtdir
172         $(X3) $< -o $@ $(X3_GCC_COMMAND)
174 # because these are in the $(host) subdir, pattern match rules will not work
175 gcc/config/unix.o: $(config_unix_d_src) $(config_d_src) $(config_libc_d_src)
176         $(GDC) -o $@ $(ALL_DFLAGS) -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host) -c $<
177 gcc/config/unix.t.o: gcc/config/unix.o
178         cp $< $@
180 gcc/config/mathfuncs.o: $(config_mathfuncs_d_src) $(config_d_src) $(config_libc_d_src)
181         $(GDC) -o $@ $(ALL_DFLAGS) -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host) -c $<
182 gcc/config/mathfuncs.t.o: gcc/config/mathfuncs.o
183         cp $< $@
185 gcc/cbridge_math.o: gcc/cbridge_math.c
186         $(CC) -o $@ $(OUR_CFLAGS) $(CFLAGS) -fno-strict-aliasing -c $<
188 std/stream.o: std/stream.d $(D_PREREQ_SRCS)
189         $(GDC) -o $@ $(ALL_DFLAGS) -fdeprecated -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host) -c $<
190 std/stream.t.o: std/stream.d $(D_PREREQ_SRCS)
191         $(GDC) -o $@ $(ALL_DFLAGS) -fdeprecated -I $(srcdir) -I $(srcdir)/internal/gc -I ./$(host) -c $<
193 ALL_PHOBOS_OBJS = $(D_EXTRA_OBJS) $(GCC_OBJS) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(WEAK_OBJS) $(INTERNAL_OBJS)
195 libgphobos2.a : $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
196         $(AR) -r $@ $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
197         $(RANLIB) $@
199 libgphobos2_t.a : $(ALL_PHOBOS_OBJS:.o=.t.o) $(CMAIN_OBJS)
200         $(AR) -r $@ $(ALL_PHOBOS_OBJS:.o=.t.o) $(CMAIN_OBJS)
201         $(RANLIB) $@
203 libgphobos2.so: $(D_EXTRA_OBJS) $(GCC_OBJS) $(INTERNAL_OBJS) $(GC_OBJS) $(WEAK_OBJS) $(CMAIN_OBJS) $(ZLIB_OBJS)
204         $(CC) -shared -Wl,-soname=libgphobos2.so -o $@ $^
206 # This has to be an empty file because it is included in the prerequisites of rules
207 # that use "cat $^" to generate their targets.
208 stamp-tgtdir:
209         mkdir -p gcc/config
210         mkdir -p $(host)/gcc/config
211         touch $@
213 check-local: unittest testgc
214         ./unittest
215         ./testgc
217 install-exec-local: $(D_PREREQ_SRCS) libgphobos2.so
218         $(mkinstalldirs) $(DESTDIR)$(toolexeclibdir)
219         $(INSTALL) libgphobos2.so $(DESTDIR)$(toolexeclibdir)
221 install-data-local: $(D_PREREQ_SRCS) libgphobos2.a
222         for i in etc etc/c \
223                 etc/c/zlib \
224                 gcc std std/c \
225                 std/c/darwin std/c/linux std/c/mach std/c/skyos std/c/unix std/c/windows \
226                 std/typeinfo std/windows; do \
227                 $(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$$i; \
228                 for f in $(srcdir)/$$i/*.[hd]; do $(INSTALL_HEADER) $$f $(DESTDIR)$(gdc_include_dir)/$$i; done; \
229         done
230         for i in crc32.d gcstats.d object.d; do \
231                 $(INSTALL_HEADER) $(srcdir)/$$i $(DESTDIR)$(gdc_include_dir); done
232         $(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$(host)/$(MULTISUBDIR)/gcc/config
233         for i in $(host)/gcc/config/*.d ; \
234                 do $(INSTALL_HEADER) $$i $(DESTDIR)$(gdc_include_dir)/$(host)/$(MULTISUBDIR)/gcc/config; done
235         $(INSTALL) phobos-ver-syms $(DESTDIR)$(gdc_include_dir)/$(host)/$(MULTISUBDIR)
237 clean-local:
238         rm -f $(ALL_PHOBOS_OBJS) $(CMAIN_OBJS)
239         rm -f $(ALL_PHOBOS_OBJS:.o=.t.o)
240         rm -f unittest.o internal/gc/testgc.o
241         rm -f unittest$(EXEEXT) testgc$(EXEEXT)
242         rm -f $(config_d_src) $(config_errno_d_src) $(config_libc_d_src)
243         rm -f $(config_unix_d_src)
244         rm -f libgphobos2.a
245         rm -f libgphobos2_t.a
248 # Work around what appears to be a GNU make bug handling MAKEFLAGS
249 # values defined in terms of make variables, as is the case for CC and
250 # friends when we are called from the top level Makefile.
251 AM_MAKEFLAGS = \
252         "AR_FLAGS=$(AR_FLAGS)" \
253         "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
254         "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
255         "CFLAGS=$(CFLAGS)" \
256         "CXXFLAGS=$(CXXFLAGS)" \
257         "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
258         "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
259         "INSTALL=$(INSTALL)" \
260         "INSTALL_DATA=$(INSTALL_DATA)" \
261         "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
262         "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
263         "LDFLAGS=$(LDFLAGS)" \
264         "LIBCFLAGS=$(LIBCFLAGS)" \
265         "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
266         "MAKE=$(MAKE)" \
267         "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
268         "PICFLAG=$(PICFLAG)" \
269         "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
270         "SHELL=$(SHELL)" \
271         "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
272         "exec_prefix=$(exec_prefix)" \
273         "infodir=$(infodir)" \
274         "libdir=$(libdir)" \
275         "includedir=$(includedir)" \
276         "prefix=$(prefix)" \
277         "tooldir=$(tooldir)" \
278         "gdc_include_dir=$(gdc_include_dir)" \
279         "AR=$(AR)" \
280         "AS=$(AS)" \
281         "LD=$(LD)" \
282         "RANLIB=$(RANLIB)" \
283         "NM=$(NM)" \
284         "NM_FOR_BUILD=$(NM_FOR_BUILD)" \
285         "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
286         "DESTDIR=$(DESTDIR)" \
287         "WERROR=$(WERROR)"
289 # Subdir rules rely on $(FLAGS_TO_PASS)
290 FLAGS_TO_PASS = $(AM_MAKEFLAGS)