diff --git a/win32/GNUmakefile b/win32/GNUmakefile index d49614f..3a74665 100644 --- a/win32/GNUmakefile +++ b/win32/GNUmakefile @@ -29,6 +29,9 @@ DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-$(ARCH) endif DEVLARC = $(DEVLDIR).zip +# Project root +PROOT = .. + # Edit the vars below to change target settings. TARGET = libssh2 WWWURL = http://www.libssh2.org/ @@ -134,7 +137,7 @@ LIBEXT = a RANLIB = $(CROSSPREFIX)ranlib #LDLIBS += -lwsock32 LDLIBS += -lws2_32 -RCFLAGS = -I ../include -O coff +RCFLAGS = -I $(PROOT)/include -O coff CFLAGS += -fno-builtin CFLAGS += -fno-strict-aliasing CFLAGS += -Wall # -pedantic @@ -147,7 +150,7 @@ RCFLAGS += -F pe-i386 endif endif -INCLUDES = -I. -I../include +INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include ifdef WITH_WINCNG CFLAGS += -DLIBSSH2_WINCNG @@ -196,21 +199,22 @@ endif CFLAGS += $(INCLUDES) -vpath %.c ../src +vpath %.c $(PROOT)/src ifdef WITH_WINCNG -include ../Makefile.WinCNG.inc +include $(PROOT)/Makefile.WinCNG.inc else -include ../Makefile.OpenSSL.inc +include $(PROOT)/Makefile.OpenSSL.inc endif # include Makefile.inc to get CSOURCES define -include ../Makefile.inc +include $(PROOT)/Makefile.inc OBJECTS := $(patsubst %.c,%.o,$(CSOURCES)) OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS)) OBJL = $(OBJS) $(OBJDIR)/$(TARGET).res + all: lib dll dll: prebuild $(TARGET).dll @@ -227,17 +231,17 @@ $(OBJDIR)/%.o: %.c # @echo Compiling $< $(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 $@ @$(AWK) -f $^ > $@ dist: all $(DISTDIR) $(DISTDIR)/readme.txt @$(call MKDIR, $(DISTDIR)/bin) - @$(call COPY, ../AUTHORS, $(DISTDIR)) - @$(call COPY, ../COPYING, $(DISTDIR)) - @$(call COPY, ../INSTALL, $(DISTDIR)) - @$(call COPY, ../README, $(DISTDIR)) - @$(call COPY, ../RELEASE-NOTES, $(DISTDIR)) + @$(call COPY, $(PROOT)/AUTHORS, $(DISTDIR)) + @$(call COPY, $(PROOT)/COPYING, $(DISTDIR)) + @$(call COPY, $(PROOT)/INSTALL, $(DISTDIR)) + @$(call COPY, $(PROOT)/README, $(DISTDIR)) + @$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR)) @$(call COPY, $(TARGET).dll, $(DISTDIR)/bin) @echo Creating $(DISTARC) @$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt @@ -246,13 +250,13 @@ dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt @$(call MKDIR, $(DEVLDIR)/bin) @$(call MKDIR, $(DEVLDIR)/include) @$(call MKDIR, $(DEVLDIR)/win32) - @$(call COPY, ../AUTHORS, $(DEVLDIR)) - @$(call COPY, ../COPYING, $(DEVLDIR)) - @$(call COPY, ../INSTALL, $(DEVLDIR)) - @$(call COPY, ../README, $(DEVLDIR)) - @$(call COPY, ../RELEASE-NOTES, $(DEVLDIR)) + @$(call COPY, $(PROOT)/AUTHORS, $(DEVLDIR)) + @$(call COPY, $(PROOT)/COPYING, $(DEVLDIR)) + @$(call COPY, $(PROOT)/INSTALL, $(DEVLDIR)) + @$(call COPY, $(PROOT)/README, $(DEVLDIR)) + @$(call COPY, $(PROOT)/RELEASE-NOTES, $(DEVLDIR)) @$(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, *.$(LIBEXT), $(DEVLDIR)/win32) @echo Creating $(DEVLARC) diff --git a/win32/test/GNUmakefile b/win32/test/GNUmakefile index 7f902c6..530a069 100644 --- a/win32/test/GNUmakefile +++ b/win32/test/GNUmakefile @@ -17,16 +17,14 @@ ifndef OPENSSL_PATH OPENSSL_PATH = ../../../openssl-0.9.8y endif -# Edit the var below to set to your architecture or set environment var. -ifndef ARCH -ARCH = w32 -endif +# Project root +PROOT = ../.. # Edit the var below to enable static linking of libssh2 and libz LINK_STATIC = 1 # 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)))) WWWURL = http://www.libssh2.org/ DESCR = libssh2 $(subst .rc,,$(notdir $@)) $(LIBSSH2_VERSION_STR) @@ -86,14 +84,24 @@ else CC = $(CROSSPREFIX)gcc 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 $(OBJDIR)/version.inc # Global flags for all compilers CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H -ifeq ($(ARCH),w64) -CFLAGS += -D_AMD64_ -endif ifeq ($(CC),mwcc) LD = mwld @@ -118,13 +126,21 @@ ARFLAGS = -cq LIBEXT = a #LDLIBS += -lwsock32 LDLIBS += -lws2_32 -RCFLAGS = -O coff -i +RCFLAGS = -I $(PROOT)/include -O coff +CFLAGS += -fno-builtin CFLAGS += -fno-strict-aliasing 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 -INCLUDES = -I.. -I../../include -LIBPATH += -L.. +INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include +LIBPATH += -L$(PROOT)/win32 ifdef LINK_STATIC LDLIBS += -llibssh2 @@ -132,6 +148,11 @@ else LDLIBS += -llibssh2dll endif +ifdef WITH_WINCNG +# CFLAGS += -DLIBSSH2_WINCNG +LDLIBS += -lbcrypt -lcrypt32 +else +# CFLAGS += -DLIBSSH2_OPENSSL ifndef OPENSSL_INCLUDE ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc" OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc @@ -162,6 +183,7 @@ else LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN)) endif endif +endif ifdef WITH_ZLIB CFLAGS += -DLIBSSH2_HAVE_ZLIB @@ -175,7 +197,7 @@ endif CFLAGS += $(INCLUDES) -vpath %.c ../../example +vpath %.c $(PROOT)/example .PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.rc $(OBJDIR)/%.res @@ -188,9 +210,9 @@ $(OBJDIR)/%.o: %.c # @echo Compiling $< $(CC) $(CFLAGS) -c $< -o $@ -$(OBJDIR)/version.inc: ../../include/libssh2.h $(OBJDIR) +$(OBJDIR)/version.inc: $(PROOT)/include/libssh2.h $(OBJDIR) @echo Creating $@ - @$(AWK) -f ../../get_ver.awk $< > $@ + @$(AWK) -f $(PROOT)/get_ver.awk $< > $@ objclean: $(call RMDIR, $(OBJDIR)) @@ -208,7 +230,7 @@ $(OBJDIR): $(OBJDIR)/%.res: $(OBJDIR)/%.rc @echo Creating $@ - @$(RC) $(RCFLAGS) $< -o $@ + @$(RC) $(RCFLAGS) -i $< -o $@ $(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc @echo $(DL)1 VERSIONINFO$(DL) > $@