1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-21 14:00:51 +03:00

GNUmakefile: cleanups [ci skip] (#840)

- indent
- sync `test/GNUmakefile` with main
- delete `RANLIB`
- use `else if`
- use more `?=`
- use ASCII-7 copyright symbol (in test)
This commit is contained in:
Viktor Szakats
2023-03-11 11:06:42 +01:00
committed by GitHub
parent a273816521
commit 0621f97c7b
2 changed files with 157 additions and 186 deletions

View File

@@ -7,15 +7,14 @@
# #
######################################################################### #########################################################################
# Project root
PROOT := ..
# Edit the path below to point to the base of your Zlib sources. # Edit the path below to point to the base of your Zlib sources.
ifndef ZLIB_PATH ZLIB_PATH ?= $(PROOT)/../zlib
ZLIB_PATH = ../../zlib
endif
# Edit the path below to point to the base of your OpenSSL package. # Edit the path below to point to the base of your OpenSSL package.
ifndef OPENSSL_PATH OPENSSL_PATH ?= $(PROOT)/../openssl
OPENSSL_PATH = ../../openssl
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
@@ -29,9 +28,6 @@ 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 = https://www.libssh2.org/ WWWURL = https://www.libssh2.org/
@@ -39,10 +35,7 @@ DESCR = libssh2 $(LIBSSH2_VERSION_STR)
#STACK = 64000 #STACK = 64000
# must be equal to DEBUG or NDEBUG # must be equal to DEBUG or NDEBUG
ifndef DB DB ?= NDEBUG
DB = NDEBUG
# DB = DEBUG
endif
# Optimization: -O<n> or debugging: -g # Optimization: -O<n> or debugging: -g
ifeq ($(DB),NDEBUG) ifeq ($(DB),NDEBUG)
OPT = -O2 OPT = -O2
@@ -86,37 +79,26 @@ CAT = type
ECHONL = $(ComSpec) /c echo. ECHONL = $(ComSpec) /c echo.
endif endif
ifeq ($(LIBSSH2_RC),) LIBSSH2_RC ?= $(CROSSPREFIX)windres
LIBSSH2_RC := $(CROSSPREFIX)windres LIBSSH2_CC ?= $(CROSSPREFIX)gcc
endif LIBSSH2_AR ?= $(CROSSPREFIX)ar
ifeq ($(LIBSSH2_CC),)
LIBSSH2_CC := $(CROSSPREFIX)gcc
endif
ifeq ($(LIBSSH2_AR),)
LIBSSH2_AR := $(CROSSPREFIX)ar
endif
ifeq ($(LIBSSH2_RANLIB),)
LIBSSH2_RANLIB := $(CROSSPREFIX)ranlib
endif
ifeq ($(LIBSSH2_DLL_A_SUFFIX),)
LIBSSH2_DLL_A_SUFFIX := dll
endif
LIBSSH2_DLL_A_SUFFIX ?= dll
libssh2_dll_LIBRARY = $(TARGET)$(LIBSSH2_DLL_SUFFIX).dll libssh2_dll_LIBRARY = $(TARGET)$(LIBSSH2_DLL_SUFFIX).dll
CC = $(LIBSSH2_CC) CC = $(LIBSSH2_CC)
# Set environment var ARCH to your architecture to override autodetection. # Set environment var ARCH to your architecture to override autodetection.
ifndef ARCH ifndef ARCH
ifeq ($(findstring gcc,$(CC)),gcc) ifeq ($(findstring gcc,$(CC)),gcc)
ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64) ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
ARCH = w64 ARCH = w64
else else
ARCH = w32 ARCH = w32
endif endif
else else
ARCH = w32 ARCH = w32
endif endif
endif endif
# Include the version info retrieved from libssh2.h # Include the version info retrieved from libssh2.h
@@ -132,49 +114,45 @@ RC = $(LIBSSH2_RC)
LDFLAGS += -s -shared -Wl,--output-def,$(libssh2_dll_LIBRARY:.dll=.def),--out-implib,$(TARGET)$(LIBSSH2_DLL_A_SUFFIX).$(LIBEXT) LDFLAGS += -s -shared -Wl,--output-def,$(libssh2_dll_LIBRARY:.dll=.def),--out-implib,$(TARGET)$(LIBSSH2_DLL_A_SUFFIX).$(LIBEXT)
AR = $(LIBSSH2_AR) AR = $(LIBSSH2_AR)
ARFLAGS = cru ARFLAGS = cru
RANLIB = $(LIBSSH2_RANLIB)
RCFLAGS = -I $(PROOT)/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
ifeq ($(ARCH),w64) ifeq ($(ARCH),w64)
CFLAGS += -m64 CFLAGS += -m64
LDFLAGS += -m64 LDFLAGS += -m64
RCFLAGS += -F pe-x86-64 RCFLAGS += -F pe-x86-64
else else ifeq ($(ARCH),w32)
ifeq ($(ARCH),w32) CFLAGS += -m32
CFLAGS += -m32 LDFLAGS += -m32
LDFLAGS += -m32 RCFLAGS += -F pe-i386
RCFLAGS += -F pe-i386
endif
endif endif
INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include
ifdef WITH_WINCNG ifdef WITH_WINCNG
CFLAGS += -DLIBSSH2_WINCNG CFLAGS += -DLIBSSH2_WINCNG
LDLIBS += -lbcrypt -lcrypt32 LDLIBS += -lbcrypt -lcrypt32
else ifdef MBEDTLS_PATH
CFLAGS += -DLIBSSH2_MBEDTLS
CFLAGS += -I"$(MBEDTLS_PATH)/include"
LIBPATH += -L"$(MBEDTLS_PATH)/libs"
LDLIBS += -lmbedtls -lmbedx509 -lmbedcrypto
else else
ifdef MBEDTLS_PATH CFLAGS += -DLIBSSH2_OPENSSL
CFLAGS += -DLIBSSH2_MBEDTLS ifndef OPENSSL_INCLUDE
CFLAGS += -I"$(MBEDTLS_PATH)/include"
LIBPATH += -L"$(MBEDTLS_PATH)/libs"
LDLIBS += -lmbedtls -lmbedx509 -lmbedcrypto
else
CFLAGS += -DLIBSSH2_OPENSSL
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
endif endif
ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include" ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
OPENSSL_INCLUDE = $(OPENSSL_PATH)/include OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
endif endif
endif endif
ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h" ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
$(error Invalid OPENSSL_PATH: $(OPENSSL_PATH)) $(error Invalid OPENSSL_PATH: $(OPENSSL_PATH))
endif endif
INCLUDES += -I"$(OPENSSL_INCLUDE)" INCLUDES += -I"$(OPENSSL_INCLUDE)"
ifndef OPENSSL_LIBPATH ifndef OPENSSL_LIBPATH
OPENSSL_LIBS_STAT = crypto ssl OPENSSL_LIBS_STAT = crypto ssl
ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out" ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
OPENSSL_LIBPATH = $(OPENSSL_PATH)/out OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
@@ -184,13 +162,12 @@ ifndef OPENSSL_LIBPATH
OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
OPENSSL_LIBS_DYN = crypto.dll ssl.dll OPENSSL_LIBS_DYN = crypto.dll ssl.dll
endif endif
endif endif
ifdef LINK_OPENSSL_STATIC ifdef LINK_OPENSSL_STATIC
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_STAT)) -lgdi32 LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_STAT)) -lgdi32
else else
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN)) LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
endif endif
endif
endif endif
LDLIBS += -lws2_32 LDLIBS += -lws2_32
@@ -209,13 +186,11 @@ CFLAGS += $(INCLUDES)
vpath %.c $(PROOT)/src vpath %.c $(PROOT)/src
ifdef WITH_WINCNG ifdef WITH_WINCNG
include $(PROOT)/Makefile.WinCNG.inc include $(PROOT)/Makefile.WinCNG.inc
else ifdef MBEDTLS_PATH
include $(PROOT)/Makefile.mbedTLS.inc
else else
ifdef MBEDTLS_PATH include $(PROOT)/Makefile.OpenSSL.inc
include $(PROOT)/Makefile.mbedTLS.inc
else
include $(PROOT)/Makefile.OpenSSL.inc
endif
endif endif
# include Makefile.inc to get CSOURCES define # include Makefile.inc to get CSOURCES define
@@ -305,9 +280,6 @@ $(TARGET).$(LIBEXT): $(OBJS)
@echo Creating $@ @echo Creating $@
@$(call DEL, $@) @$(call DEL, $@)
@$(AR) $(ARFLAGS) $@ $^ @$(AR) $(ARFLAGS) $@ $^
ifdef RANLIB
@$(RANLIB) $@
endif
$(libssh2_dll_LIBRARY) $(TARGET)$(LIBSSH2_DLL_A_SUFFIX).$(LIBEXT): $(OBJL) $(libssh2_dll_LIBRARY) $(TARGET)$(LIBSSH2_DLL_A_SUFFIX).$(LIBEXT): $(OBJL)
@echo Linking $@ @echo Linking $@

