MinGW build: some GNUMakefile tweaks.
Added architecture autodetection; added switches to CFLAGS and RCFLAGS to make sure that the right architecture is used. Added support to build with WinCNG.
This commit is contained in:
parent
46f017e751
commit
e4ba5fabec
@ -17,11 +17,6 @@ ifndef OPENSSL_PATH
|
|||||||
OPENSSL_PATH = ../../openssl-0.9.8y
|
OPENSSL_PATH = ../../openssl-0.9.8y
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Edit the var below to set to your architecture or set environment var.
|
|
||||||
ifndef ARCH
|
|
||||||
ARCH = w32
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Edit the path below to point to your Distribution folder.
|
# Edit the path below to point to your Distribution folder.
|
||||||
ifndef DISTDIR
|
ifndef DISTDIR
|
||||||
DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-$(ARCH)
|
DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-$(ARCH)
|
||||||
@ -95,14 +90,24 @@ else
|
|||||||
CC = $(CROSSPREFIX)gcc
|
CC = $(CROSSPREFIX)gcc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Set environment var ARCH to your architecture to override autodetection.
|
||||||
|
ifndef ARCH
|
||||||
|
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||||
|
ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
|
||||||
|
ARCH = w64
|
||||||
|
else
|
||||||
|
ARCH = w32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ARCH = w32
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# Include the version info retrieved from libssh2.h
|
# Include the version info retrieved from libssh2.h
|
||||||
-include $(OBJDIR)/version.inc
|
-include $(OBJDIR)/version.inc
|
||||||
|
|
||||||
# Global flags for all compilers
|
# Global flags for all compilers
|
||||||
CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||||
ifeq ($(ARCH),w64)
|
|
||||||
CFLAGS += -D_AMD64_
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CC),mwcc)
|
ifeq ($(CC),mwcc)
|
||||||
LD = mwld
|
LD = mwld
|
||||||
@ -129,13 +134,26 @@ LIBEXT = a
|
|||||||
RANLIB = $(CROSSPREFIX)ranlib
|
RANLIB = $(CROSSPREFIX)ranlib
|
||||||
#LDLIBS += -lwsock32
|
#LDLIBS += -lwsock32
|
||||||
LDLIBS += -lws2_32
|
LDLIBS += -lws2_32
|
||||||
RCFLAGS = -I. -I ../include -O coff -i
|
RCFLAGS = -I ../include -O coff
|
||||||
|
CFLAGS += -fno-builtin
|
||||||
CFLAGS += -fno-strict-aliasing
|
CFLAGS += -fno-strict-aliasing
|
||||||
CFLAGS += -Wall # -pedantic
|
CFLAGS += -Wall # -pedantic
|
||||||
|
ifeq ($(ARCH),w64)
|
||||||
|
CFLAGS += -D_AMD64_
|
||||||
|
RCFLAGS += -F pe-x86-64
|
||||||
|
else
|
||||||
|
CFLAGS += -m32
|
||||||
|
RCFLAGS += -F pe-i386
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
INCLUDES = -I. -I../include
|
INCLUDES = -I. -I../include
|
||||||
|
|
||||||
|
ifdef WITH_WINCNG
|
||||||
|
CFLAGS += -DLIBSSH2_WINCNG
|
||||||
|
LDLIBS += -lbcrypt -lcrypt32
|
||||||
|
else
|
||||||
|
CFLAGS += -DLIBSSH2_OPENSSL
|
||||||
ifndef OPENSSL_INCLUDE
|
ifndef OPENSSL_INCLUDE
|
||||||
ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
|
ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
|
||||||
OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
|
OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
|
||||||
@ -164,6 +182,7 @@ ifdef LINK_OPENSSL_STATIC
|
|||||||
else
|
else
|
||||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef WITH_ZLIB
|
ifdef WITH_ZLIB
|
||||||
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
||||||
@ -177,11 +196,13 @@ endif
|
|||||||
|
|
||||||
CFLAGS += $(INCLUDES)
|
CFLAGS += $(INCLUDES)
|
||||||
|
|
||||||
vpath %.c . ../src
|
vpath %.c ../src
|
||||||
|
|
||||||
# only OpenSSL is supported with this build system
|
ifdef WITH_WINCNG
|
||||||
CFLAGS += -DLIBSSH2_OPENSSL
|
include ../Makefile.WinCNG.inc
|
||||||
|
else
|
||||||
include ../Makefile.OpenSSL.inc
|
include ../Makefile.OpenSSL.inc
|
||||||
|
endif
|
||||||
|
|
||||||
# include Makefile.inc to get CSOURCES define
|
# include Makefile.inc to get CSOURCES define
|
||||||
include ../Makefile.inc
|
include ../Makefile.inc
|
||||||
@ -237,7 +258,7 @@ dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
|||||||
@echo Creating $(DEVLARC)
|
@echo Creating $(DEVLARC)
|
||||||
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||||||
|
|
||||||
distclean: clean
|
distclean vclean: clean
|
||||||
$(call RMDIR, $(DISTDIR))
|
$(call RMDIR, $(DISTDIR))
|
||||||
$(call DEL, $(DISTARC))
|
$(call DEL, $(DISTARC))
|
||||||
|
|
||||||
@ -281,7 +302,7 @@ $(TARGET).dll $(TARGET)dll.a: $(OBJL)
|
|||||||
|
|
||||||
$(OBJDIR)/%.res: %.rc
|
$(OBJDIR)/%.res: %.rc
|
||||||
@echo Creating $@
|
@echo Creating $@
|
||||||
@$(RC) $(RCFLAGS) $< -o $@
|
@$(RC) $(RCFLAGS) -i $< -o $@
|
||||||
|
|
||||||
|
|
||||||
$(DISTDIR)/readme.txt: GNUmakefile
|
$(DISTDIR)/readme.txt: GNUmakefile
|
||||||
|
Loading…
Reference in New Issue
Block a user