MinGW build: some more GNUMakefile tweaks.
test/GNUmakefile: 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
3260beb07a
commit
600f26ce6e
@ -29,6 +29,9 @@ DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-$(ARCH)
|
|||||||
endif
|
endif
|
||||||
DEVLARC = $(DEVLDIR).zip
|
DEVLARC = $(DEVLDIR).zip
|
||||||
|
|
||||||
|
# Project root
|
||||||
|
PROOT = ..
|
||||||
|
|
||||||
# Edit the vars below to change target settings.
|
# Edit the vars below to change target settings.
|
||||||
TARGET = libssh2
|
TARGET = libssh2
|
||||||
WWWURL = http://www.libssh2.org/
|
WWWURL = http://www.libssh2.org/
|
||||||
@ -134,7 +137,7 @@ LIBEXT = a
|
|||||||
RANLIB = $(CROSSPREFIX)ranlib
|
RANLIB = $(CROSSPREFIX)ranlib
|
||||||
#LDLIBS += -lwsock32
|
#LDLIBS += -lwsock32
|
||||||
LDLIBS += -lws2_32
|
LDLIBS += -lws2_32
|
||||||
RCFLAGS = -I ../include -O coff
|
RCFLAGS = -I $(PROOT)/include -O coff
|
||||||
CFLAGS += -fno-builtin
|
CFLAGS += -fno-builtin
|
||||||
CFLAGS += -fno-strict-aliasing
|
CFLAGS += -fno-strict-aliasing
|
||||||
CFLAGS += -Wall # -pedantic
|
CFLAGS += -Wall # -pedantic
|
||||||
@ -147,7 +150,7 @@ RCFLAGS += -F pe-i386
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
INCLUDES = -I. -I../include
|
INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include
|
||||||
|
|
||||||
ifdef WITH_WINCNG
|
ifdef WITH_WINCNG
|
||||||
CFLAGS += -DLIBSSH2_WINCNG
|
CFLAGS += -DLIBSSH2_WINCNG
|
||||||
@ -196,21 +199,22 @@ endif
|
|||||||
|
|
||||||
CFLAGS += $(INCLUDES)
|
CFLAGS += $(INCLUDES)
|
||||||
|
|
||||||
vpath %.c ../src
|
vpath %.c $(PROOT)/src
|
||||||
|
|
||||||
ifdef WITH_WINCNG
|
ifdef WITH_WINCNG
|
||||||
include ../Makefile.WinCNG.inc
|
include $(PROOT)/Makefile.WinCNG.inc
|
||||||
else
|
else
|
||||||
include ../Makefile.OpenSSL.inc
|
include $(PROOT)/Makefile.OpenSSL.inc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# include Makefile.inc to get CSOURCES define
|
# include Makefile.inc to get CSOURCES define
|
||||||
include ../Makefile.inc
|
include $(PROOT)/Makefile.inc
|
||||||
|
|
||||||
OBJECTS := $(patsubst %.c,%.o,$(CSOURCES))
|
OBJECTS := $(patsubst %.c,%.o,$(CSOURCES))
|
||||||
OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
|
OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
|
||||||
OBJL = $(OBJS) $(OBJDIR)/$(TARGET).res
|
OBJL = $(OBJS) $(OBJDIR)/$(TARGET).res
|
||||||
|
|
||||||
|
|
||||||
all: lib dll
|
all: lib dll
|
||||||
|
|
||||||
dll: prebuild $(TARGET).dll
|
dll: prebuild $(TARGET).dll
|
||||||
@ -227,17 +231,17 @@ $(OBJDIR)/%.o: %.c
|
|||||||
# @echo Compiling $<
|
# @echo Compiling $<
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(OBJDIR)/version.inc: ../get_ver.awk ../include/libssh2.h $(OBJDIR)
|
$(OBJDIR)/version.inc: $(PROOT)/get_ver.awk $(PROOT)/include/libssh2.h $(OBJDIR)
|
||||||
@echo Creating $@
|
@echo Creating $@
|
||||||
@$(AWK) -f $^ > $@
|
@$(AWK) -f $^ > $@
|
||||||
|
|
||||||
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||||
@$(call MKDIR, $(DISTDIR)/bin)
|
@$(call MKDIR, $(DISTDIR)/bin)
|
||||||
@$(call COPY, ../AUTHORS, $(DISTDIR))
|
@$(call COPY, $(PROOT)/AUTHORS, $(DISTDIR))
|
||||||
@$(call COPY, ../COPYING, $(DISTDIR))
|
@$(call COPY, $(PROOT)/COPYING, $(DISTDIR))
|
||||||
@$(call COPY, ../INSTALL, $(DISTDIR))
|
@$(call COPY, $(PROOT)/INSTALL, $(DISTDIR))
|
||||||
@$(call COPY, ../README, $(DISTDIR))
|
@$(call COPY, $(PROOT)/README, $(DISTDIR))
|
||||||
@$(call COPY, ../RELEASE-NOTES, $(DISTDIR))
|
@$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR))
|
||||||
@$(call COPY, $(TARGET).dll, $(DISTDIR)/bin)
|
@$(call COPY, $(TARGET).dll, $(DISTDIR)/bin)
|
||||||
@echo Creating $(DISTARC)
|
@echo Creating $(DISTARC)
|
||||||
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||||||
@ -246,13 +250,13 @@ dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
|||||||
@$(call MKDIR, $(DEVLDIR)/bin)
|
@$(call MKDIR, $(DEVLDIR)/bin)
|
||||||
@$(call MKDIR, $(DEVLDIR)/include)
|
@$(call MKDIR, $(DEVLDIR)/include)
|
||||||
@$(call MKDIR, $(DEVLDIR)/win32)
|
@$(call MKDIR, $(DEVLDIR)/win32)
|
||||||
@$(call COPY, ../AUTHORS, $(DEVLDIR))
|
@$(call COPY, $(PROOT)/AUTHORS, $(DEVLDIR))
|
||||||
@$(call COPY, ../COPYING, $(DEVLDIR))
|
@$(call COPY, $(PROOT)/COPYING, $(DEVLDIR))
|
||||||
@$(call COPY, ../INSTALL, $(DEVLDIR))
|
@$(call COPY, $(PROOT)/INSTALL, $(DEVLDIR))
|
||||||
@$(call COPY, ../README, $(DEVLDIR))
|
@$(call COPY, $(PROOT)/README, $(DEVLDIR))
|
||||||
@$(call COPY, ../RELEASE-NOTES, $(DEVLDIR))
|
@$(call COPY, $(PROOT)/RELEASE-NOTES, $(DEVLDIR))
|
||||||
@$(call COPY, $(TARGET).dll, $(DEVLDIR)/bin)
|
@$(call COPY, $(TARGET).dll, $(DEVLDIR)/bin)
|
||||||
@$(call COPY, ../include/*.h, $(DEVLDIR)/include)
|
@$(call COPY, $(PROOT)/include/*.h, $(DEVLDIR)/include)
|
||||||
@$(call COPY, libssh2_config.h, $(DEVLDIR)/include)
|
@$(call COPY, libssh2_config.h, $(DEVLDIR)/include)
|
||||||
@$(call COPY, *.$(LIBEXT), $(DEVLDIR)/win32)
|
@$(call COPY, *.$(LIBEXT), $(DEVLDIR)/win32)
|
||||||
@echo Creating $(DEVLARC)
|
@echo Creating $(DEVLARC)
|
||||||
|
@ -17,16 +17,14 @@ 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.
|
# Project root
|
||||||
ifndef ARCH
|
PROOT = ../..
|
||||||
ARCH = w32
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Edit the var below to enable static linking of libssh2 and libz
|
# Edit the var below to enable static linking of libssh2 and libz
|
||||||
LINK_STATIC = 1
|
LINK_STATIC = 1
|
||||||
|
|
||||||
# Edit the vars below to change target settings.
|
# Edit the vars below to change target settings.
|
||||||
SAMPLES = ../../example
|
SAMPLES = $(PROOT)/example
|
||||||
TARGETS := $(filter-out x11.exe,$(patsubst $(SAMPLES)/%.c,%.exe,$(strip $(wildcard $(SAMPLES)/*.c))))
|
TARGETS := $(filter-out x11.exe,$(patsubst $(SAMPLES)/%.c,%.exe,$(strip $(wildcard $(SAMPLES)/*.c))))
|
||||||
WWWURL = http://www.libssh2.org/
|
WWWURL = http://www.libssh2.org/
|
||||||
DESCR = libssh2 $(subst .rc,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
|
DESCR = libssh2 $(subst .rc,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
|
||||||
@ -86,14 +84,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
|
||||||
@ -118,13 +126,21 @@ ARFLAGS = -cq
|
|||||||
LIBEXT = a
|
LIBEXT = a
|
||||||
#LDLIBS += -lwsock32
|
#LDLIBS += -lwsock32
|
||||||
LDLIBS += -lws2_32
|
LDLIBS += -lws2_32
|
||||||
RCFLAGS = -O coff -i
|
RCFLAGS = -I $(PROOT)/include -O coff
|
||||||
|
CFLAGS += -fno-builtin
|
||||||
CFLAGS += -fno-strict-aliasing
|
CFLAGS += -fno-strict-aliasing
|
||||||
CFLAGS += -Wall #-Wno-unused #-pedantic
|
CFLAGS += -Wall #-Wno-unused #-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$(PROOT)/win32 -I$(PROOT)/include
|
||||||
LIBPATH += -L..
|
LIBPATH += -L$(PROOT)/win32
|
||||||
|
|
||||||
ifdef LINK_STATIC
|
ifdef LINK_STATIC
|
||||||
LDLIBS += -llibssh2
|
LDLIBS += -llibssh2
|
||||||
@ -132,6 +148,11 @@ else
|
|||||||
LDLIBS += -llibssh2dll
|
LDLIBS += -llibssh2dll
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
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
|
||||||
@ -162,6 +183,7 @@ else
|
|||||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef WITH_ZLIB
|
ifdef WITH_ZLIB
|
||||||
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
||||||
@ -175,7 +197,7 @@ endif
|
|||||||
|
|
||||||
CFLAGS += $(INCLUDES)
|
CFLAGS += $(INCLUDES)
|
||||||
|
|
||||||
vpath %.c ../../example
|
vpath %.c $(PROOT)/example
|
||||||
|
|
||||||
.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.rc $(OBJDIR)/%.res
|
.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.rc $(OBJDIR)/%.res
|
||||||
|
|
||||||
@ -188,9 +210,9 @@ $(OBJDIR)/%.o: %.c
|
|||||||
# @echo Compiling $<
|
# @echo Compiling $<
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(OBJDIR)/version.inc: ../../include/libssh2.h $(OBJDIR)
|
$(OBJDIR)/version.inc: $(PROOT)/include/libssh2.h $(OBJDIR)
|
||||||
@echo Creating $@
|
@echo Creating $@
|
||||||
@$(AWK) -f ../../get_ver.awk $< > $@
|
@$(AWK) -f $(PROOT)/get_ver.awk $< > $@
|
||||||
|
|
||||||
objclean:
|
objclean:
|
||||||
$(call RMDIR, $(OBJDIR))
|
$(call RMDIR, $(OBJDIR))
|
||||||
@ -208,7 +230,7 @@ $(OBJDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.res: $(OBJDIR)/%.rc
|
$(OBJDIR)/%.res: $(OBJDIR)/%.rc
|
||||||
@echo Creating $@
|
@echo Creating $@
|
||||||
@$(RC) $(RCFLAGS) $< -o $@
|
@$(RC) $(RCFLAGS) -i $< -o $@
|
||||||
|
|
||||||
$(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc
|
$(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc
|
||||||
@echo $(DL)1 VERSIONINFO$(DL) > $@
|
@echo $(DL)1 VERSIONINFO$(DL) > $@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user