299 lines
7.6 KiB
Makefile
299 lines
7.6 KiB
Makefile
|
#################################################################
|
||
|
#
|
||
|
## Makefile for building libssh2 (Win32 version - gnu make)
|
||
|
## Use: make -f Makefile.win32 [help|all|clean|dev|devclean|dist|distclean|objclean]
|
||
|
##
|
||
|
## Comments to: Guenter Knauf <eflash@gmx.net>
|
||
|
#
|
||
|
#################################################################
|
||
|
|
||
|
# Edit the path below to point to the base of your Zlib sources.
|
||
|
ifndef ZLIB_PATH
|
||
|
ZLIB_PATH = ../../zlib-1.2.3
|
||
|
endif
|
||
|
|
||
|
# Edit the path below to point to the base of your OpenSSL package.
|
||
|
ifndef OPENSSL_PATH
|
||
|
OPENSSL_PATH = ../../openssl-0.9.8d
|
||
|
endif
|
||
|
|
||
|
# Edit the path below to point to your Distribution folder.
|
||
|
ifndef DISTDIR
|
||
|
DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-w32
|
||
|
endif
|
||
|
DISTARC = $(DISTDIR).zip
|
||
|
|
||
|
# Edit the path below to point to your Development folder.
|
||
|
ifndef DEVLDIR
|
||
|
DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-w32
|
||
|
endif
|
||
|
DEVLARC = $(DEVLDIR).zip
|
||
|
|
||
|
# Edit the vars below to change target settings.
|
||
|
TARGET = libssh2
|
||
|
VERSION = $(LIBSSH2_VERSION)
|
||
|
COPYR = (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
||
|
WWWURL = http://www.libssh2.org/
|
||
|
DESCR = libssh2 $(LIBSSH2_VERSION_STR)
|
||
|
#STACK = 64000
|
||
|
|
||
|
# must be equal to DEBUG or NDEBUG
|
||
|
DB = NDEBUG
|
||
|
# DB = DEBUG
|
||
|
# Optimization: -O<n> or debugging: -g
|
||
|
ifeq ($(DB),NDEBUG)
|
||
|
OPT = -O2
|
||
|
OBJDIR = release
|
||
|
else
|
||
|
OPT = -g
|
||
|
OBJDIR = debug
|
||
|
endif
|
||
|
|
||
|
# Include the version info retrieved from libssh2.h
|
||
|
-include $(OBJDIR)/version.inc
|
||
|
|
||
|
# The following line defines your compiler.
|
||
|
ifdef METROWERKS
|
||
|
CC = mwcc
|
||
|
else
|
||
|
CC = gcc
|
||
|
endif
|
||
|
CP = cp -afv
|
||
|
# RM = rm -f
|
||
|
AWK = awk
|
||
|
ZIP = zip -qzr9
|
||
|
|
||
|
# Global flags for all compilers
|
||
|
CFLAGS = $(OPT) -D$(DB) -DWIN32 -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||
|
|
||
|
ifeq ($(CC),mwcc)
|
||
|
LD = mwld
|
||
|
RC = mwwinrc
|
||
|
LDFLAGS = -nostdlib
|
||
|
AR = $(LD)
|
||
|
ARFLAGS = -type library -w nocmdline $(OBJS) -o
|
||
|
LIBEXT = lib
|
||
|
LIBPATH += -lr "$(METROWERKS)/MSL" -lr "$(METROWERKS)/Win32-x86 Support"
|
||
|
LDLIBS += -lMSL_Runtime_x86.lib -lMSL_C_x86.lib -lMSL_Extras_x86.lib
|
||
|
LDLIBS += -lkernel32.lib -luser32.lib -lwsock32.lib
|
||
|
RCFLAGS =
|
||
|
CFLAGS += -nostdinc -gccinc -msgstyle gcc -inline off -opt nointrinsics -proc 586
|
||
|
CFLAGS += -ir "$(METROWERKS)/MSL" -ir "$(METROWERKS)/Win32-x86 Support"
|
||
|
CFLAGS += -w on,nounused,nounusedexpr # -ansi strict
|
||
|
else
|
||
|
LD = gcc
|
||
|
RC = windres
|
||
|
LDFLAGS = -s -shared -Wl,--out-implib,$(TARGET)dll.a
|
||
|
AR = ar
|
||
|
ARFLAGS = -cq
|
||
|
LIBEXT = a
|
||
|
#LDLIBS += -lwsock32
|
||
|
LDLIBS += -lws2_32
|
||
|
RCFLAGS = -O coff -i
|
||
|
CFLAGS += -fno-strict-aliasing -Wall -Wno-unused # -pedantic
|
||
|
endif
|
||
|
|
||
|
INCLUDES = -I. -I../include
|
||
|
INCLUDES += -I$(OPENSSL_PATH)/outinc -I$(OPENSSL_PATH)/outinc/openssl
|
||
|
|
||
|
ifdef LINK_STATIC
|
||
|
LDLIBS += $(OPENSSL_PATH)/out/libcrypto.$(LIBEXT) $(OPENSSL_PATH)/out/libssl.$(LIBEXT)
|
||
|
else
|
||
|
LDLIBS += $(OPENSSL_PATH)/out/libeay32.$(LIBEXT) $(OPENSSL_PATH)/out/libssl32.$(LIBEXT)
|
||
|
endif
|
||
|
|
||
|
ifdef WITH_ZLIB
|
||
|
INCLUDES += -I$(ZLIB_PATH)
|
||
|
LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
|
||
|
endif
|
||
|
|
||
|
CFLAGS += $(INCLUDES)
|
||
|
|
||
|
#ifeq ($(findstring linux,$(OSTYPE)),linux)
|
||
|
ifdef __MSYS__
|
||
|
DL = '
|
||
|
DS = /
|
||
|
else
|
||
|
DS = \\
|
||
|
endif
|
||
|
|
||
|
vpath %.c . ../src
|
||
|
|
||
|
OBJECTS = \
|
||
|
channel.o \
|
||
|
comp.o \
|
||
|
crypt.o \
|
||
|
hostkey.o \
|
||
|
kex.o \
|
||
|
mac.o \
|
||
|
misc.o \
|
||
|
openssl.o \
|
||
|
packet.o \
|
||
|
pem.o \
|
||
|
publickey.o \
|
||
|
scp.o \
|
||
|
session.o \
|
||
|
sftp.o \
|
||
|
userauth.o
|
||
|
|
||
|
OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
|
||
|
OBJL = $(OBJS) $(OBJDIR)/$(TARGET).res
|
||
|
|
||
|
all: lib dll
|
||
|
|
||
|
dll: prebuild $(TARGET).dll
|
||
|
|
||
|
lib: prebuild $(TARGET).$(LIBEXT)
|
||
|
|
||
|
prebuild: $(OBJDIR) $(OBJDIR)/version.inc
|
||
|
# libssh2_config.h
|
||
|
|
||
|
test: all
|
||
|
$(MAKE) -C test -f Makefile.win32
|
||
|
|
||
|
$(OBJDIR)/%.o: %.c
|
||
|
# @echo Compiling $<
|
||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||
|
|
||
|
$(OBJDIR)/version.inc: ../include/libssh2.h $(OBJDIR)
|
||
|
@echo Creating $@
|
||
|
@$(AWK) -f ../get_ver.awk $< > $@
|
||
|
|
||
|
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||
|
@-mkdir $(DISTDIR)$(DS)bin
|
||
|
@-$(CP) ../INSTALL $(DISTDIR)
|
||
|
@-$(CP) ../LICENSE $(DISTDIR)
|
||
|
@-$(CP) ../README $(DISTDIR)
|
||
|
@$(CP) $(TARGET).dll $(DISTDIR)/bin
|
||
|
@echo Creating $(DISTARC)
|
||
|
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||
|
|
||
|
dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
||
|
@-mkdir $(DEVLDIR)$(DS)bin
|
||
|
@-mkdir $(DEVLDIR)$(DS)include
|
||
|
@-mkdir $(DEVLDIR)$(DS)win32
|
||
|
@-$(CP) ../INSTALL $(DEVLDIR)
|
||
|
@-$(CP) ../LICENSE $(DEVLDIR)
|
||
|
@-$(CP) ../README $(DEVLDIR)
|
||
|
@$(CP) $(TARGET).dll $(DEVLDIR)/bin
|
||
|
@$(CP) ../include/*.h $(DEVLDIR)/include
|
||
|
@$(CP) libssh2_config.h $(DEVLDIR)/include
|
||
|
@$(CP) *.$(LIBEXT) $(DEVLDIR)/win32
|
||
|
@echo Creating $(DEVLARC)
|
||
|
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||
|
|
||
|
distclean: clean
|
||
|
-$(RM) -r $(DISTDIR)
|
||
|
-$(RM) $(DISTARC)
|
||
|
|
||
|
devclean: clean
|
||
|
-$(RM) -r $(DEVLDIR)
|
||
|
-$(RM) $(DEVLARC)
|
||
|
|
||
|
objclean: all
|
||
|
-$(RM) -r $(OBJDIR)
|
||
|
|
||
|
testclean: clean
|
||
|
$(MAKE) -C test -f Makefile.win32 clean
|
||
|
|
||
|
clean:
|
||
|
# -$(RM) libssh2_config.h
|
||
|
-$(RM) $(TARGET).dll $(TARGET).$(LIBEXT) $(TARGET)dll.$(LIBEXT)
|
||
|
-$(RM) -r $(OBJDIR)
|
||
|
|
||
|
$(OBJDIR):
|
||
|
@mkdir $@
|
||
|
|
||
|
$(DISTDIR):
|
||
|
@mkdir $@
|
||
|
|
||
|
$(DEVLDIR):
|
||
|
@mkdir $@
|
||
|
|
||
|
$(TARGET).$(LIBEXT): $(OBJS)
|
||
|
@echo Creating $@
|
||
|
@-$(RM) $@
|
||
|
@$(AR) $(ARFLAGS) $@ $^
|
||
|
|
||
|
$(TARGET).dll $(TARGET)dll.a: $(OBJL)
|
||
|
@echo Linking $@
|
||
|
@-$(RM) $@
|
||
|
@$(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
|
||
|
|
||
|
|
||
|
$(OBJDIR)/%.res: $(OBJDIR)/%.rc
|
||
|
@echo Creating $@
|
||
|
@$(RC) $(RCFLAGS) $< -o $@
|
||
|
|
||
|
$(OBJDIR)/%.rc: Makefile.win32 $(OBJDIR)/version.inc
|
||
|
@echo 1 VERSIONINFO > $@
|
||
|
@echo FILEVERSION $(LIBSSH2_VERSION),0 >> $@
|
||
|
@echo PRODUCTVERSION $(LIBSSH2_VERSION),0 >> $@
|
||
|
@echo FILEFLAGSMASK 0x3fL >> $@
|
||
|
@echo FILEOS 0x40004L >> $@
|
||
|
@echo FILEFLAGS 0x0L >> $@
|
||
|
@echo FILETYPE 0x1L >> $@
|
||
|
@echo FILESUBTYPE 0x0L >> $@
|
||
|
@echo BEGIN >> $@
|
||
|
@echo BLOCK "StringFileInfo" >> $@
|
||
|
@echo BEGIN >> $@
|
||
|
@echo BLOCK "040904E4" >> $@
|
||
|
@echo BEGIN >> $@
|
||
|
@echo VALUE "LegalCopyright","$(COPYR)\0" >> $@
|
||
|
ifdef COMPANY
|
||
|
@echo VALUE "CompanyName","$(COMPANY)\0" >> $@
|
||
|
endif
|
||
|
@echo VALUE "ProductName","$(notdir $(@:.rc=.dll))\0" >> $@
|
||
|
@echo VALUE "ProductVersion","$(LIBSSH2_VERSION_STR)\0" >> $@
|
||
|
@echo VALUE "License","Released under GPL.\0" >> $@
|
||
|
@echo VALUE "FileDescription","$(DESCR)\0" >> $@
|
||
|
@echo VALUE "FileVersion","$(LIBSSH2_VERSION_STR)\0" >> $@
|
||
|
@echo VALUE "InternalName","$(notdir $(@:.rc=))\0" >> $@
|
||
|
@echo VALUE "OriginalFilename","$(notdir $(@:.rc=.dll))\0" >> $@
|
||
|
@echo VALUE "WWW","$(WWWURL)\0" >> $@
|
||
|
@echo END >> $@
|
||
|
@echo END >> $@
|
||
|
@echo BLOCK "VarFileInfo" >> $@
|
||
|
@echo BEGIN >> $@
|
||
|
@echo VALUE "Translation", 0x409, 1252 >> $@
|
||
|
@echo END >> $@
|
||
|
@echo END >> $@
|
||
|
ifdef ICON
|
||
|
@echo 10 ICON DISCARDABLE "$(ICON)" >> $@
|
||
|
endif
|
||
|
|
||
|
$(DISTDIR)/readme.txt: Makefile.win32
|
||
|
@echo Creating $@
|
||
|
@echo $(DL)This is a binary distribution for Win32 platform.$(DL) > $@
|
||
|
@echo $(DL)libssh version $(LIBSSH2_VERSION_STR)$(DL) >> $@
|
||
|
@echo $(DL)Please download the complete libssh package for$(DL) >> $@
|
||
|
@echo $(DL)any further documentation:$(DL) >> $@
|
||
|
@echo $(DL)$(WWWURL)$(DL) >> $@
|
||
|
|
||
|
$(DEVLDIR)/readme.txt: Makefile.win32
|
||
|
@echo Creating $@
|
||
|
@echo $(DL)This is a development distribution for Win32 platform.$(DL) > $@
|
||
|
@echo $(DL)libssh version $(LIBSSH2_VERSION_STR)$(DL) >> $@
|
||
|
@echo $(DL)Please download the complete libssh package for$(DL) >> $@
|
||
|
@echo $(DL)any further documentation:$(DL) >> $@
|
||
|
@echo $(DL)$(WWWURL)$(DL) >> $@
|
||
|
|
||
|
help: $(OBJDIR)/version.inc
|
||
|
@echo $(DL)===========================================================$(DL)
|
||
|
@echo $(DL)OpenSSL path = $(OPENSSL_PATH)$(DL)
|
||
|
@echo $(DL)Zlib path = $(ZLIB_PATH)$(DL)
|
||
|
@echo $(DL)===========================================================$(DL)
|
||
|
@echo $(DL)libssh $(LIBSSH2_VERSION_STR) - available targets are:$(DL)
|
||
|
@echo $(DL)$(MAKE) all$(DL)
|
||
|
@echo $(DL)$(MAKE) dll$(DL)
|
||
|
@echo $(DL)$(MAKE) lib$(DL)
|
||
|
@echo $(DL)$(MAKE) clean$(DL)
|
||
|
@echo $(DL)$(MAKE) dev$(DL)
|
||
|
@echo $(DL)$(MAKE) devclean$(DL)
|
||
|
@echo $(DL)$(MAKE) dist$(DL)
|
||
|
@echo $(DL)$(MAKE) distclean$(DL)
|
||
|
@echo $(DL)$(MAKE) objclean$(DL)
|
||
|
@echo $(DL)===========================================================$(DL)
|
||
|
|
||
|
|