BuildSystem: Permit to differentiate between native DLL and CYGWIN DLL.
authorJerome Benoit <jerome.benoit@sap.com>
Tue, 21 Mar 2017 17:57:35 +0000 (18:57 +0100)
committerJerome Benoit <jerome.benoit@sap.com>
Tue, 21 Mar 2017 17:57:35 +0000 (18:57 +0100)
Signed-off-by: Jerome Benoit <jerome.benoit@sap.com>
TP_13/exo2/Makefile

index ef4bea820c001b420090747984e25060341ed981..88bc97f74f9aeab370e6a1a634a800c94d822eb0 100644 (file)
 #
 # Automatic dependencies code from:
 # http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#tldr
-BINARY_NAME=exo2
+BINARY_NAME:=exo2
 SRC_PATH:=src
-LIBRARY_NAME=libexo2
+LIBRARY_NAME:=libexo2
 LIBRARY_PATH:=lib
-LDLIBS=-lncurses -ltinfo
-BUILD_TYPE=debug
+LDLIBS:=-lncurses -ltinfo
+BUILD_TYPE:=debug
 #BUILD_TYPE=release
 
 # ====================================
@@ -73,12 +73,13 @@ DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$(notdir $*).Td
 POSTCOMPILE = mv -f $(DEPDIR)/$(notdir $*).Td $(DEPDIR)/$(notdir $*).d
 
 ifeq ($(UNAME),Cygwin)
+CYGWIN_DLIBRARY_NAME := $(subst lib,cyg,$(LIBRARY_NAME))
 GOLD_SUPPORT = no
 # Cygwin ncurses do not contain tinfo
 LDLIBS := $(filter-out -ltinfo,$(LDLIBS))
 BINARY_SUFFIX := .exe
 DLIB_SUFFIX := .dll
-CYGWIN_LDLIBS_NOARCHIVE = -lncurses
+CYGWIN_LDLIBS_NOARCHIVE := $(LDLIBS)
 CYGWIN_LIBLDFLAGS := -Wl,--out-implib=$(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a \
     -Wl,--export-all-symbols \
     -Wl,--enable-auto-import
@@ -109,8 +110,8 @@ $(LIBRARY_PATH)/$(SLIB_PREFIX)$(LIBRARY_NAME)$(SLIB_SUFFIX): $(LIBOBJS)
        @$(AR) rcs $@ $^
 
 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)
+$(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a: $(LIBRARY_PATH)/$(DLIB_PREFIX)$(CYGWIN_DLIBRARY_NAME)$(DLIB_SUFFIX)
+$(LIBRARY_PATH)/$(DLIB_PREFIX)$(CYGWIN_DLIBRARY_NAME)$(DLIB_SUFFIX): $(LIBOBJS)
        @echo "[LD DLL] $@"
        @$(LD) $(LIBCFLAGS) $(LIBLDFLAGS) $(CYGWIN_LIBLDFLAGS) -Wl,--whole-archive $^ -Wl,--no-whole-archive $(CYGWIN_LDLIBS_NOARCHIVE) -o $@
 else
@@ -166,9 +167,11 @@ clean:
        -@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)$(CYGWIN_DLIBRARY_NAME)$(DLIB_SUFFIX)
        -@rm $(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX).a
+else
+       -@rm $(LIBRARY_PATH)/$(DLIB_PREFIX)$(LIBRARY_NAME)$(DLIB_SUFFIX)
 endif
 
 disassemble: $(BINARY_NAME)$(BINARY_SUFFIX)