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,22 +79,11 @@ 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)
@@ -132,7 +114,6 @@ 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
@@ -141,21 +122,18 @@ 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 else ifdef MBEDTLS_PATH
ifdef MBEDTLS_PATH
CFLAGS += -DLIBSSH2_MBEDTLS CFLAGS += -DLIBSSH2_MBEDTLS
CFLAGS += -I"$(MBEDTLS_PATH)/include" CFLAGS += -I"$(MBEDTLS_PATH)/include"
LIBPATH += -L"$(MBEDTLS_PATH)/libs" LIBPATH += -L"$(MBEDTLS_PATH)/libs"
@@ -191,7 +169,6 @@ 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
ifdef WITH_ZLIB ifdef WITH_ZLIB
@@ -210,13 +187,11 @@ vpath %.c $(PROOT)/src
ifdef WITH_WINCNG ifdef WITH_WINCNG
include $(PROOT)/Makefile.WinCNG.inc include $(PROOT)/Makefile.WinCNG.inc
else else ifdef MBEDTLS_PATH
ifdef MBEDTLS_PATH
include $(PROOT)/Makefile.mbedTLS.inc include $(PROOT)/Makefile.mbedTLS.inc
else else
include $(PROOT)/Makefile.OpenSSL.inc include $(PROOT)/Makefile.OpenSSL.inc
endif endif
endif
# include Makefile.inc to get CSOURCES define # include Makefile.inc to get CSOURCES define
include $(PROOT)/Makefile.inc include $(PROOT)/Makefile.inc
@@ -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,7 +70,11 @@ 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
@@ -96,29 +93,28 @@ endif
-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
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
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
LIBPATH += -L$(PROOT)/win32 LIBPATH += -L$(PROOT)/win32
@@ -130,10 +126,12 @@ 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
@@ -165,6 +163,7 @@ else
endif endif
endif endif
endif endif
LDLIBS += -lws2_32
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