BuildSystem: Even more sync to latest
authorJerome Benoit <jerome.benoit@sap.com>
Mon, 20 Mar 2017 16:45:36 +0000 (17:45 +0100)
committerJerome Benoit <jerome.benoit@sap.com>
Mon, 20 Mar 2017 16:45:36 +0000 (17:45 +0100)
Signed-off-by: Jerome Benoit <jerome.benoit@sap.com>
TP_11/exo2/Makefile
TP_13/exo1/Makefile

index d8dd23abf8ad190ea85e2fad57ea90069e80bd91..8246f9bbbf236949dd6933f0c6702a99922b60c6 100644 (file)
@@ -28,8 +28,6 @@ BUILD_TYPE=debug
 # DO NOT CHANGE STUFF BEYOND THIS LINE
 # ====================================
 
-all: $(BINARY_NAME) $(BINARY_NAME).dynamic $(BINARY_NAME).static
-
 CC=gcc
 LD=gcc
 AR=ar
@@ -54,8 +52,33 @@ LTO_SUPPORT = yes
 GOLD_SUPPORT = yes
 endif
 
+BINARY_SUFFIX :=
+DLIB_PREFIX :=
+SDLIB_PREFIX :=
+DLIB_SUFFIX := .so
+SLIB_SUFFIX := .a
+
+OBJDIR := $(BUILDDIR)/objs
+$(shell mkdir -p $(OBJDIR))
+
+SRCS=$(wildcard $(SRC_PATH)/*.c)
+LIBSRCS=$(wildcard $(LIBRARY_PATH)/*.c)
+OBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SRCS)))
+LIBOBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(LIBSRCS)))
+
+DEPDIR := $(BUILDDIR)/deps
+$(shell mkdir -p $(DEPDIR))
+DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$(notdir $*).Td
+POSTCOMPILE = mv -f $(DEPDIR)/$(notdir $*).Td $(DEPDIR)/$(notdir $*).d
+
 ifeq ($(UNAME),Cygwin)
 GOLD_SUPPORT = no
+BINARY_SUFFIX := .exe
+DLIB_SUFFIX := .dll
+CYGWIN_LDLIBS_NOARCHIVE =
+CYGWIN_LIBLDFLAGS := -Wl,--out-implib=$(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a \
+    -Wl,--export-all-symbols \
+    -Wl,--enable-auto-import
 endif
 
 ifeq ($(LTO_SUPPORT),yes)
@@ -67,49 +90,49 @@ 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) $(CFLAGS_LTO) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES)
+# Putting header files in the source directory is not the purpose of this INCLUDES_PATH variable
+INCLUDES_PATH := $(INCLUDES_PATH) -I$(LIBRARY_PATH)
+CFLAGS := $(CFLAGS) $(CFLAGS_LTO) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES_PATH)
 LIBCFLAGS := -fPIC $(CFLAGS)
 LDFLAGS := $(LDFLAGS) $(LDFLAGS_LTO) $(LDFLAGS_GOLD) $(STRIP_FLAG)
 LIBLDFLAGS := -shared $(LDFLAGS)
 STATICLIBLDFLAGS := -static $(LDFLAGS)
 LDLIBS := $(LDLIBS) -L$(LIBRARY_PATH) -l$(BINARY_NAME)
 
-OBJDIR := $(BUILDDIR)/objs
-$(shell mkdir -p $(OBJDIR))
+all: $(BINARY_NAME)$(BINARY_SUFFIX) $(BINARY_NAME).dynamic$(BINARY_SUFFIX) $(BINARY_NAME).static$(BINARY_SUFFIX)
 
-SRCS=$(wildcard $(SRC_PATH)/*.c)
-LIBSRCS=$(wildcard $(LIBRARY_PATH)/*.c)
-OBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SRCS)))
-LIBOBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(LIBSRCS)))
-
-DEPDIR := $(BUILDDIR)/deps
-$(shell mkdir -p $(DEPDIR))
-DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$(notdir $*).Td
-POSTCOMPILE = mv -f $(DEPDIR)/$(notdir $*).Td $(DEPDIR)/$(notdir $*).d
-
-$(LIBRARY_PATH)/$(LIBRARY_NAME).a: $(LIBOBJS)
+$(LIBRARY_PATH)/$(SLIB_PREFIX)$(LIBRARY_NAME)$(SLIB_SUFFIX): $(LIBOBJS)
        @echo "[AR StO] $@"
        @$(AR) rcs $@ $^
 
-$(LIBRARY_PATH)/$(LIBRARY_NAME).so: $(LIBOBJS)
+ifeq ($(UNAME),Cygwin)
+$(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a: $(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX)
+$(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX): $(LIBOBJS)
+       @echo "[LD DLL] $@"
+       @$(LD) $(LIBCFLAGS) $(LIBLDFLAGS) $(CYGWIN_LIBLDFLAGS) -Wl,--whole-archive $^ -Wl,--no-whole-archive $(CYGWIN_LDLIBS_NOARCHIVE) -o $@
+else
+$(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX): $(LIBOBJS)
        @echo "[LD ShO] $@"
        @$(LD) $(LIBCFLAGS) $(LIBLDFLAGS) $^ -o $@
+endif
 
-#$(BINARY_NAME): $(OBJS) $(LIBOBJS)
+#$(BINARY_NAME)$(BINARY_SUFFIX): $(OBJS) $(LIBOBJS)
 #      @echo "[LD ] $@"
 #      @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
 
-$(BINARY_NAME): $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a
+$(BINARY_NAME)$(BINARY_SUFFIX): $(OBJS) $(LIBRARY_PATH)/$(SLIB_PREFIX)$(LIBRARY_NAME)$(SLIB_SUFFIX)
        @echo "[LD ] $@"
        @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
 
-$(BINARY_NAME).static: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a
+$(BINARY_NAME).static$(BINARY_SUFFIX): $(OBJS) $(LIBRARY_PATH)/$(SLIB_PREFIX)$(LIBRARY_NAME)$(SLIB_SUFFIX)
        @echo "[LD ] $@"
        @$(LD) $(CFLAGS) $(STATICLIBLDFLAGS) $^ $(LDLIBS) -o $@
 
-$(BINARY_NAME).dynamic: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).so
+ifeq ($(UNAME),Cygwin)
+$(BINARY_NAME).dynamic$(BINARY_SUFFIX): $(OBJS) $(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a
+else
+$(BINARY_NAME).dynamic$(BINARY_SUFFIX): $(OBJS) $(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX)
+endif
        @echo "[LD ] $@"
        @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
 
@@ -136,14 +159,17 @@ $(DEPDIR)/%.d: ;
 clean:
        @echo "[CLN]"
        -@rm -r $(BUILDDIR)
-       -@rm $(BINARY_NAME)
-       -@rm $(BINARY_NAME).static
-       -@rm $(BINARY_NAME).dynamic
-       -@rm $(LIBRARY_PATH)/$(LIBRARY_NAME).a
-       -@rm $(LIBRARY_PATH)/$(LIBRARY_NAME).so
+       -@rm $(BINARY_NAME)$(BINARY_SUFFIX)
+       -@rm $(BINARY_NAME).static$(BINARY_SUFFIX)
+       -@rm $(BINARY_NAME).dynamic$(BINARY_SUFFIX)
+       -@rm $(LIBRARY_PATH)/$(SLIB_PREFIX)$(LIBRARY_NAME)$(SLIB_SUFFIX)
+       -@rm $(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX)
+ifeq ($(UNAME),Cygwin)
+       -@rm $(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a
+endif
 
-disassemble: $(BINARY_NAME)
+disassemble: $(BINARY_NAME)$(BINARY_SUFFIX)
        objdump -d $< | less
 
-symbols: $(BINARY_NAME)
+symbols: $(BINARY_NAME)$(BINARY_SUFFIX)
        objdump -t $< | sort | less
index c4259967d6af06a453366049cd3f321f835a5f0f..14935a2fd8dc79e9181f3b6f5673762de50e7387 100644 (file)
@@ -75,7 +75,7 @@ ifeq ($(UNAME),Cygwin)
 GOLD_SUPPORT = no
 BINARY_SUFFIX := .exe
 DLIB_SUFFIX := .dll
-CYGWIN_LDLIBS_NOARCHIVE = -lncurses
+CYGWIN_LDLIBS_NOARCHIVE =
 CYGWIN_LIBLDFLAGS := -Wl,--out-implib=$(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a \
     -Wl,--export-all-symbols \
     -Wl,--enable-auto-import