OSDN Git Service

a5d24c6550ee14589f8a7cac91d0974b5dae5d3c
[pf3gnuchains/gcc-fork.git] / boehm-gc / Makefile.direct
1 # This is the original manually generated Makefile.  It may still be used
2 # to build the collector.
3 #
4 # Primary targets:
5 # gc.a - builds basic library
6 # c++ - adds C++ interface to library
7 # cords - adds cords (heavyweight strings) to library
8 # test - prints porting information, then builds basic version of gc.a,
9 #        and runs some tests of collector and cords.  Does not add cords or
10 #        c++ interface to gc.a
11 # cord/de - builds dumb editor based on cords.
12 ABI_FLAG= 
13 CC=cc $(ABI_FLAG)
14 CXX=g++ $(ABI_FLAG)
15 AS=as $(ABI_FLAG)
16 #  The above doesn't work with gas, which doesn't run cpp.
17 #  Define AS as `gcc -c -x assembler-with-cpp' instead.
18 #  Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64)
19 #  if you use something other than the default ABI on your machine.
20
21 # Redefining srcdir allows object code for the nonPCR version of the collector
22 # to be generated in different directories.
23 srcdir= .
24 VPATH= $(srcdir)
25
26 CFLAGS= -O -I$(srcdir)/include -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DSILENT -DALL_INTERIOR_POINTERS
27
28 # To build the parallel collector on Linux, add to the above:
29 # -DGC_LINUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC
30 # To build the parallel collector n a static library on HP/UX, add to the above:
31 # -DGC_HPUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC -DUSE_HPUX_TLS -D_POSIX_C_SOURCE=199506L
32
33 # HOSTCC and HOSTCFLAGS are used to build executables that will be run as
34 # part of the build process, i.e. on the build machine.  These will usually
35 # be the same as CC and CFLAGS, except in a cross-compilation environment.
36 # Note that HOSTCFLAGS should include any -D flags that affect thread support.
37 HOSTCC=$(CC)
38 HOSTCFLAGS=$(CFLAGS)
39
40 # For dynamic library builds, it may be necessary to add flags to generate
41 # PIC code, e.g. -fPIC on Linux.
42
43 # Setjmp_test may yield overly optimistic results when compiled
44 # without optimization.
45
46 # These define arguments influence the collector configuration:
47 # -DSILENT disables statistics printing, and improves performance.
48 # -DFIND_LEAK causes GC_find_leak to be initially set.
49 #   This causes the collector to assume that all inaccessible
50 #   objects should have been explicitly deallocated, and reports exceptions.
51 #   Finalization and the test program are not usable in this mode.
52 # -DGC_SOLARIS_THREADS enables support for Solaris (thr_) threads.
53 #   (Clients should also define GC_SOLARIS_THREADS and then include
54 #   gc.h before performing thr_ or dl* or GC_ operations.)
55 #   Must also define -D_REENTRANT.
56 # -DGC_SOLARIS_PTHREADS enables support for Solaris pthreads.
57 #   Define SOLARIS_THREADS as well.
58 # -DGC_IRIX_THREADS enables support for Irix pthreads.  See README.irix.
59 # -DGC_HPUX_THREADS enables support for HP/UX 11 pthreads.
60 #   Also requires -D_REENTRANT or -D_POSIX_C_SOURCE=199506L. See README.hp.
61 # -DGC_LINUX_THREADS enables support for Xavier Leroy's Linux threads.
62 #   see README.linux.  -D_REENTRANT may also be required.
63 # -DALL_INTERIOR_POINTERS allows all pointers to the interior
64 #   of objects to be recognized.  (See gc_priv.h for consequences.)
65 #   Alternatively, GC_all_interior_pointers can be set at process
66 #   initialization time.
67 # -DSMALL_CONFIG tries to tune the collector for small heap sizes,
68 #   usually causing it to use less space in such situations.
69 #   Incremental collection no longer works in this case.
70 # -DLARGE_CONFIG tunes the collector for unusually large heaps.
71 #   Necessary for heaps larger than about 500 MB on most machines.
72 #   Recommended for heaps larger than about 64 MB.
73 # -DDONT_ADD_BYTE_AT_END is meaningful only with -DALL_INTERIOR_POINTERS or
74 #   GC_all_interior_pointers = 1.  Normally -DALL_INTERIOR_POINTERS
75 #   causes all objects to be padded so that pointers just past the end of
76 #   an object can be recognized.  This can be expensive.  (The padding
77 #   is normally more than one byte due to alignment constraints.)
78 #   -DDONT_ADD_BYTE_AT_END disables the padding.
79 # -DNO_SIGNALS does not disable signals during critical parts of
80 #   the GC process.  This is no less correct than many malloc 
81 #   implementations, and it sometimes has a significant performance
82 #   impact.  However, it is dangerous for many not-quite-ANSI C
83 #   programs that call things like printf in asynchronous signal handlers.
84 #   This is on by default.  Turning it off has not been extensively tested with
85 #   compilers that reorder stores.  It should have been.
86 # -DNO_EXECUTE_PERMISSION may cause some or all of the heap to not
87 #   have execute permission, i.e. it may be impossible to execute
88 #   code from the heap.  Currently this only affects the incremental
89 #   collector on UNIX machines.  It may greatly improve its performance,
90 #   since this may avoid some expensive cache synchronization.
91 # -DGC_NO_OPERATOR_NEW_ARRAY declares that the C++ compiler does not support
92 #   the  new syntax "operator new[]" for allocating and deleting arrays.
93 #   See gc_cpp.h for details.  No effect on the C part of the collector.
94 #   This is defined implicitly in a few environments.  Must also be defined
95 #   by clients that use gc_cpp.h.
96 # -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined
97 #   as aliases for X, GC_realloc, and GC_free, respectively.
98 #   Calloc is redefined in terms of the new malloc.  X should
99 #   be either GC_malloc or GC_malloc_uncollectable, or
100 #   GC_debug_malloc_replacement.  (The latter invokes GC_debug_malloc
101 #   with dummy source location information, but still results in
102 #   properly remembered call stacks on Linux/X86 and Solaris/SPARC.)
103 #   The former is occasionally useful for working around leaks in code
104 #   you don't want to (or can't) look at.  It may not work for
105 #   existing code, but it often does.  Neither works on all platforms,
106 #   since some ports use malloc or calloc to obtain system memory.
107 #   (Probably works for UNIX, and win32.)
108 # -DREDIRECT_REALLOC=X causes GC_realloc to be redirected to X.
109 #   The canonical use is -DREDIRECT_REALLOC=GC_debug_realloc_replacement,
110 #   together with -DREDIRECT_MALLOC=GC_debug_malloc_replacement to
111 #   generate leak reports with call stacks for both malloc and realloc.
112 # -DIGNORE_FREE turns calls to free into a noop.  Only useful with
113 #   -DREDIRECT_MALLOC.
114 # -DNO_DEBUGGING removes GC_dump and the debugging routines it calls.
115 #   Reduces code size slightly at the expense of debuggability.
116 # -DJAVA_FINALIZATION makes it somewhat safer to finalize objects out of
117 #   order by specifying a nonstandard finalization mark procedure  (see
118 #   finalize.c).  Objects reachable from finalizable objects will be marked
119 #   in a sepearte postpass, and hence their memory won't be reclaimed.
120 #   Not recommended unless you are implementing a language that specifies
121 #   these semantics.  Since 5.0, determines only only the initial value
122 #   of GC_java_finalization variable.
123 # -DFINALIZE_ON_DEMAND causes finalizers to be run only in response
124 #   to explicit GC_invoke_finalizers() calls.
125 #   In 5.0 this became runtime adjustable, and this only determines the
126 #   initial value of GC_finalize_on_demand.
127 # -DATOMIC_UNCOLLECTABLE includes code for GC_malloc_atomic_uncollectable.
128 #   This is useful if either the vendor malloc implementation is poor,
129 #   or if REDIRECT_MALLOC is used.
130 # -DHBLKSIZE=ddd, where ddd is a power of 2 between 512 and 16384, explicitly
131 #   sets the heap block size.  Each heap block is devoted to a single size and
132 #   kind of object.  For the incremental collector it makes sense to match
133 #   the most likely page size.  Otherwise large values result in more
134 #   fragmentation, but generally better performance for large heaps.
135 # -DUSE_MMAP use MMAP instead of sbrk to get new memory.
136 #   Works for Solaris and Irix.
137 # -DUSE_MUNMAP causes memory to be returned to the OS under the right
138 #   circumstances.  This currently disables VM-based incremental collection.
139 #   This is currently experimental, and works only under some Unix and
140 #   Linux versions.
141 # -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than
142 #   GC_scratch_alloc() to get stack memory.
143 # -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever
144 #   the garbage collector detects a value that looks almost, but not quite,
145 #   like a pointer, print both the address containing the value, and the
146 #   value of the near-bogus-pointer.  Can be used to identifiy regions of
147 #   memory that are likely to contribute misidentified pointers.
148 # -DKEEP_BACK_PTRS Add code to save back pointers in debugging headers
149 #   for objects allocated with the debugging allocator.  If all objects
150 #   through GC_MALLOC with GC_DEBUG defined, this allows the client
151 #   to determine how particular or randomly chosen objects are reachable
152 #   for debugging/profiling purposes.  The gc_backptr.h interface is
153 #   implemented only if this is defined.
154 # -DGC_ASSERTIONS Enable some internal GC assertion checking.  Currently
155 #   this facility is only used in a few places.  It is intended primarily
156 #   for debugging of the garbage collector itself, but could also
157 # -DDBG_HDRS_ALL Make sure that all objects have debug headers.  Increases
158 #   the reliability (from 99.9999% to 100%) of some of the debugging
159 #   code (especially KEEP_BACK_PTRS).  Makes -DSHORT_DBG_HDRS possible.
160 #   Assumes that all client allocation is done through debugging
161 #   allocators.
162 # -DSHORT_DBG_HDRS Assume that all objects have debug headers.  Shorten
163 #   the headers to minimize object size, at the expense of checking for
164 #   writes past the end of an object.  This is intended for environments
165 #   in which most client code is written in a "safe" language, such as
166 #   Scheme or Java.  Assumes that all client allocation is done using
167 #   the GC_debug_ functions, or through the macros that expand to these,
168 #   or by redirecting malloc to GC_debug_malloc_replacement.
169 #   (Also eliminates the field for the requested object size.)
170 #   occasionally be useful for debugging of client code.  Slows down the
171 #   collector somewhat, but not drastically.
172 # -DSAVE_CALL_COUNT=<n> Set the number of call frames saved with objects
173 #   allocated through the debugging interface.  Affects the amount of
174 #   information generated in leak reports.  Only matters on platforms
175 #   on which we can quickly generate call stacks, currently Linux/(X86 & SPARC)
176 #   and Solaris/SPARC.  Turns on call chain saving on X86.  On X86, client
177 #   code should NOT be compiled with -fomit-frame-pointer.
178 # -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
179 #   altered stubborn objects, at substantial performance cost.
180 #   Use only for debugging of the incremental collector.
181 # -DGC_GCJ_SUPPORT includes support for gcj (and possibly other systems
182 #   that include a pointer to a type descriptor in each allocated object).
183 #   Building this way requires an ANSI C compiler.
184 # -DUSE_I686_PREFETCH causes the collector to issue Pentium III style
185 #   prefetch instructions.  No effect except on X86 Linux platforms.
186 #   Assumes a very recent gcc-compatible compiler and assembler.
187 #   (Gas prefetcht0 support was added around May 1999.)
188 #   Empirically the code appears to still run correctly on Pentium II
189 #   processors, though with no performance benefit.  May not run on other
190 #   X86 processors?  In some cases this improves performance by
191 #   15% or so.
192 # -DUSE_3DNOW_PREFETCH causes the collector to issue AMD 3DNow style
193 #   prefetch instructions.  Same restrictions as USE_I686_PREFETCH.
194 #   UNTESTED!!
195 # -DGC_USE_LD_WRAP in combination with the gld flags listed in README.linux
196 #   causes the collector some system and pthread calls in a more transparent
197 #   fashion than the usual macro-based approach.  Requires GNU ld, and
198 #   currently probably works only with Linux.
199 # -DTHREAD_LOCAL_ALLOC defines GC_local_malloc(), GC_local_malloc_atomic()
200 #   and GC_local_gcj_malloc().  Needed for gc_gcj.h interface.  These allocate
201 #   in a way that usually does not involve acquisition of a global lock.
202 #   Currently requires -DGC_LINUX_THREADS, but should be easy to port to
203 #   other pthreads environments.  Recommended for multiprocessors.
204 # -DPARALLEL_MARK allows the marker to run in multiple threads.  Recommended
205 #   for multiprocessors.  Currently requires Linux on X86 or IA64, though
206 #   support for other Posix platforms should be fairly easy to add,
207 #   if the thread implementation is otherwise supported.
208 # -DNO_GETENV prevents the collector from looking at environment variables.
209 #   These may otherwise alter its configuration, or turn off GC altogether.
210 #   I don't know of a reason to disable this, except possibly if the
211 #   resulting process runs as a privileged user?
212 # -DSTUBBORN_ALLOC allows allocation of "hard to change" objects, and thus
213 #   makes incremental collection easier.  Was enabled by default until 6.0.
214 #   Rarely used, to my knowledge.
215 #
216
217 CXXFLAGS= $(CFLAGS) 
218 AR= ar
219 RANLIB= ranlib
220
221
222 OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o
223
224 CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c
225
226 CORD_SRCS=  cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC
227
228 CORD_OBJS=  cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o
229
230 SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \
231     sparc_mach_dep.s include/gc.h include/gc_typed.h \
232     include/private/gc_hdrs.h include/private/gc_priv.h \
233     include/private/gcconfig.h include/private/gc_pmark.h \
234     include/gc_inl.h include/gc_inline.h include/gc_mark.h \
235     threadlibs.c if_mach.c if_not_there.c gc_cpp.cc include/gc_cpp.h \
236     gcname.c include/weakpointer.h include/private/gc_locks.h \
237     gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h \
238     include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \
239     sparc_netbsd_mach_dep.s \
240     include/private/solaris_threads.h include/gc_backptr.h \
241     hpux_test_and_clear.s include/gc_gcj.h \
242     include/gc_local_alloc.h include/private/dbg_mlc.h \
243     include/private/specific.h powerpc_macosx_mach_dep.s \
244     include/leak_detector.h include/gc_amiga_redirects.h \
245     include/gc_pthread_redirects.h $(CORD_SRCS)
246
247 DOC_FILES= README.QUICK doc/README.Mac doc/README.MacOSX doc/README.OS2 \
248         doc/README.amiga doc/README.cords doc/debugging.html \
249         doc/README.dj doc/README.hp doc/README.linux doc/README.rs6000 \
250         doc/README.sgi doc/README.solaris2 doc/README.uts \
251         doc/README.win32 doc/barrett_diagram doc/README \
252         doc/README.contributors doc/README.changes doc/gc.man \
253         doc/README.environment doc/tree.html doc/gcdescr.html \
254         doc/README.autoconf doc/README.macros
255
256 TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \
257         tests/leak_test.c tests/thread_leak_test.c
258
259 GNU_BUILD_FILES= configure.in Makefile.am configure acinclude.m4 \
260                  libtool.m4 install-sh configure.host Makefile.in \
261                  aclocal.m4 config.sub config.guess ltconfig \
262                  ltmain.sh mkinstalldirs
263
264 OTHER_MAKEFILES= OS2_MAKEFILE NT_MAKEFILE NT_THREADS_MAKEFILE gc.mak \
265                  BCC_MAKEFILE EMX_MAKEFILE WCC_MAKEFILE Makefile.dj \
266                  PCR-Makefile SMakefile.amiga Makefile.DLLs \
267                  digimars.mak Makefile.direct
268 #       Makefile and Makefile.direct are copies of each other.
269
270 OTHER_FILES= Makefile setjmp_t.c callprocs pc_excludes \
271            MacProjects.sit.hqx MacOS.c \
272            Mac_files/datastart.c Mac_files/dataend.c \
273            Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \
274            add_gc_prefix.c gc_cpp.cpp win32_threads.c \
275            version.h AmigaOS.c \
276            $(TESTS) $(GNU_BUILD_FILES) $(OTHER_MAKEFILES)
277
278 CORD_INCLUDE_FILES= $(srcdir)/include/gc.h $(srcdir)/include/cord.h \
279         $(srcdir)/include/ec.h $(srcdir)/include/private/cord_pos.h
280
281 UTILS= if_mach if_not_there threadlibs
282
283 # Libraries needed for curses applications.  Only needed for de.
284 CURSES= -lcurses -ltermlib
285
286 # The following is irrelevant on most systems.  But a few
287 # versions of make otherwise fork the shell specified in
288 # the SHELL environment variable.
289 SHELL= /bin/sh
290
291 SPECIALCFLAGS = -I$(srcdir)/include
292 # Alternative flags to the C compiler for mach_dep.c.
293 # Mach_dep.c often doesn't like optimization, and it's
294 # not time-critical anyway.
295 # Set SPECIALCFLAGS to -q nodirect_code on Encore.
296
297 all: gc.a gctest
298
299 BSD-pkg-all: bsd-libgc.a
300
301 bsd-libgc.a:
302         $(MAKE) CFLAGS="$(CFLAGS)" clean c++-t
303         mv gc.a bsd-libgc.a
304
305 BSD-pkg-install: BSD-pkg-all
306         ${CP} bsd-libgc.a libgc.a
307         ${INSTALL_DATA} libgc.a ${PREFIX}/lib
308         ${INSTALL_DATA} gc.h gc_cpp.h ${PREFIX}/include
309
310 pcr: PCR-Makefile include/private/gc_private.h include/private/gc_hdrs.h \
311 include/private/gc_locks.h include/gc.h include/private/gcconfig.h \
312 mach_dep.o $(SRCS)
313         $(MAKE) -f PCR-Makefile depend
314         $(MAKE) -f PCR-Makefile
315
316 $(OBJS) tests/test.o dyn_load.o dyn_load_sunos53.o: \
317     $(srcdir)/include/private/gc_priv.h \
318     $(srcdir)/include/private/gc_hdrs.h $(srcdir)/include/private/gc_locks.h \
319     $(srcdir)/include/gc.h \
320     $(srcdir)/include/private/gcconfig.h $(srcdir)/include/gc_typed.h \
321     Makefile
322 # The dependency on Makefile is needed.  Changing
323 # options such as -DSILENT affects the size of GC_arrays,
324 # invalidating all .o files that rely on gc_priv.h
325
326 mark.o typd_mlc.o finalize.o ptr_chck.o: $(srcdir)/include/gc_mark.h $(srcdir)/include/private/gc_pmark.h
327
328 specific.o linux_threads.o: $(srcdir)/include/private/specific.h
329
330 solaris_threads.o solaris_pthreads.o: $(srcdir)/include/private/solaris_threads.h
331
332 dbg_mlc.o gcj_mlc.o: $(srcdir)/include/private/dbg_mlc.h
333
334 tests/test.o: tests $(srcdir)/tests/test.c
335         $(CC) $(CFLAGS) -c $(srcdir)/tests/test.c
336         mv test.o tests/test.o
337
338 tests:
339         mkdir tests
340
341 base_lib gc.a: $(OBJS) dyn_load.o $(UTILS)
342         echo > base_lib
343         rm -f dont_ar_1
344         ./if_mach SPARC SUNOS5 touch dont_ar_1
345         ./if_mach SPARC SUNOS5 $(AR) rus gc.a $(OBJS) dyn_load.o
346         ./if_mach M68K AMIGA touch dont_ar_1
347         ./if_mach M68K AMIGA $(AR) -vrus gc.a $(OBJS) dyn_load.o
348         ./if_not_there dont_ar_1 $(AR) ru gc.a $(OBJS) dyn_load.o
349         ./if_not_there dont_ar_1 $(RANLIB) gc.a || cat /dev/null
350 #       ignore ranlib failure; that usually means it doesn't exist, and isn't needed
351
352 cords: $(CORD_OBJS) cord/cordtest $(UTILS)
353         rm -f dont_ar_3
354         ./if_mach SPARC SUNOS5 touch dont_ar_3
355         ./if_mach SPARC SUNOS5 $(AR) rus gc.a $(CORD_OBJS)
356         ./if_mach M68K AMIGA touch dont_ar_3
357         ./if_mach M68K AMIGA $(AR) -vrus gc.a $(CORD_OBJS)
358         ./if_not_there dont_ar_3 $(AR) ru gc.a $(CORD_OBJS)
359         ./if_not_there dont_ar_3 $(RANLIB) gc.a || cat /dev/null
360
361 gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h Makefile
362         $(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
363
364 test_cpp: $(srcdir)/tests/test_cpp.cc $(srcdir)/include/gc_cpp.h gc_cpp.o $(srcdir)/include/gc.h \
365 base_lib $(UTILS)
366         rm -f test_cpp
367         ./if_mach HP_PA HPUX $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/tests/test_cpp.cc gc_cpp.o gc.a -ldld `./threadlibs`
368         ./if_not_there test_cpp $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/tests/test_cpp.cc gc_cpp.o gc.a `./threadlibs`
369
370 c++-t: c++
371         ./test_cpp 1
372
373 c++-nt: c++
374         @echo "Use ./test_cpp 1 to test the leak library"
375
376 c++: gc_cpp.o $(srcdir)/include/gc_cpp.h test_cpp
377         rm -f dont_ar_4
378         ./if_mach SPARC SUNOS5 touch dont_ar_4
379         ./if_mach SPARC SUNOS5 $(AR) rus gc.a gc_cpp.o
380         ./if_mach M68K AMIGA touch dont_ar_4
381         ./if_mach M68K AMIGA $(AR) -vrus gc.a gc_cpp.o
382         ./if_not_there dont_ar_4 $(AR) ru gc.a gc_cpp.o
383         ./if_not_there dont_ar_4 $(RANLIB) gc.a || cat /dev/null
384         ./test_cpp 1
385         echo > c++
386
387 dyn_load_sunos53.o: dyn_load.c
388         $(CC) $(CFLAGS) -DSUNOS53_SHARED_LIB -c $(srcdir)/dyn_load.c -o $@
389
390 # SunOS5 shared library version of the collector
391 sunos5gc.so: $(OBJS) dyn_load_sunos53.o
392         $(CC) -G -o sunos5gc.so $(OBJS) dyn_load_sunos53.o -ldl
393         ln sunos5gc.so libgc.so
394
395 # Alpha/OSF shared library version of the collector
396 libalphagc.so: $(OBJS)
397         ld -shared -o libalphagc.so $(OBJS) dyn_load.o -lc
398         ln libalphagc.so libgc.so
399
400 # IRIX shared library version of the collector
401 libirixgc.so: $(OBJS) dyn_load.o
402         ld -shared $(ABI_FLAG) -o libirixgc.so $(OBJS) dyn_load.o -lc
403         ln libirixgc.so libgc.so
404
405 # Linux shared library version of the collector
406 liblinuxgc.so: $(OBJS) dyn_load.o
407         gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o
408         ln liblinuxgc.so libgc.so
409
410 # Alternative Linux rule.  This is preferable, but is likely to break the
411 # Makefile for some non-linux platforms.
412 # LIBOBJS= $(patsubst %.o, %.lo, $(OBJS))
413 #
414 #.SUFFIXES: .lo $(SUFFIXES)
415 #
416 #.c.lo:
417 #       $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c $< -o $@
418 #
419 # liblinuxgc.so: $(LIBOBJS) dyn_load.lo
420 #       gcc -shared -Wl,-soname=libgc.so.0 -o libgc.so.0 $(LIBOBJS) dyn_load.lo
421 #       touch liblinuxgc.so
422
423 mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s \
424             $(srcdir)/rs6000_mach_dep.s $(srcdir)/powerpc_macosx_mach_dep.s $(UTILS)
425         rm -f mach_dep.o
426         ./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s
427         ./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
428         ./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
429         ./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s
430         ./if_mach POWERPC MACOSX $(AS) -o mach_dep.o $(srcdir)/powerpc_macosx_mach_dep.s
431 #       ./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s
432 #       alpha_mach_dep.s assumes that pointers are not saved in fp registers.
433 #       Gcc on a 21264 can spill pointers to fp registers.  Oops.
434         ./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s
435         ./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s
436         ./if_mach SPARC OPENBSD $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s
437         ./if_mach SPARC NETBSD $(AS) -o mach_dep.o $(srcdir)/sparc_netbsd_mach_dep.s
438         ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
439
440 mark_rts.o: $(srcdir)/mark_rts.c $(UTILS)
441         rm -f mark_rts.o
442         -./if_mach ALPHA OSF1 $(CC) -c $(CFLAGS) -Wo,-notail $(srcdir)/mark_rts.c
443         ./if_not_there mark_rts.o $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c
444 #       Work-around for DEC optimizer tail recursion elimination bug.
445 #  The ALPHA-specific line should be removed if gcc is used.
446
447 alloc.o: version.h
448
449 cord:
450         mkdir cord
451
452 cord/cordbscs.o: cord $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES)
453         $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordbscs.c
454         mv cordbscs.o cord/cordbscs.o
455 #  not all compilers understand -o filename
456
457 cord/cordxtra.o: cord $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES)
458         $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordxtra.c
459         mv cordxtra.o cord/cordxtra.o
460
461 cord/cordprnt.o: cord $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES)
462         $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordprnt.c
463         mv cordprnt.o cord/cordprnt.o
464
465 cord/cordtest: $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a $(UTILS)
466         rm -f cord/cordtest
467         ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -lucb
468         ./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -ldld `./threadlibs`
469         ./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a `./threadlibs`
470         ./if_not_there cord/cordtest $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a `./threadlibs`
471
472 cord/de: $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(UTILS)
473         rm -f cord/de
474         ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -lucb `./threadlibs`
475         ./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -ldld `./threadlibs`
476         ./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
477         ./if_mach POWERPC MACOSX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a
478         ./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
479         ./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
480         ./if_mach IA64 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
481         ./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
482         ./if_not_there cord/de $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) `./threadlibs`
483
484 if_mach: $(srcdir)/if_mach.c $(srcdir)/include/private/gcconfig.h
485         $(HOSTCC) $(HOSTCFLAGS) -o if_mach $(srcdir)/if_mach.c
486
487 threadlibs: $(srcdir)/threadlibs.c $(srcdir)/include/private/gcconfig.h Makefile
488         $(HOSTCC) $(HOSTCFLAGS) -o threadlibs $(srcdir)/threadlibs.c
489
490 if_not_there: $(srcdir)/if_not_there.c
491         $(HOSTCC) $(HOSTCFLAGS) -o if_not_there $(srcdir)/if_not_there.c
492
493 clean: 
494         rm -f gc.a *.o *.exe tests/*.o gctest gctest_dyn_link test_cpp \
495               setjmp_test  mon.out gmon.out a.out core if_not_there if_mach \
496               threadlibs $(CORD_OBJS) cord/cordtest cord/de
497         -rm -f *~
498
499 gctest: tests/test.o gc.a $(UTILS)
500         rm -f gctest
501         ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest  tests/test.o gc.a -lucb
502         ./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o gctest  tests/test.o gc.a -ldld `./threadlibs`
503         ./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o gctest  tests/test.o gc.a `./threadlibs`
504         ./if_not_there gctest $(CC) $(CFLAGS) -o gctest tests/test.o gc.a `./threadlibs`
505
506 # If an optimized setjmp_test generates a segmentation fault,
507 # odds are your compiler is broken.  Gctest may still work.
508 # Try compiling setjmp_t.c unoptimized.
509 setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/include/gc.h $(UTILS)
510         $(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c
511
512 test:  KandRtest cord/cordtest
513         cord/cordtest
514
515 # Those tests that work even with a K&R C compiler:
516 KandRtest: setjmp_test gctest
517         ./setjmp_test
518         ./gctest
519
520 add_gc_prefix: $(srcdir)/add_gc_prefix.c $(srcdir)/version.h
521         $(CC) -o add_gc_prefix $(srcdir)/add_gc_prefix.c
522
523 gcname: $(srcdir)/gcname.c $(srcdir)/version.h
524         $(CC) -o gcname $(srcdir)/gcname.c
525
526 gc.tar: $(SRCS) $(DOC_FILES) $(OTHER_FILES) add_gc_prefix gcname
527         cp Makefile Makefile.old
528         cp Makefile.direct Makefile
529         rm -f `./gcname`
530         ln -s . `./gcname`
531         ./add_gc_prefix $(SRCS) $(DOC_FILES) $(OTHER_FILES) > /tmp/gc.tar-files
532         tar cvfh gc.tar `cat /tmp/gc.tar-files`
533         cp gc.tar `./gcname`.tar
534         gzip `./gcname`.tar
535         rm `./gcname`
536
537 pc_gc.tar: $(SRCS) $(OTHER_FILES)
538         tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES)
539
540 floppy: pc_gc.tar
541         -mmd a:/cord
542         -mmd a:/cord/private
543         -mmd a:/include
544         -mmd a:/include/private
545         mkdir /tmp/pc_gc
546         cat pc_gc.tar | (cd /tmp/pc_gc; tar xvf -)
547         -mcopy -tmn /tmp/pc_gc/* a:
548         -mcopy -tmn /tmp/pc_gc/cord/* a:/cord
549         -mcopy -mn /tmp/pc_gc/cord/de_win.ICO a:/cord
550         -mcopy -tmn /tmp/pc_gc/cord/private/* a:/cord/private
551         -mcopy -tmn /tmp/pc_gc/include/* a:/include
552         -mcopy -tmn /tmp/pc_gc/include/private/* a:/include/private
553         rm -r /tmp/pc_gc
554
555 gc.tar.Z: gc.tar
556         compress gc.tar
557
558 gc.tar.gz: gc.tar
559         gzip gc.tar
560
561 lint: $(CSRCS) tests/test.c
562         lint -DLINT $(CSRCS) tests/test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall|change in ANSI|improper alignment"
563
564 # BTL: added to test shared library version of collector.
565 # Currently works only under SunOS5.  Requires GC_INIT call from statically
566 # loaded client code.
567 ABSDIR = `pwd`
568 gctest_dyn_link: tests/test.o libgc.so
569         $(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link tests/test.o -lgc -ldl -lthread
570
571 gctest_irix_dyn_link: tests/test.o libirixgc.so
572         $(CC) -L$(ABSDIR) -o gctest_irix_dyn_link tests/test.o -lirixgc
573
574 # The following appear to be dead, especially since libgc_globals.h
575 # is apparently lost.
576 test_dll.o: tests/test.c libgc_globals.h
577         $(CC) $(CFLAGS) -DGC_USE_DLL -c tests/test.c -o test_dll.o
578
579 test_dll: test_dll.o libgc_dll.a libgc.dll
580         $(CC) test_dll.o -L$(ABSDIR) -lgc_dll -o test_dll
581
582 SYM_PREFIX-libgc=GC
583
584 # Uncomment the following line to build a GNU win32 DLL
585 # include Makefile.DLLs
586
587 reserved_namespace: $(SRCS)
588         for file in $(SRCS) tests/test.c tests/test_cpp.cc; do \
589                 sed s/GC_/_GC_/g < $$file > tmp; \
590                 cp tmp $$file; \
591                 done
592
593 user_namespace: $(SRCS)
594         for file in $(SRCS) tests/test.c tests/test_cpp.cc; do \
595                 sed s/_GC_/GC_/g < $$file > tmp; \
596                 cp tmp $$file; \
597                 done