Fix building with musl libc

This commit is contained in:
Kylie McClain 2015-11-05 16:59:29 +00:00 committed by Maxime Coste
parent 788c358720
commit 1ed66e9b6a
2 changed files with 15 additions and 6 deletions

View File

@ -1,4 +1,6 @@
debug ?= yes debug ?= yes
pedantic ?= yes
ifeq ($(debug),yes) ifeq ($(debug),yes)
CPPFLAGS += -DKAK_DEBUG CPPFLAGS += -DKAK_DEBUG
suffix := .debug suffix := .debug
@ -11,6 +13,10 @@ else
endif endif
endif endif
ifeq ($(pedantic),yes)
CXXFLAGS += -pedantic
endif
sources := $(wildcard *.cc) sources := $(wildcard *.cc)
objects := $(addprefix ., $(sources:.cc=$(suffix).o)) objects := $(addprefix ., $(sources:.cc=$(suffix).o))
deps := $(addprefix ., $(sources:.cc=$(suffix).d)) deps := $(addprefix ., $(sources:.cc=$(suffix).d))
@ -22,8 +28,6 @@ bindir := $(DESTDIR)$(PREFIX)/bin
sharedir := $(DESTDIR)$(PREFIX)/share/kak sharedir := $(DESTDIR)$(PREFIX)/share/kak
docdir := $(DESTDIR)$(PREFIX)/share/doc/kak docdir := $(DESTDIR)$(PREFIX)/share/doc/kak
CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare -pedantic
os := $(shell uname) os := $(shell uname)
ifeq ($(os),Darwin) ifeq ($(os),Darwin)
@ -46,6 +50,8 @@ else
LDFLAGS += -rdynamic LDFLAGS += -rdynamic
endif endif
CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare
kak : $(objects) kak : $(objects)
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) $(LIBS) -o $@ $(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) $(LIBS) -o $@

View File

@ -2,21 +2,24 @@
#include "string.hh" #include "string.hh"
#if defined(__linux__) || defined(__APPLE__) #if defined(__GLIBC__) || defined(__APPLE__)
# include <execinfo.h> # include <execinfo.h>
# include <stdlib.h>
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
# include <windows.h> # include <windows.h>
# include <dbghelp.h> # include <dbghelp.h>
# include <stdio.h> # include <stdio.h>
#endif #endif
#if defined(__linux__) || defined(__APPLE__)
# include <stdlib.h>
#endif
namespace Kakoune namespace Kakoune
{ {
Backtrace::Backtrace() Backtrace::Backtrace()
{ {
#if defined(__linux__) || defined(__APPLE__) #if defined(__GLIBC__) || defined(__APPLE__)
num_frames = backtrace(stackframes, max_frames); num_frames = backtrace(stackframes, max_frames);
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
num_frames = CaptureStackBackTrace(0, max_frames, stackframes, nullptr); num_frames = CaptureStackBackTrace(0, max_frames, stackframes, nullptr);
@ -25,7 +28,7 @@ Backtrace::Backtrace()
String Backtrace::desc() const String Backtrace::desc() const
{ {
#if defined(__linux__) || defined(__APPLE__) #if defined(__GLIBC__) || defined(__APPLE__)
char** symbols = backtrace_symbols(stackframes, num_frames); char** symbols = backtrace_symbols(stackframes, num_frames);
ByteCount size = 0; ByteCount size = 0;
for (int i = 0; i < num_frames; ++i) for (int i = 0; i < num_frames; ++i)