CC = ccache cc
-CFLAGS = -g -O2
+CFLAGS = -g -O2 -Wno-unused-value -Wno-switch
CINCL = -I "clib"
LDFLAGS ?=
-LDLIBS ?= -lm -lgc -lunwind
+LDLIBS ?= -lm -lgc
+
+NEED_LIBUNWIND := YesPlease
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+ifeq ($(uname_S),Darwin)
+ NEED_LIBUNWIND :=
+endif
+
+clang_check := $(shell sh -c '$(CC) -v 2>&1 | grep -q clang; echo $$?')
+ifeq ($(clang_check), 0)
+ CFLAGS += -Qunused-arguments
+endif
+ifdef NEED_LIBUNWIND
+ LDLIBS += -lunwind
+endif
all: nitg
# limitations under the License.
NITCOPT=
+OLDNITCOPT= --no-stacktrace
all: ../bin/nitdoc ../bin/nitmetrics ../bin/nitg ../bin/nit ../bin/nitx ../bin/nitunit ../bin/nitlight ../bin/nitls ../bin/nitdbg_client
@echo '* Compile nitg_0 from NIT source files *'
@echo '***************************************************************'
./git-gen-version.sh
- ../c_src/nitg ${NITCOPT} -o nitg_0 -v nitg.nit
+ ../c_src/nitg ${OLDNITCOPT} -o nitg_0 -v nitg.nit
../bin/nitg: nitg_0 parser/parser.nit
@echo '***************************************************************'
if libs != null then linker_options.add_all(libs)
end
+ makefile.write("CC = ccache cc\nCFLAGS = -g -O2 -Wno-unused-value -Wno-switch\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS ?= -lm -lgc {linker_options.join(" ")}\n\n")
+
var ost = toolcontext.opt_stacktrace.value
- if ost == "libunwind" or ost == "nitstack" then linker_options.add("-lunwind")
+ if ost == "libunwind" or ost == "nitstack" then makefile.write("NEED_LIBUNWIND := YesPlease\n")
+
+ # Dynamic adaptations
+ # While `platform` enable complex toolchains, they are statically applied
+ # For a dynamic adaptsation of the compilation, the generated Makefile should check and adapt things itself
+
+ # Check and adapt the targeted system
+ makefile.write("uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n")
+ makefile.write("ifeq ($(uname_S),Darwin)\n")
+ # remove -lunwind since it is already included on macosx
+ makefile.write("\tNEED_LIBUNWIND :=\n")
+ makefile.write("endif\n\n")
+
+ # Check and adapt for the compiler used
+ # clang need an additionnal `-Qunused-arguments`
+ makefile.write("clang_check := $(shell sh -c '$(CC) -v 2>&1 | grep -q clang; echo $$?')\nifeq ($(clang_check), 0)\n\tCFLAGS += -Qunused-arguments\nendif\n")
+
+ makefile.write("ifdef NEED_LIBUNWIND\n\tLDLIBS += -lunwind\nendif\n")
- makefile.write("CC = ccache cc\nCFLAGS = -g -O2\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS ?= -lm -lgc {linker_options.join(" ")}\n\n")
makefile.write("all: {outpath}\n\n")
var ofiles = new Array[String]
# Compile class names (for the class_name and output_class_name methods)
protected fun compile_class_names do
var v = new_visitor
- self.header.add_decl("extern const char const * class_names[];")
- v.add("const char const * class_names[] = \{")
+ self.header.add_decl("extern const char *class_names[];")
+ v.add("const char *class_names[] = \{")
for t in self.runtime_type_analysis.live_types do
v.add("\"{t}\", /* {self.classid(t)} */")
end
perl -i -npe 's#"\.\./.*?([^/]*.h)"#"\1"#' "$out"/*.[ch]
perl -i -npe 's#\S*/([^/]*.[ch])#\1#' "$out/Makefile"
perl -i -npe 's#\.\./clib#.#' "$out/Makefile"
+
+# Remove old compilation flags
+sed -i -e 's/OLDNITCOPT=.*/OLDNITCOPT=/' src/Makefile
-Caught signal : Segmentation fault
+UNDEFINED
-Caught signal : Segmentation fault
+UNDEFINED
# Set lang do default to avoid failed tests because of locale
export LANG=C
+export LC_ALL=C
export NIT_TESTING=true
unset NIT_DIR