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

NMakefile: merge them into a single file [ci skip] (#902)

Also:

- allow to override `AR` and `ARFLAGS`.

- The extra `src` subdir in the target directory is no longer, to
  simplify things.

- gone the dynamically generated `objects.mk`. Now replaced with some
  tricky logic to do that inline.

- add necessary `LIBS` for WinCNG. (untested)

Lightly tested via clang-cl.
This commit is contained in:
Viktor Szakats
2023-03-30 21:01:01 +02:00
committed by GitHub
parent 5012442850
commit 057522bb0f
5 changed files with 96 additions and 112 deletions

107
NMakefile
View File

@@ -1,4 +1,56 @@
!include "win32/config.mk" # Tweak these for your system
!if "$(OPENSSLINC)" == ""
OPENSSLINC=..\openssl\include
!endif
!if "$(OPENSSLLIB)" == ""
OPENSSLLIB=..\openssl\lib
!endif
!if "$(ZLIBINC)" == ""
ZLIBINC=..\zlib
!endif
!if "$(ZLIBLIB)" == ""
ZLIBLIB=..\zlib
!endif
!if "$(TARGET)" == ""
TARGET=Release
!endif
!if "$(TARGET)" == "Debug"
SUFFIX=_debug
CPPFLAGS=/Od /MDd
DLLFLAGS=/DEBUG /LDd
!else
CPPFLAGS=/Oi /O2 /Oy /GF /Y- /MD /DNDEBUG
DLLFLAGS=/DEBUG /LD
!endif
CPPFLAGS=/nologo /GL /Zi /EHsc $(CPPFLAGS) /Iwin32 /Iinclude
!if "$(WITH_WINCNG)" == "1"
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_WINCNG
LIBS=ws2_32.lib crypt32.lib bcrypt.lib
!else
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_OPENSSL /I$(OPENSSLINC)
LIBS=$(LIBS) $(OPENSSLLIB)\lib\crypto.lib $(OPENSSLLIB)\lib\ssl.lib
!endif
!if "$(WITH_ZLIB)" == "1"
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_HAVE_ZLIB /I$(ZLIBINC)
LIBS=$(LIBS) $(ZLIBLIB)\zlib.lib
!endif
CFLAGS=$(CPPFLAGS)
RCFLAGS=/Iinclude
DLLFLAGS=$(CFLAGS) $(DLLFLAGS)
LIBS=$(LIBS) ws2_32.lib user32.lib advapi32.lib gdi32.lib
INTDIR=$(TARGET)
SUBDIR=src
!if "$(WITH_WINCNG)" == "1" !if "$(WITH_WINCNG)" == "1"
!include "Makefile.WinCNG.inc" !include "Makefile.WinCNG.inc"
@@ -9,15 +61,53 @@
OBJECTS=$(CSOURCES:.c=.obj) OBJECTS=$(CSOURCES:.c=.obj)
# SUBDIRS=src example !if "$(TARGET)" == "Debug"
SUBDIRS=src OBJECTS=Debug/$(OBJECTS: = Debug/)
OBJECTS=$(OBJECTS: Debug/ = )
!else
TARGET=Release
OBJECTS=Release/$(OBJECTS: = Release/)
OBJECTS=$(OBJECTS: Release/ = )
!endif
all-sub: win32\objects.mk CFLAGS=$(CFLAGS)
-for %D in ($(SUBDIRS)) do $(MAKE) /nologo /f %D/NMakefile BUILD=$(BUILD) SUBDIR=%D all-sub
!if "$(AR)" == ""
AR=lib
ARFLAGS=-nologo /LTCG
!endif
RESOURCE=$(INTDIR)\libssh2.res
DLL=libssh2$(SUFFIX).dll
STATICLIB=$(INTDIR)\libssh2.lib
!if "$(BUILD_STATIC_LIB)" == ""
all: $(INTDIR) $(DLL)
!else
all: $(INTDIR) $(STATICLIB)
!endif
$(INTDIR):
@if not exist $(INTDIR) mkdir $(INTDIR)
$(DLL): $(OBJECTS) $(RESOURCE)
$(CC) -o $(DLL) $(DLLFLAGS) $(OBJECTS) $(RESOURCE) $(LIBS)
$(STATICLIB): $(OBJECTS)
$(AR) $(ARFLAGS) -out:$@ $(OBJECTS)
$(RESOURCE): win32\libssh2.rc
$(RC) $(RCFLAGS) /Fo"$@" $?
all-sub: $(INTDIR) all
clean-sub: clean
{$(SUBDIR)}.c{$(INTDIR)}.obj::
$(CC) -c $(CFLAGS) /Fo"$(INTDIR)\\" $<
clean: clean:
-rmdir 2>NUL /s/q $(TARGET) -rmdir 2>NUL /s/q $(TARGET)
-del 2>NUL win32\objects.mk
real-clean vclean: clean real-clean vclean: clean
-del 2>NUL libssh2.dll -del 2>NUL libssh2.dll
@@ -25,8 +115,3 @@ real-clean vclean: clean
-del 2>NUL libssh2.ilk -del 2>NUL libssh2.ilk
-del 2>NUL libssh2.lib -del 2>NUL libssh2.lib
-del 2>NUL *.pdb -del 2>NUL *.pdb
win32\objects.mk: Makefile.inc
@echo OBJECTS = \>$@
@for %O in ($(OBJECTS)) do @echo $$(INTDIR)\%O \>>$@
@echo $$(EOL)>>$@

View File

@@ -1,29 +0,0 @@
!include "win32/config.mk"
!include "win32/objects.mk"
CFLAGS=$(CFLAGS)
AR = lib
ARFLAGS = -nologo /LTCG
RESOURCE=$(INTDIR)\libssh2.res
DLL=libssh2$(SUFFIX).dll
STATICLIB=$(INTDIR)\libssh2.lib
!if "$(BUILD_STATIC_LIB)" == ""
all: $(DLL)
!else
all: $(STATICLIB)
!endif
$(DLL): $(OBJECTS) $(RESOURCE)
$(CC) -o $(DLL) $(DLLFLAGS) $(OBJECTS) $(RESOURCE) $(LIBS)
$(STATICLIB): $(OBJECTS)
$(AR) $(ARFLAGS) -out:$@ $(OBJECTS)
$(RESOURCE): win32\libssh2.rc
$(RC) $(RCFLAGS) /Fo"$@" $?
!include "win32/rules.mk"

9
win32/.gitignore vendored
View File

@@ -1,13 +1,4 @@
*.lib
*.pdb
*.dll *.dll
*.exe *.exe
*.obj
.*.swp
Debug Debug
Release Release
*.exp
*.ncb
*.opt
*.plg
objects.mk

View File

@@ -1,51 +0,0 @@
# Tweak these for your system
!if "$(OPENSSLINC)" == ""
OPENSSLINC=..\openssl\include
!endif
!if "$(OPENSSLLIB)" == ""
OPENSSLLIB=..\openssl\lib
!endif
!if "$(ZLIBINC)" == ""
ZLIBINC=..\zlib
!endif
!if "$(ZLIBLIB)" == ""
ZLIBLIB=..\zlib
!endif
!if "$(TARGET)" == ""
TARGET=Release
!endif
!if "$(TARGET)" == "Debug"
SUFFIX=_debug
CPPFLAGS=/Od /MDd
DLLFLAGS=/DEBUG /LDd
!else
CPPFLAGS=/Oi /O2 /Oy /GF /Y- /MD /DNDEBUG
DLLFLAGS=/DEBUG /LD
!endif
CPPFLAGS=/nologo /GL /Zi /EHsc $(CPPFLAGS) /Iwin32 /Iinclude
!if "$(WITH_WINCNG)" == "1"
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_WINCNG
# LIBS=bcrypt.lib crypt32.lib
!else
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_OPENSSL /I$(OPENSSLINC)
LIBS=$(LIBS) $(OPENSSLLIB)\lib\crypto.lib $(OPENSSLLIB)\lib\ssl.lib
!endif
!if "$(WITH_ZLIB)" == "1"
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_HAVE_ZLIB /I$(ZLIBINC)
LIBS=$(LIBS) $(ZLIBLIB)\zlib.lib
!endif
CFLAGS=$(CPPFLAGS)
RCFLAGS=/Iinclude
DLLFLAGS=$(CFLAGS) $(DLLFLAGS)
LIBS=$(LIBS) ws2_32.lib user32.lib advapi32.lib gdi32.lib
INTDIR=$(TARGET)\$(SUBDIR)

View File

@@ -1,12 +0,0 @@
all-sub: $(INTDIR) all
clean-sub: clean
$(INTDIR):
!if "$(SRCDIR)" == ""
@if not exist $(TARGET) mkdir $(TARGET)
!endif
@if not exist $(INTDIR) mkdir $(INTDIR)
{$(SUBDIR)}.c{$(INTDIR)}.obj::
$(CC) -c $(CFLAGS) /Fo"$(INTDIR)\\" $<