View File

@@ -7,21 +7,17 @@
# #
######################################################################### #########################################################################
# Project root
PROOT := ../..
# Edit the path below to point to the base of your Zlib sources. # Edit the path below to point to the base of your Zlib sources.
ifndef ZLIB_PATH ZLIB_PATH ?= $(PROOT)/../zlib
ZLIB_PATH = ../../../zlib
endif
# Edit the path below to point to the base of your OpenSSL package. # Edit the path below to point to the base of your OpenSSL package.
ifndef OPENSSL_PATH OPENSSL_PATH ?= $(PROOT)/../openssl
OPENSSL_PATH = ../../../openssl
endif
# Project root
PROOT = ../..
# 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 = $(PROOT)/example SAMPLES = $(PROOT)/example
@@ -31,10 +27,7 @@ DESCR = libssh2 $(subst .rc,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
#STACK = 64000 #STACK = 64000
# must be equal to DEBUG or NDEBUG # must be equal to DEBUG or NDEBUG
ifndef DB DB ?= NDEBUG
DB = NDEBUG
# DB = DEBUG
endif
# Optimization: -O<n> or debugging: -g # Optimization: -O<n> or debugging: -g
ifeq ($(DB),NDEBUG) ifeq ($(DB),NDEBUG)
OPT = -O2 OPT = -O2
@@ -77,47 +70,50 @@ CAT = type
ECHONL = $(ComSpec) /c echo. ECHONL = $(ComSpec) /c echo.
endif endif
CC = $(CROSSPREFIX)gcc LIBSSH2_RC ?= $(CROSSPREFIX)windres
LIBSSH2_CC ?= $(CROSSPREFIX)gcc
LIBSSH2_AR ?= $(CROSSPREFIX)ar
CC = $(LIBSSH2_CC)
# Set environment var ARCH to your architecture to override autodetection. # Set environment var ARCH to your architecture to override autodetection.
ifndef ARCH ifndef ARCH
ifeq ($(findstring gcc,$(CC)),gcc) ifeq ($(findstring gcc,$(CC)),gcc)
ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64) ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
ARCH = w64 ARCH = w64
else else
ARCH = w32 ARCH = w32
endif endif
else else
ARCH = w32 ARCH = w32
endif endif
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) CFLAGS = $(LIBSSH2_CFLAG_EXTRAS) $(OPT) -D$(DB)
LDFLAGS = $(LIBSSH2_LDFLAG_EXTRAS)
LD = $(CROSSPREFIX)gcc
RC = $(CROSSPREFIX)windres
LDFLAGS = -s
AR = $(CROSSPREFIX)ar
ARFLAGS = -cq
LIBEXT = a LIBEXT = a
#LDLIBS += -lwsock32 LD = $(LIBSSH2_CC)
LDLIBS += -lws2_32 RC = $(LIBSSH2_RC)
LDFLAGS += -s
AR = $(LIBSSH2_AR)
ARFLAGS = cru
RCFLAGS = -I $(PROOT)/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 #-Wno-unused #-pedantic CFLAGS += -Wall # -pedantic
ifeq ($(ARCH),w64) ifeq ($(ARCH),w64)
CFLAGS += -m64 CFLAGS += -m64
RCFLAGS += -F pe-x86-64 LDFLAGS += -m64
else RCFLAGS += -F pe-x86-64
ifeq ($(ARCH),w32) else ifeq ($(ARCH),w32)
CFLAGS += -m32 CFLAGS += -m32
RCFLAGS += -F pe-i386 LDFLAGS += -m32
endif RCFLAGS += -F pe-i386
endif endif
INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include
@@ -130,23 +126,25 @@ else
endif endif
ifdef WITH_WINCNG ifdef WITH_WINCNG
# CFLAGS += -DLIBSSH2_WINCNG LDLIBS += -lbcrypt -lcrypt32
LDLIBS += -lbcrypt -lcrypt32 else ifdef MBEDTLS_PATH
CFLAGS += -I"$(MBEDTLS_PATH)/include"
LIBPATH += -L"$(MBEDTLS_PATH)/libs"
LDLIBS += -lmbedtls -lmbedx509 -lmbedcrypto
else 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
endif endif
ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include" ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
OPENSSL_INCLUDE = $(OPENSSL_PATH)/include OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
endif endif
endif endif
ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h" ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
$(error Invalid OPENSSL_PATH: $(OPENSSL_PATH)) $(error Invalid OPENSSL_PATH: $(OPENSSL_PATH))
endif endif
INCLUDES += -I"$(OPENSSL_INCLUDE)" INCLUDES += -I"$(OPENSSL_INCLUDE)"
ifndef OPENSSL_LIBPATH ifndef OPENSSL_LIBPATH
OPENSSL_LIBS_STAT = crypto ssl OPENSSL_LIBS_STAT = crypto ssl
ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out" ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
OPENSSL_LIBPATH = $(OPENSSL_PATH)/out OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
@@ -156,15 +154,16 @@ ifndef OPENSSL_LIBPATH
OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
OPENSSL_LIBS_DYN = crypto.dll ssl.dll OPENSSL_LIBS_DYN = crypto.dll ssl.dll
endif endif
endif endif
ifdef LINK_STATIC ifdef LINK_STATIC
ifdef LINK_OPENSSL_STATIC ifdef LINK_OPENSSL_STATIC
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_STAT)) -lgdi32 LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_STAT)) -lgdi32
else else
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN)) LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
endif
endif
endif endif
endif LDLIBS += -lws2_32
endif
ifdef WITH_ZLIB ifdef WITH_ZLIB
CFLAGS += -DLIBSSH2_HAVE_ZLIB CFLAGS += -DLIBSSH2_HAVE_ZLIB
@@ -172,7 +171,7 @@ ifdef WITH_ZLIB
ifdef LINK_ZLIB_STATIC ifdef LINK_ZLIB_STATIC
LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT) LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
else else
LDLIBS += $(ZLIB_PATH)/libzdll.$(LIBEXT) LDLIBS += $(ZLIB_PATH)/libz.dll.$(LIBEXT)
endif endif
endif endif
@@ -227,7 +226,7 @@ $(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc
@echo $(DL) BEGIN$(DL) >> $@ @echo $(DL) BEGIN$(DL) >> $@
@echo $(DL) BLOCK "040904E4"$(DL) >> $@ @echo $(DL) BLOCK "040904E4"$(DL) >> $@
@echo $(DL) BEGIN$(DL) >> $@ @echo $(DL) BEGIN$(DL) >> $@
@echo $(DL) VALUE "LegalCopyright","\xA9 $(LIBSSH2_COPYRIGHT_STR)\0"$(DL) >> $@ @echo $(DL) VALUE "LegalCopyright","(C) $(LIBSSH2_COPYRIGHT_STR)\0"$(DL) >> $@
ifdef COMPANY ifdef COMPANY
@echo $(DL) VALUE "CompanyName","$(COMPANY)\0"$(DL) >> $@ @echo $(DL) VALUE "CompanyName","$(COMPANY)\0"$(DL) >> $@
endif endif