Skip to content

Commit

Permalink
Fixed Makefile errors and warnings on Mac/clang build environments.
Browse files Browse the repository at this point in the history
  • Loading branch information
asaparov committed Apr 26, 2020
1 parent 84efdc9 commit 4b484ec
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,45 @@ MATH_INDUCTION_OBJS=$(MATH_INDUCTION_CPP_SRCS:.cpp=.release.o)
# Compile and link options
#

CPP=g++
cc-option = $(shell $(CPP) -Werror $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; echo $$?)

LIBRARY_PKG_LIBS=
PKG_LIBS=-Wl,--no-as-needed -lpthread
GLIBC := $(word 2,$(shell getconf GNU_LIBC_VERSION))
GLIBC_HAS_RT := $(shell expr $(GLIBC) \>= 2.17)
ifeq "$(GLIBC_HAS_RT)" "0"
LIBRARY_PKG_LIBS += -lrt
PKG_LIBS += -lrt
PKG_LIBS=-pthread
NO_AS_NEEDED=-Wl,--no-as-needed
ifeq ($(call cc-option, $(NO_AS_NEEDED)),0)
PKG_LIBS += $(NO_AS_NEEDED)
endif
GLIBC := $(word 2,$(shell getconf GNU_LIBC_VERSION 2>/dev/null))
ifeq "$(.SHELLSTATUS)" "0"
GLIBC_HAS_RT := $(shell expr $(GLIBC) \>= 2.17)
ifeq "$(GLIBC_HAS_RT)" "0"
LIBRARY_PKG_LIBS += -lrt
PKG_LIBS += -lrt
endif
endif

CPP=g++
WARNING_FLAGS=-Wall -Wpedantic
override CPPFLAGS_DBG += $(WARNING_FLAGS) -I. -g -march=native -std=c++11 $(PKG_LIBS)
override CPPFLAGS += $(WARNING_FLAGS) -I. -O3 -DNDEBUG -march=native -std=c++11 -fno-stack-protector $(PKG_LIBS)
override LDFLAGS_DBG += -g $(LIB_PATHS)
override LDFLAGS += $(LIB_PATHS) -fwhole-program
override CPPFLAGS_DBG += $(WARNING_FLAGS) -I. -g -march=native -mtune=native -std=c++11
override CPPFLAGS += $(WARNING_FLAGS) -I. -Ofast -DNDEBUG -march=native -mtune=native -std=c++11 -fno-stack-protector
override LDFLAGS_DBG += -g $(LIB_PATHS) $(PKG_LIBS)
override LDFLAGS += $(LIB_PATHS) -fwhole-program $(PKG_LIBS)


#
# GNU Make: targets that don't build files
#

.PHONY: all debug clean distclean

#
# Compile command
# Make targets
#

all: pcfg_induction

debug: pcfg_induction_dbg

-include $(PCFG_INDUCTION_OBJS:.release.o=.release.d)
-include $(PCFG_INDUCTION_DBG_OBJS:.debug.o=.debug.d)
-include $(MATH_INDUCTION_OBJS:.release.o=.release.d)
Expand All @@ -65,21 +83,6 @@ endef
%.debug.pic.o: %.cpp
$(call make_dependencies,$(CPP),$(CPPFLAGS_DBG),$*,cpp,debug.pic)


#
# GNU Make: targets that don't build files
#

.PHONY: all debug clean distclean

#
# Make targets
#

all: pcfg_induction

debug: pcfg_induction_dbg

pcfg_induction: $(LIBS) $(PCFG_INDUCTION_OBJS)
$(CPP) -o pcfg_induction $(CPPFLAGS) $(LDFLAGS) $(PCFG_INDUCTION_OBJS)

Expand All @@ -94,6 +97,3 @@ math_induction_dbg: $(LIBS) $(MATH_INDUCTION_DBG_OBJS)

clean:
${RM} -f *.o */*.o */*/*.o *.d */*.d */*/*.d pcfg_induction pcfg_induction.exe pcfg_induction_dbg pcfg_induction_dbg.exe math_induction math_induction.exe math_induction_dbg math_induction_dbg.exe $(LIBS)

distclean: clean
${RM} -f *~

0 comments on commit 4b484ec

Please sign in to comment.