X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_11%2Fexo2%2FMakefile;h=d8dd23abf8ad190ea85e2fad57ea90069e80bd91;hb=5d64063095177554839e67ddc73193929f115d07;hp=d1ca467374630fe66c8f0d5fbb373b2eb028c211;hpb=25dc671f8b36ed62a1d2b689347902a122493782;p=TD_C.git diff --git a/TP_11/exo2/Makefile b/TP_11/exo2/Makefile index d1ca467..d8dd23a 100644 --- a/TP_11/exo2/Makefile +++ b/TP_11/exo2/Makefile @@ -36,24 +36,42 @@ AR=ar WARN_FLAGS = -Wall -Wextra STD_FLAG = -std=c11 +UNAME := $(shell uname -o) ifeq ($(BUILD_TYPE),debug) BUILDDIR := .build/debug DEBUG_FLAG = -g STRIP_FLAG = OPTI_FLAG = -O0 +LTO_SUPPORT = yes +GOLD_SUPPORT = yes else BUILDDIR := .build/release DEBUG_FLAG = STRIP_FLAG = -s OPTI_FLAG = -O3 +LTO_SUPPORT = yes +GOLD_SUPPORT = yes +endif + +ifeq ($(UNAME),Cygwin) +GOLD_SUPPORT = no +endif + +ifeq ($(LTO_SUPPORT),yes) +CFLAGS_LTO = -flto -ffat-lto-objects +LDFLAGS_LTO = -fuse-linker-plugin -flto +endif + +ifeq ($(GOLD_SUPPORT),yes) +LDFLAGS_GOLD = -fuse-ld=gold endif # Putting header files in the source directory is not the purpose of this INCLUDES variable INCLUDES := $(INCLUDES) -I$(LIBRARY_PATH) -CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES) +CFLAGS := $(CFLAGS) $(CFLAGS_LTO) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES) LIBCFLAGS := -fPIC $(CFLAGS) -LDFLAGS := $(LDFLAGS) $(STRIP_FLAG) +LDFLAGS := $(LDFLAGS) $(LDFLAGS_LTO) $(LDFLAGS_GOLD) $(STRIP_FLAG) LIBLDFLAGS := -shared $(LDFLAGS) STATICLIBLDFLAGS := -static $(LDFLAGS) LDLIBS := $(LDLIBS) -L$(LIBRARY_PATH) -l$(BINARY_NAME)