OSDN Git Service

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