Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile fixes #14

Merged
merged 3 commits into from
Dec 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ OBJCONV = objconv

CPPFLAGS_add = -I$(LIBOSXUNWIND_HOME)/src -I$(LIBOSXUNWIND_HOME)/include -DNDEBUG
CFLAGS_add = -std=c99 -Wall -O3
CXXFLAGS_add = -std=c++11 -Wall -O3
LDFLAGS_add = -nodefaultlibs -Wl,-upward-lSystem -Wl,-umbrella,System
SFLAGS_add = -x assembler-with-cpp

# If `-stdlib=` is specified within our environment variables, then don't add another command line argument asking to link against it..
ifneq (,$(findstring -stdlib=,$(CC) $(CPPFLAGS) $(CXXFLAGS)))
# If our clang is new enough, then we need to add in `-stdlib=libstdc++`.
CLANG_MAJOR_VER := $(shell clang -v 2>&1 | grep LLVM | cut -d' ' -f 4 | cut -d'.' -f 1)
ifeq ($(shell [ $(CLANG_MAJOR_VER) -ge 8 ] && echo true),true)
CXXFLAGS_add = -std=c++11 -stdlib=libstdc++ -Wall -O3
LDFLAGS_add = -nodefaultlibs -stdlib=libstdc++ -Wl,-upward-lSystem -Wl,-umbrella,System
CXXFLAGS_add += -stdlib=libstdc++
LDFLAGS_add += -stdlib=libstdc++
else
CXXFLAGS_add = -std=c++11 -Wall -O3
LDFLAGS_add = -nodefaultlibs -Wl,-upward-lSystem -Wl,-umbrella,System -lstdc++
LDFLAGS_add += -lstdc++
endif
endif

# Files (in src/)
Expand Down Expand Up @@ -60,7 +65,8 @@ OBJS = $(patsubst %.c,%.c.o, \
$(CC) $(CPPFLAGS_add) $(CPPFLAGS) $(CXXFLAGS_add) $(CXXFLAGS) -c $< -o $@

%.s.o: %.s
$(CC) $(SFLAGS) $(SFLAGS_add) $(filter -m% -B% -I% -D%,$(CFLAGS_add)) -c $< -o $@
$(CC) $(SFLAGS_add) $(SFLAGS) $(filter -m% -B% -I% -D%,$(CFLAGS_add)) -c $< -o $@



libosxunwind.a: $(OBJS)
Expand All @@ -77,4 +83,4 @@ libosxunwind.dylib: $(OBJS)
clean:
rm -f $(OBJS) *.a *.dylib
distclean: clean
.SUFFIXES: .cxx