1 # This is the original manually generated Makefile. It may still be used
2 # to build the collector.
5 # all - builds gc.a, gccpp.a and cord.a
6 # base_lib - builds gc.a only (basic library)
7 # c++ - builds gccpp.a only (C++ interface to library)
8 # cords - builds cord.a only (heavyweight strings library)
9 # check - same as "all" but also prints porting information, and runs some
10 # tests of collector and cords
11 # check-cpp - builds gc.a and gccpp.a, runs C++ only test
12 # cord/de - builds dumb editor based on cords.
15 # ABI_FLAG should be the cc flag that specifies the ABI. On most
16 # platforms this will be the empty string. Possible values:
17 # +DD64 for 64-bit executable on HP/UX.
18 # -n32, -n64, -o32 for SGI/MIPS ABIs.
20 AS_ABI_FLAG=$(ABI_FLAG)
21 # ABI flag for assembler. On HP/UX this is +A64 for 64 bit
25 # Compiler executable name. For EMX, replace to "gcc".
28 # Needed only for "make c++", which builds the C++ interface.
31 # The above doesn't work with gas, which doesn't run cpp.
32 # Define AS as `gcc -c -x assembler-with-cpp' instead.
33 # Under Irix 6, you have to specify the ABI (-o32, -n32, or -64)
34 # if you use something other than the default ABI on your machine.
38 # Redefining srcdir allows object code for the nonPCR version of the collector
39 # to be generated in different directories.
43 # Path to atomic_ops source.
44 AO_SRC_DIR=$(srcdir)/libatomic_ops
47 # We need CFLAGS_FOR_PIC because we might be building a shared library.
48 CFLAGS= -O -I$(srcdir)/include -I$(AO_SRC_DIR)/src \
49 -DALL_INTERIOR_POINTERS -DENABLE_DISCLAIM -DGC_ATOMIC_UNCOLLECTABLE \
50 -DGC_GCJ_SUPPORT -DJAVA_FINALIZATION -DNO_EXECUTE_PERMISSION \
51 -DUSE_MMAP -DUSE_MUNMAP $(CFLAGS_FOR_PIC) $(CFLAGS_EXTRA)
53 # To build the collector with threads support, add to the above:
54 # -DGC_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC
56 # To build the preload library that intercepts malloc, add:
57 # -DGC_USE_DLOPEN_WRAP -DREDIRECT_MALLOC=GC_malloc -fpic
59 # To build the collector with fork() support by default, add to the above:
62 # HOSTCC and HOSTCFLAGS are used to build executables that will be run as
63 # part of the build process, i.e. on the build machine. These will usually
64 # be the same as CC and CFLAGS, except in a cross-compilation environment.
65 # Note that HOSTCFLAGS should include any -D flags that affect thread support.
69 # For dynamic library builds, it may be necessary to add flags to generate
70 # PIC code, e.g. -fPIC on Linux.
72 # Setjmp_test may yield overly optimistic results when compiled
73 # without optimization.
75 # Look into doc/README.macros for the description of the "define arguments"
76 # influencing the collector configuration.
82 # For EMX, replace "ranlib" with "ar s".
85 OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o \
86 headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o \
87 malloc.o checksums.o pthread_support.o pthread_stop_world.o \
88 darwin_stop_world.o typd_mlc.o ptr_chck.o mallocx.o gcj_mlc.o specific.o \
89 gc_dlopen.o backgraph.o win32_threads.o pthread_start.o \
90 thread_local_alloc.o fnlz_mlc.o atomic_ops.o atomic_ops_sysdeps.o
92 CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c \
93 headers.c mark.c obj_map.c blacklst.c finalize.c \
94 new_hblk.c dyn_load.c dbg_mlc.c malloc.c \
95 checksums.c pthread_support.c pthread_stop_world.c darwin_stop_world.c \
96 typd_mlc.c ptr_chck.c mallocx.c gcj_mlc.c specific.c gc_dlopen.c \
97 backgraph.c win32_threads.c pthread_start.c thread_local_alloc.c fnlz_mlc.c
99 CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/tests/de.c \
100 cord/tests/cordtest.c include/cord.h include/ec.h \
101 include/cord_pos.h cord/tests/de_win.c cord/tests/de_win.h \
102 cord/tests/de_cmds.h cord/tests/de_win.rc
104 CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o
107 include/gc.h include/gc_typed.h include/gc_tiny_fl.h \
108 include/gc_version.h include/private/gc_hdrs.h include/private/gc_priv.h \
109 include/private/gcconfig.h include/private/gc_pmark.h \
110 include/gc_inline.h include/gc_mark.h include/gc_disclaim.h \
111 tools/threadlibs.c tools/if_mach.c tools/if_not_there.c gc_cpp.cc \
112 include/gc_cpp.h include/private/gc_locks.h include/new_gc_alloc.h \
113 include/gc_alloc_ptrs.h include/gc_allocator.h include/javaxfc.h \
114 include/gc_backptr.h include/gc_gcj.h include/private/dbg_mlc.h \
115 include/private/specific.h include/leak_detector.h \
116 include/gc_pthread_redirects.h include/private/gc_atomic_ops.h \
117 include/gc_config_macros.h include/private/pthread_support.h \
118 include/private/pthread_stop_world.h include/private/darwin_semaphore.h \
119 include/private/darwin_stop_world.h include/private/thread_local_alloc.h \
120 ia64_save_regs_in_stack.s sparc_mach_dep.S \
121 sparc_netbsd_mach_dep.s $(CORD_SRCS)
123 CORD_INCLUDE_FILES= $(srcdir)/include/gc.h $(srcdir)/include/cord.h \
124 $(srcdir)/include/ec.h $(srcdir)/include/cord_pos.h
126 # Executable file name extension. For EMX, specify ".exe".
129 UTILS= if_mach$(EXEEXT) if_not_there$(EXEEXT) threadlibs$(EXEEXT)
131 # Libraries needed for curses applications. Only needed for de.
132 # It might also require -ltermlib on some targets.
135 # The following is irrelevant on most systems. But a few
136 # versions of make otherwise fork the shell specified in
137 # the SHELL environment variable.
140 SPECIALCFLAGS= -I$(srcdir)/include -I$(AO_SRC_DIR)/src $(CFLAGS_FOR_PIC)
141 # Alternative flags to the C compiler for mach_dep.c.
142 # Mach_dep.c often doesn't like optimization, and it's
143 # not time-critical anyway.
144 # Set SPECIALCFLAGS to -q nodirect_code on Encore.
146 all: base_lib cords c++
148 atomic_ops.o: $(AO_SRC_DIR)/src/atomic_ops.c
149 $(CC) $(CFLAGS) -c -o $@ $(AO_SRC_DIR)/src/atomic_ops.c
150 # For some reason, Solaris make does not handle "$<" properly.
152 atomic_ops_sysdeps.o: $(AO_SRC_DIR)/src/atomic_ops_sysdeps.S
153 $(CC) $(CFLAGS) -c -o $@ $(AO_SRC_DIR)/src/atomic_ops_sysdeps.S
155 LEAKFLAGS= $(CFLAGS) -DFIND_LEAK
157 BSD-pkg-all: bsd-libgc.a bsd-libleak.a
159 bsd-libgc.a bsd-libgccpp.a:
160 $(MAKE) -f Makefile.direct CFLAGS="$(CFLAGS)" clean c++-t
162 mv gccpp.a bsd-libgccpp.a
165 $(MAKE) -f Makefile.direct CFLAGS="$(LEAKFLAGS)" clean c++-nt
166 mv gc.a bsd-libleak.a
168 BSD-pkg-install: BSD-pkg-all
169 ${CP} bsd-libgc.a libgc.a
170 ${INSTALL_DATA} libgc.a ${PREFIX}/lib
171 ${CP} bsd-libgccpp.a libgccpp.a
172 ${INSTALL_DATA} libgccpp.a ${PREFIX}/lib
173 ${INSTALL_DATA} gc.h gc_cpp.h ${PREFIX}/include
174 ${INSTALL_MAN} doc/gc.man ${PREFIX}/man/man3/gc.3
176 pcr: PCR-Makefile include/private/gc_private.h include/private/gc_hdrs.h \
177 include/private/gc_locks.h include/gc.h include/private/gcconfig.h \
179 $(MAKE) -f PCR-Makefile depend
180 $(MAKE) -f PCR-Makefile
182 $(OBJS) tests/test.o dyn_load.o dyn_load_sunos53.o: \
183 $(srcdir)/include/private/gc_priv.h \
184 $(srcdir)/include/private/gc_hdrs.h $(srcdir)/include/private/gc_locks.h \
185 $(srcdir)/include/gc.h $(srcdir)/include/gc_pthread_redirects.h \
186 $(srcdir)/include/private/gcconfig.h $(srcdir)/include/gc_typed.h \
187 $(srcdir)/include/gc_config_macros.h
189 mark.o typd_mlc.o finalize.o ptr_chck.o: $(srcdir)/include/gc_mark.h \
190 $(srcdir)/include/private/gc_pmark.h
192 specific.o pthread_support.o thread_local_alloc.o win32_threads.o: \
193 $(srcdir)/include/private/specific.h $(srcdir)/include/gc_inline.h \
194 $(srcdir)/include/private/thread_local_alloc.h
196 dbg_mlc.o gcj_mlc.o: $(srcdir)/include/private/dbg_mlc.h
198 tests/test.o: $(srcdir)/tests/test.c
199 mkdir tests || cat /dev/null
200 $(CC) $(CFLAGS) -c $(srcdir)/tests/test.c
201 mv test.o tests/test.o
203 base_lib gc.a: $(OBJS) dyn_load.o $(UTILS)
205 ./if_mach SPARC SOLARIS touch dont_ar_1
206 ./if_mach SPARC SOLARIS $(AR) rus gc.a $(OBJS) dyn_load.o
207 ./if_mach M68K AMIGA touch dont_ar_1
208 ./if_mach M68K AMIGA $(AR) -vrus gc.a $(OBJS) dyn_load.o
209 ./if_not_there dont_ar_1 || $(AR) ru gc.a $(OBJS) dyn_load.o
210 ./if_not_there dont_ar_1 || $(RANLIB) gc.a || cat /dev/null
212 # Ignore ranlib failure; that usually means it doesn't exist, and
215 cords cord.a: $(CORD_OBJS) $(UTILS)
217 ./if_mach SPARC SOLARIS touch dont_ar_3
218 ./if_mach SPARC SOLARIS $(AR) rus cord.a $(CORD_OBJS)
219 ./if_mach M68K AMIGA touch dont_ar_3
220 ./if_mach M68K AMIGA $(AR) -vrus cord.a $(CORD_OBJS)
221 ./if_not_there dont_ar_3 || $(AR) ru cord.a $(CORD_OBJS)
222 ./if_not_there dont_ar_3 || $(RANLIB) cord.a || cat /dev/null
225 gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h
226 $(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
228 test_cpp$(EXEEXT): $(srcdir)/tests/test_cpp.cc $(srcdir)/include/gc_cpp.h \
229 $(srcdir)/include/gc.h c++ base_lib $(UTILS)
230 rm -f test_cpp$(EXEEXT)
231 ./if_mach HP_PA HPUX $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/tests/test_cpp.cc gc.a gccpp.a -ldld `./threadlibs`
232 ./if_not_there test_cpp$(EXEEXT) || $(CXX) $(CXXFLAGS) -DGC_NOT_DLL -o test_cpp$(EXEEXT) $(srcdir)/tests/test_cpp.cc gc.a gccpp.a `./threadlibs`
234 check-cpp: test_cpp$(EXEEXT)
237 c++-t: c++ test_cpp$(EXEEXT)
241 @echo "Use ./test_cpp 1 to test the leak library"
243 c++ gccpp.a: gc_cpp.o $(UTILS)
245 ./if_mach SPARC SOLARIS touch dont_ar_4
246 ./if_mach SPARC SOLARIS $(AR) rus gccpp.a gc_cpp.o
247 ./if_mach M68K AMIGA touch dont_ar_4
248 ./if_mach M68K AMIGA $(AR) -vrus gccpp.a gc_cpp.o
249 ./if_not_there dont_ar_4 || $(AR) ru gccpp.a gc_cpp.o
250 ./if_not_there dont_ar_4 || $(RANLIB) gccpp.a || cat /dev/null
253 dyn_load_sunos53.o: dyn_load.c
254 $(CC) $(CFLAGS) -DSUNOS53_SHARED_LIB -c $(srcdir)/dyn_load.c -o $@
256 # SunOS5 shared library version of the collector
257 sunos5gc.so: $(OBJS) dyn_load_sunos53.o
258 $(CC) -G -o sunos5gc.so $(OBJS) dyn_load_sunos53.o -ldl
259 ln sunos5gc.so libgc.so
261 # Alpha/OSF shared library version of the collector
262 libalphagc.so: $(OBJS)
263 $(LD) -shared -o libalphagc.so $(OBJS) dyn_load.o -lc
264 ln libalphagc.so libgc.so
266 # IRIX shared library version of the collector
267 libirixgc.so: $(OBJS) dyn_load.o
268 $(LD) -shared $(ABI_FLAG) -o libirixgc.so $(OBJS) dyn_load.o -lc
269 ln libirixgc.so libgc.so
271 # Linux shared library version of the collector
272 liblinuxgc.so: $(OBJS) dyn_load.o
273 gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o
274 ln liblinuxgc.so libgc.so
276 # Build gctest with dynamic library
278 $(CC) $(CFLAGS) -o gctest$(EXEEXT) tests/test.c libgc.so `./threadlibs`
281 # Alternative Linux rule. This is preferable, but is likely to break the
282 # Makefile for some non-linux platforms.
283 # LIBOBJS= $(patsubst %.o, %.lo, $(OBJS))
285 #.SUFFIXES: .lo $(SUFFIXES)
288 # $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c $< -o $@
290 # liblinuxgc.so: $(LIBOBJS) dyn_load.lo
291 # gcc -shared -Wl,-soname=libgc.so.0 -o libgc.so.0 $(LIBOBJS) dyn_load.lo
292 # touch liblinuxgc.so
294 mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/sparc_mach_dep.S \
295 $(srcdir)/ia64_save_regs_in_stack.s \
296 $(srcdir)/sparc_netbsd_mach_dep.s $(UTILS)
298 ./if_mach SPARC SOLARIS $(CC) -c -o mach_dep2.o $(srcdir)/sparc_mach_dep.S
299 ./if_mach SPARC OPENBSD $(CC) -c -o mach_dep2.o $(srcdir)/sparc_mach_dep.S
300 ./if_mach SPARC NETBSD $(AS) -o mach_dep2.o $(srcdir)/sparc_netbsd_mach_dep.s
301 ./if_mach SPARC "" $(CC) -c -o mach_dep1.o $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
302 ./if_mach SPARC "" $(LD) -r -o mach_dep.o mach_dep1.o mach_dep2.o
303 ./if_mach IA64 "" $(AS) -o ia64_save_regs_in_stack.o $(srcdir)/ia64_save_regs_in_stack.s
304 ./if_mach IA64 "" $(CC) -c -o mach_dep1.o $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
305 ./if_mach IA64 "" $(LD) -r -o mach_dep.o mach_dep1.o ia64_save_regs_in_stack.o
306 -./if_not_there mach_dep.o || $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
307 -./if_not_there mach_dep.o || `cygpath -w /bin/sh` $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
308 -./if_not_there mach_dep.o || /bin/sh $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
310 mark_rts.o: $(srcdir)/mark_rts.c $(UTILS)
312 -./if_mach ALPHA OSF1 $(CC) -c $(CFLAGS) -Wo,-notail $(srcdir)/mark_rts.c
313 -./if_not_there mark_rts.o || $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c
314 -./if_not_there mark_rts.o || `cygpath -w /bin/sh` $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c
315 -./if_not_there mark_rts.o || /bin/sh $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c
316 # Work-around for DEC optimizer tail recursion elimination bug.
317 # The ALPHA-specific line should be removed if gcc is used.
319 alloc.o: include/gc_version.h
321 cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES)
322 $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordbscs.c
323 mkdir cord || cat /dev/null
324 mv cordbscs.o cord/cordbscs.o
325 # not all compilers understand -o filename
327 cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES)
328 $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordxtra.c
329 mkdir cord || cat /dev/null
330 mv cordxtra.o cord/cordxtra.o
332 cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES)
333 $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordprnt.c
334 mkdir cord || cat /dev/null
335 mv cordprnt.o cord/cordprnt.o
337 cordtest$(EXEEXT): $(srcdir)/cord/tests/cordtest.c cords base_lib $(UTILS)
338 rm -f cordtest$(EXEEXT)
339 ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cordtest $(srcdir)/cord/tests/cordtest.c gc.a cord.a -lucb
340 ./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o cordtest $(srcdir)/cord/tests/cordtest.c gc.a cord.a -ldld `./threadlibs`
341 ./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o cordtest $(srcdir)/cord/tests/cordtest.c gc.a cord.a `./threadlibs`
342 ./if_not_there cordtest$(EXEEXT) || $(CC) $(CFLAGS) -o cordtest$(EXEEXT) $(srcdir)/cord/tests/cordtest.c gc.a cord.a `./threadlibs`
346 de$(EXEEXT): $(srcdir)/cord/tests/de.c $(srcdir)/cord/tests/de_win.c \
347 $(srcdir)/cord/tests/de_win.h cords base_lib $(UTILS)
349 ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o de $(srcdir)/cord/tests/de.c gc.a cord.a -lcurses -ltermlib -lucb `./threadlibs`
350 ./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o de $(srcdir)/cord/tests/de.c gc.a cord.a -lcurses -ltermlib -ldld `./threadlibs`
351 ./if_mach POWERPC AIX $(CC) $(CFLAGS) -o de $(srcdir)/cord/tests/de.c gc.a cord.a -lcurses
352 ./if_mach POWERPC DARWIN $(CC) $(CFLAGS) -o de $(srcdir)/cord/tests/de.c gc.a cord.a
353 ./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o de $(srcdir)/cord/tests/de.c gc.a cord.a -lcurses
354 ./if_not_there de$(EXEEXT) || $(CC) $(CFLAGS) -o de$(EXEEXT) $(srcdir)/cord/tests/de.c $(srcdir)/cord/tests/de_win.c gc.a cord.a $(CURSES) `./threadlibs`
356 if_mach$(EXEEXT): $(srcdir)/tools/if_mach.c \
357 $(srcdir)/include/private/gcconfig.h
358 $(HOSTCC) $(HOSTCFLAGS) -o if_mach$(EXEEXT) $(srcdir)/tools/if_mach.c
360 threadlibs$(EXEEXT): $(srcdir)/tools/threadlibs.c \
361 $(srcdir)/include/private/gcconfig.h
362 $(HOSTCC) $(HOSTCFLAGS) -o threadlibs$(EXEEXT) $(srcdir)/tools/threadlibs.c
364 if_not_there$(EXEEXT): $(srcdir)/tools/if_not_there.c
365 $(HOSTCC) $(HOSTCFLAGS) -o if_not_there$(EXEEXT) $(srcdir)/tools/if_not_there.c
368 rm -f *.a *.i *.o *.exe tests/*.o gctest gctest_dyn_link test_cpp \
369 setjmp_test mon.out gmon.out a.out core if_not_there if_mach \
370 base_lib c++ $(CORD_OBJS) cordtest de cords dont_ar_* threadlibs
373 gctest$(EXEEXT): tests/test.o base_lib $(UTILS)
374 rm -f gctest$(EXEEXT)
375 ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest tests/test.o gc.a -lucb
376 ./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o gctest tests/test.o gc.a -ldld `./threadlibs`
377 ./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o gctest tests/test.o gc.a `./threadlibs`
378 ./if_not_there gctest$(EXEEXT) || $(CC) $(CFLAGS) -o gctest$(EXEEXT) tests/test.o gc.a `./threadlibs`
380 # If an optimized setjmp_test generates a segmentation fault,
381 # odds are your compiler is broken. Gctest may still work.
382 # Try compiling setjmp_t.c unoptimized.
383 setjmp_test$(EXEEXT): $(srcdir)/tools/setjmp_t.c $(srcdir)/include/gc.h \
385 $(CC) $(CFLAGS) -o setjmp_test$(EXEEXT) $(srcdir)/tools/setjmp_t.c
387 check: cordtest$(EXEEXT) gctest$(EXEEXT) setjmp_test$(EXEEXT) test_cpp$(EXEEXT)
393 # A synonym to "check" (for compatibility with older GC versions).
396 # BTL: added to test shared library version of collector.
397 # Currently works only under SunOS5. Requires GC_INIT call from statically
398 # loaded client code.
400 gctest_dyn_link: tests/test.o libgc.so
401 $(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link tests/test.o -lgc -ldl -lthread
403 gctest_irix_dyn_link: tests/test.o libirixgc.so
404 $(CC) -L$(ABSDIR) -o gctest_irix_dyn_link tests/test.o -lirixgc
408 reserved_namespace: $(SRCS)
409 for file in $(SRCS) tests/test.c tests/test_cpp.cc; do \
410 sed s/GC_/_GC_/g < $$file > tmp; \
414 user_namespace: $(SRCS)
415 for file in $(SRCS) tests/test.c tests/test_cpp.cc; do \
416 sed s/_GC_/GC_/g < $$file > tmp; \