tools: use pkg-config to found libgc
authorJean Privat <jean@pryen.org>
Sat, 1 Nov 2014 18:06:17 +0000 (14:06 -0400)
committerJean Privat <jean@pryen.org>
Mon, 3 Nov 2014 15:01:39 +0000 (10:01 -0500)
In some platform (macosx+macports), the libgc library is not located at
standard default position.
Fortunately, libgc seems to be registered with pkg-config under most
platforms.

Thus, use pkg-config in the generated makefiles to found the correct
flags and paths.

In c_src, some generated files are manually modified to provide a
working bootstrap under those platforms.

This is only a quick-and-dirty workaround. The real job must be polished
and generalized to solve the issue #864.

Reported-by: Alexandre Blondin Massé <alexandre.blondin.masse@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

c_src/Makefile
c_src/abstract_compiler.sep.1.c
src/compiler/abstract_compiler.nit

index db97fe4..40131db 100644 (file)
@@ -3,7 +3,7 @@ CXX = ccache c++
 CFLAGS = -g -O2 -Wno-unused-value -Wno-switch
 CINCL = 
 LDFLAGS ?= 
-LDLIBS  ?= -lm -lgc 
+LDLIBS  ?= -lm `pkg-config --libs bdw-gc` 
 
 NEED_LIBUNWIND := YesPlease
 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
@@ -315,7 +315,7 @@ c_functions_hash.extern.o: c_functions_hash.c
        $(CC) $(CFLAGS)  -c -o c_functions_hash.extern.o c_functions_hash.c
 
 gc_chooser.extern.o: gc_chooser.c
-       $(CC) $(CFLAGS) -DWITH_LIBGC -c -o gc_chooser.extern.o gc_chooser.c
+       $(CC) $(CFLAGS) -DWITH_LIBGC `pkg-config --cflags bdw-gc` -c -o gc_chooser.extern.o gc_chooser.c
 
 string._ffi.extern.o: string._ffi.c
        $(CC) $(CFLAGS)  -c -o string._ffi.extern.o string._ffi.c
index da573c6..e9e6534 100644 (file)
@@ -3498,8 +3498,8 @@ abstract_compiler__AbstractCompiler__build_c_to_nit_bindings(var_compiler); /* D
 if (varonce26) {
 var27 = varonce26;
 } else {
-var28 = "-DWITH_LIBGC";
-var29 = 12;
+var28 = "-DWITH_LIBGC `pkg-config --cflags bdw-gc` ";
+var29 = 42;
 var30 = string__NativeString__to_s_with_length(var28, var29);
 var27 = var30;
 varonce26 = var27;
@@ -5985,8 +5985,8 @@ varonce65 = var66;
 if (varonce70) {
 var71 = varonce70;
 } else {
-var72 = "\nLDFLAGS ?= \nLDLIBS  ?= -lm -lgc ";
-var73 = 33;
+var72 = "\nLDFLAGS ?= \nLDLIBS  ?= -lm `pkg-config --libs bdw-gc`";
+var73 = 55;
 var74 = string__NativeString__to_s_with_length(var72, var73);
 var71 = var74;
 varonce70 = var71;
index 008e8f1..e3c2fdf 100644 (file)
@@ -225,7 +225,7 @@ class MakefileToolchain
        do
                var platform = compiler.mainmodule.target_platform
                if self.toolcontext.opt_stacktrace.value == "nitstack" and (platform == null or platform.supports_libunwind) then compiler.build_c_to_nit_bindings
-               var cc_opt_with_libgc = "-DWITH_LIBGC"
+               var cc_opt_with_libgc = "-DWITH_LIBGC `pkg-config --cflags bdw-gc`"
                if platform != null and not platform.supports_libgc then cc_opt_with_libgc = ""
 
                # Add gc_choser.h to aditionnal bodies
@@ -363,7 +363,7 @@ class MakefileToolchain
                        if libs != null then linker_options.add_all(libs)
                end
 
-               makefile.write("CC = ccache cc\nCXX = ccache c++\nCFLAGS = -g -O2 -Wno-unused-value -Wno-switch\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS  ?= -lm -lgc {linker_options.join(" ")}\n\n")
+               makefile.write("CC = ccache cc\nCXX = ccache c++\nCFLAGS = -g -O2 -Wno-unused-value -Wno-switch\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS  ?= -lm `pkg-config --libs bdw-gc` {linker_options.join(" ")}\n\n")
 
                var ost = toolcontext.opt_stacktrace.value
                if (ost == "libunwind" or ost == "nitstack") and (platform == null or platform.supports_libunwind) then makefile.write("NEED_LIBUNWIND := YesPlease\n")