Skip to content

Commit

Permalink
harmonise the nmake makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mirabilos committed Apr 14, 2023
1 parent 86201f4 commit ad12cbb
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 49 deletions.
55 changes: 29 additions & 26 deletions dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ clean: $(CLEAN:^unix=dos)

unixclean:
rm -f *.bat *.stp
-cd ../ws2/lib && $(MAKE) clean
rm -rf bin/armhf bin/arm64 bin/amd64 bin/i386
rm -f bin/*.bat bin/*.dll bin/*.runtimeconfig.json \
bin/*.so bin/*.so.* bin/*.sh
-cd ..$Yws2$Ylib && $(MAKE) clean
rm -rf bin$Yarmhf bin$Yarm64 bin$Yamd64 bin$Yi386
rm -f bin$Y*.bat bin$Y*.dll bin$Y*.runtimeconfig.json \
bin$Y*.so bin$Y*.so.* bin$Y*.sh

dosclean:
if exist *.stp (del *.stp)
-cd ..$Yws2$Ylib && $(MAKE) /nologo clean
-cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS) clean
-rd /s /q bin$Yarmhf bin$Yarm64 bin$Yamd64 bin$Yi386 2>nul
if exist *.bat (del *.bat)
if exist bin$Y*.bat (del bin$Y*.bat)
Expand All @@ -80,34 +80,34 @@ dosclean:
rem if exist *.obj (del *.obj)

windll:
..$Ytest-git /q
-cd ..$Yws2$Ylib && $(MAKE) /nologo clean
@..$Ytest-git /q
-cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS) clean
-rd /s /q bin$Yarmhf bin$Yarm64 bin$Yamd64 bin$Yi386 2>nul
md bin$Yarmhf
"$(VCINSTALLDIR)$YAuxiliary$YBuild$Yvcvarsall" x86_arm && \
cd ..$Yws2$Ylib && $(MAKE) /nologo
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS)
copy ..$Yws2$Ybin$Yecn-bitw.dll bin$Yarmhf$Y
cd ..$Yws2$Ylib && $(MAKE) /nologo clean
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS) clean
md bin$Yarm64
"$(VCINSTALLDIR)$YAuxiliary$YBuild$Yvcvarsall" x86_arm64 && \
cd ..$Yws2$Ylib && $(MAKE) /nologo
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS)
copy ..$Yws2$Ybin$Yecn-bitw.dll bin$Yarm64$Y
cd ..$Yws2$Ylib && $(MAKE) /nologo clean
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS) clean
md bin$Yamd64
"$(VCINSTALLDIR)$YAuxiliary$YBuild$Yvcvarsall" x86_amd64 && \
cd ..$Yws2$Ylib && $(MAKE) /nologo
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS)
copy ..$Yws2$Ybin$Yecn-bitw.dll bin$Yamd64$Y
cd ..$Yws2$Ylib && $(MAKE) /nologo clean
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS) clean
md bin$Yi386
"$(VCINSTALLDIR)$YAuxiliary$YBuild$Yvcvarsall" x86 && \
cd ..$Yws2$Ylib && $(MAKE) /nologo
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS)
copy ..$Yws2$Ybin$Yecn-bitw.dll bin$Yi386$Y
cd ..$Yws2$Ylib && $(MAKE) /nologo clean
cd ..$Yws2$Ylib && $(MAKE) /nologo /$(MAKEFLAGS) clean
@echo stamp >windll.stp
rem --- Windows DLLs built for all architectures

windll.stp:
$(MAKE) /nologo windll
$(MAKE) /nologo /$(MAKEFLAGS) windll

# cf. https://stackoverflow.com/q/70238734/2171120
dncscw.stp: mkdncsc.vbs
Expand All @@ -119,7 +119,7 @@ dncscw.stp: mkdncsc.vbs
win: winbuild winrun

winbuild: dncscw.stp windll.stp
..$Ytest-git /q
@..$Ytest-git /q
dncsc -nologo $(LIB_BUILD)
dncsc -nologo $(PROG_BUILD)
rem or: dncsc -platform:anycpu32bitpreferred $(PROG_BUILD)
Expand All @@ -131,10 +131,11 @@ winrun:
if not "$(args: =)"=="" bin$Y$(PROG_BASENAME).bat $(args)

gnudll:
-cd ../ws2/lib && $(MAKE) clean
cd ../ws2/lib && $(MAKE) NOSTATIC=Yes
cp -a ../ws2/lib/libecn-bitw.so ../ws2/lib/libecn-bitw.so.* bin/
-cd ../ws2/lib && $(MAKE) clean
@..$Ytest-git /q
-cd ..$Yws2$Ylib && $(MAKE) clean
cd ..$Yws2$Ylib && $(MAKE) NOSTATIC=Yes
cp -a ..$Yws2$Ylib$Ylibecn-bitw.so ..$Yws2$Ylib$Ylibecn-bitw.so.* bin$Y
-cd ..$Yws2$Ylib && $(MAKE) clean
@echo stamp >gnudll.stp

gnudll.stp:
Expand All @@ -150,9 +151,10 @@ dncscu.stp: mkdncsc.awk mkdncsc.sh
dotnet: dotnetbuild dotnetrun

dotnetbuild: dncscu.stp gnudll.stp
./dncsc.bat -nologo $(LIB_BUILD)
./dncsc.bat -nologo $(PROG_BUILD)
./dnmkrtcf.bat >bin$Y$(PROG_BASENAME).runtimeconfig.json
@..$Ytest-git /q
.$Ydncsc.bat -nologo $(LIB_BUILD)
.$Ydncsc.bat -nologo $(PROG_BUILD)
.$Ydnmkrtcf.bat >bin$Y$(PROG_BASENAME).runtimeconfig.json
printf '%s\n' '#!/bin/sh' 'mydir=$$(dirname "$$0")' \
'LD_LIBRARY_PATH=$$mydir$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH}' \
'export LD_LIBRARY_PATH' \
Expand All @@ -161,11 +163,12 @@ dotnetbuild: dncscu.stp gnudll.stp
chmod a+x bin$Y$(PROG_BASENAME).sh

dotnetrun:
test -z '$(args:'='\'')' || bin/$(PROG_BASENAME).sh $(args)
test -z '$(args:'='\'')' || bin$Y$(PROG_BASENAME).sh $(args)

mono: monobuild monorun

monobuild: gnudll.stp
@..$Ytest-git /q
mcs -nologo /unsafe $(LIB_BUILD)
mcs -nologo $(PROG_BUILD)
printf '%s\n' '#!/bin/sh' 'mydir=$$(dirname "$$0")' \
Expand All @@ -176,7 +179,7 @@ monobuild: gnudll.stp
chmod a+x bin$Y$(PROG_BASENAME)-mono.sh

monorun:
test -z '$(args:'='\'')' || bin/$(PROG_BASENAME)-mono.sh $(args)
test -z '$(args:'='\'')' || bin$Y$(PROG_BASENAME)-mono.sh $(args)

LSL=ls -l
DIR=$(LSL:^ls -l=dir)
Expand Down
38 changes: 22 additions & 16 deletions ws2/NMAKE.mak
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ all:
!IF [set __VSCMD_ARG_NO_LOGO=1] || [set VSCMD_SKIP_SENDTELEMETRY=1]
!ENDIF

BKSL=^\
# path slash
SLASHPRE=/
Y=$(SLASHPRE:^/=^\)

!IF [..$(BKSL)..$(BKSL)test-git.bat /q]
# echo doublequote
QCHARPRE=\"
Q=$(QCHARPRE:^\=)

!IF [..$Y..$Ytest-git.bat /q]
!ERROR git repository clone consistency check failed
!ENDIF

Expand Down Expand Up @@ -70,11 +76,11 @@ WINVERFLAGS= -DWINVER=0x0602 -D_WIN32_WINNT=0x0602 -DNTDDI_VERSION=NTDDI_WIN8
# 2027-01-12 EOL: Windows Server 2016 (NTDDI_WIN10_RS1)
#WINVERFLAGS= -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00 -DNTDDI_VERSION=NTDDI_WIN10

CPPFLAGS= $(CPPFLAGS) -D_REENTRANT $(WINVERFLAGS) -I..$(BKSL)inc
CPPFLAGS= $(CPPFLAGS) -D_REENTRANT $(WINVERFLAGS) -I..$Yinc
!IFNDEF NOPIC
CPPFLAGS= $(CPPFLAGS) -DECNBITS_WIN32_DLL
!ENDIF
CPPFLAGS= $(CPPFLAGS) -I..$(BKSL)util
CPPFLAGS= $(CPPFLAGS) -I..$Yutil
CFLAGS= $(CFLAGS) /utf-8
CFLAGS= $(CFLAGS) /Wall
CFLAGS= $(CFLAGS) /Qspectre /wd5045
Expand All @@ -91,7 +97,7 @@ CPPFLAGS= $(CPPFLAGS) -DDEBUG
!IFNDEF SRCS
SRCS= $(PROG).c
!ENDIF
LINKFLAGS= $(LINKFLAGS) /LIBPATH:..$(BKSL)lib
LINKFLAGS= $(LINKFLAGS) /LIBPATH:..$Ylib
!ENDIF

!IFNDEF OBJS
Expand All @@ -107,21 +113,21 @@ LIBS= $(LIBS) ecn-bitw.lib Ws2_32.lib
!IF EXISTS($(PROG).exe)
CLEANFILES= $(CLEANFILES) $(PROG).exe
!ENDIF
!IF EXISTS(..$(BKSL)BIN$(BKSL)$(PROG).exe)
CLEANFILES= $(CLEANFILES) ..$(BKSL)BIN$(BKSL)$(PROG).exe
!IF EXISTS(..$Ybin$Y$(PROG).exe)
CLEANFILES= $(CLEANFILES) ..$Ybin$Y$(PROG).exe
!ENDIF
!IFNDEF DPADD
!IFNDEF NOPIC
DPADD= ..$(BKSL)lib$(BKSL)ecn-bitw_imp.lib
DPADD= ..$Ylib$Yecn-bitw_imp.lib
!ELSE
DPADD= ..$(BKSL)lib$(BKSL)ecn-bitw.lib
DPADD= ..$Ylib$Yecn-bitw.lib
!ENDIF
!ENDIF
all: $(PROG).exe
$(PROG).exe: $(OBJS) $(DPADD)
@for %f in ($@ ..$(BKSL)BIN$(BKSL)$@) do @if exist %f (del %f)
@for %f in ($@ ..$Ybin$Y$@) do @if exist %f (del %f)
$(CC) $(CFLAGS) $(LDFLAGS) /Fe$@ $(OBJS) $(LIBS) /link $(LINKFLAGS)
copy $@ ..$(BKSL)BIN$(BKSL)$@
copy $@ ..$Ybin$Y$@
!ENDIF

!IFDEF MKLIB
Expand All @@ -137,8 +143,8 @@ CLEANFILES= $(CLEANFILES) $(MKLIB)_imp.lib
!IF EXISTS($(MKLIB).dll)
CLEANFILES= $(CLEANFILES) $(MKLIB).dll
!ENDIF
!IF EXISTS(..$(BKSL)BIN$(BKSL)$(MKLIB).dll)
CLEANFILES= $(CLEANFILES) ..$(BKSL)BIN$(BKSL)$(MKLIB).dll
!IF EXISTS(..$Ybin$Y$(MKLIB).dll)
CLEANFILES= $(CLEANFILES) ..$Ybin$Y$(MKLIB).dll
!ENDIF
!IFNDEF DPADD
DPADD=
Expand All @@ -147,13 +153,13 @@ DPADD=
LIBS= $(LIBS) Ws2_32.lib
all: $(MKLIB).dll
$(MKLIB).dll: $(OBJS) $(MKLIB).def $(DPADD)
@for %f in ($(MKLIB)_imp.exp $(MKLIB)_imp.lib $@ ..$(BKSL)BIN$(BKSL)$@) do @if exist %f (del %f)
@for %f in ($(MKLIB)_imp.exp $(MKLIB)_imp.lib $@ ..$Ybin$Y$@) do @if exist %f (del %f)
$(CC) $(CFLAGS) $(LDFLAGS) /LD /Fe$@ $(OBJS) $(LIBS) /link /DEF:$(MKLIB).def /IMPLIB:$(MKLIB)_imp.lib $(LINKFLAGS)
copy $@ ..$(BKSL)BIN$(BKSL)$@
copy $@ ..$Ybin$Y$@
!ELSE
all: $(MKLIB).lib
$(MKLIB).lib: $(OBJS) $(DPADD)
@for %f in ($@ ..$(BKSL)BIN$(BKSL)$@) do @if exist %f (del %f)
@for %f in ($@ ..$Ybin$Y$@) do @if exist %f (del %f)
lib.exe /OUT:$@ $(OBJS)
!ENDIF
!ENDIF
Expand Down
4 changes: 2 additions & 2 deletions ws2/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ PROG= client

!include ../NMAKE.mak

$(OBJS): ..$(BKSL)inc$(BKSL)ecn-bitw.h
client.obj: ..$(BKSL)util$(BKSL)rpl_err.h ..$(BKSL)util$(BKSL)rpl_err.c
$(OBJS): ..$Yinc$Yecn-bitw.h
client.obj: ..$Yutil$Yrpl_err.h ..$Yutil$Yrpl_err.c
2 changes: 1 addition & 1 deletion ws2/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ SRCS= $(SRCS) winsend.c

!include ../NMAKE.mak

$(OBJS): ..$(BKSL)inc$(BKSL)ecn-bitw.h
$(OBJS): ..$Yinc$Yecn-bitw.h
4 changes: 2 additions & 2 deletions ws2/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ all:
!IF [set __VSCMD_ARG_NO_LOGO=1] || [set VSCMD_SKIP_SENDTELEMETRY=1]
!ENDIF

BKSL=^\
Y=^\

!IF [..$(BKSL)test-git.bat /q]
!IF [..$Ytest-git.bat /q]
!ERROR git repository clone consistency check failed
!ENDIF

Expand Down
4 changes: 2 additions & 2 deletions ws2/server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ PROG= server

!include ../NMAKE.mak

$(OBJS): ..$(BKSL)inc$(BKSL)ecn-bitw.h
server.obj: ..$(BKSL)util$(BKSL)rpl_err.h ..$(BKSL)util$(BKSL)rpl_err.c
$(OBJS): ..$Yinc$Yecn-bitw.h
server.obj: ..$Yutil$Yrpl_err.h ..$Yutil$Yrpl_err.c

0 comments on commit ad12cbb

Please sign in to comment.