Files
mars-dosutils/CMakeLists.txt
Mario Fetka ff92f72583 Add FLAGDIR utility and clean DOS utility build files
Add a NetWare-style FLAGDIR implementation for directory attributes and
register it in the multi-call DOS utility dispatcher.  The new command
supports the 386-style directory flags Normal, System, Hidden,
DeleteInhibit, Purge and RenameInhibit, and formats output close to the
Novell FLAGDIR tool for simple mapped paths.

Update the DOS utilities install/build metadata so flagdir.exe is emitted
alongside the other public tools.  Adjust the Open Watcom CMake build to
compile C sources into the build directory instead of leaving object files
in the source tree.

Move the historical Borland/TASM build files into doc/ to keep the active
source directory focused on the modern Watcom/CMake build.
2026-05-24 02:09:59 +02:00

156 lines
4.5 KiB
CMake

# DOS utilities for mars-nwe.
#
# Default mode: install a prebuilt net.exe from this source tree. This keeps the
# normal mars-nwe build independent from Open Watcom.
#
# Maintainer mode: configure with -DMARS_NWE_BUILD_DOSUTILS=ON to rebuild
# net.exe with Open Watcom v2 on Linux.
set(MARS_DOSUTILS_NET_EXE
"${CMAKE_CURRENT_SOURCE_DIR}/net.exe"
CACHE FILEPATH "Prebuilt DOS net.exe used for installation when MARS_NWE_BUILD_DOSUTILS is OFF"
)
set(MARS_DOSUTILS_PUBLIC_TOOLS
net
login
profile
spawn
passwd
path
pathins
pathdel
map
mapdel
logout
slist
flag
flagdir
capture
endcap
)
# Do not install slist.exe yet: func_slist() is empty and SLIST is disabled in net.c.
# Do not install tests/debug by default either; they are developer-only helpers.
if(MARS_NWE_BUILD_DOSUTILS)
find_package(OpenWatcom REQUIRED)
set(DOSUTILS_C_SOURCES
net.c
tools.c
netcall.c
ncpcall.c
login.c
map.c
slist.c
flag.c
flagdir.c
c32ncp.c
nwcrypt.c
nwdebug.c
nwtests.c
capture.c
)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
COMMAND "${CMAKE_COMMAND}" -E env ${OPENWATCOM_ENV}
"${OPENWATCOM_WASM}"
-q
-zq
-fo="${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
"${CMAKE_CURRENT_SOURCE_DIR}/kern_wasm.asm"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/kern_wasm.asm"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM
)
set(DOSUTILS_OBJECTS)
foreach(src IN LISTS DOSUTILS_C_SOURCES)
get_filename_component(obj_name "${src}" NAME_WE)
set(obj "${CMAKE_CURRENT_BINARY_DIR}/${obj_name}.obj")
list(APPEND DOSUTILS_OBJECTS "${obj}")
add_custom_command(
OUTPUT "${obj}"
COMMAND "${CMAKE_COMMAND}" -E env ${OPENWATCOM_ENV}
"${OPENWATCOM_WCL}"
-q
-zq
-bt=dos
-ml
-0
-c
-fo="${obj}"
"${CMAKE_CURRENT_SOURCE_DIR}/${src}"
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/${src}"
"${CMAKE_CURRENT_SOURCE_DIR}/net.h"
"${CMAKE_CURRENT_SOURCE_DIR}/kern.h"
"${CMAKE_CURRENT_SOURCE_DIR}/c32ncp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/nwcrypt.h"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM
)
endforeach()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/net.exe"
COMMAND "${CMAKE_COMMAND}" -E env ${OPENWATCOM_ENV}
"${OPENWATCOM_WCL}"
-q
-zq
-bt=dos
-ml
-0
-k32768
-fe="${CMAKE_CURRENT_BINARY_DIR}/net.exe"
${DOSUTILS_OBJECTS}
"${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
DEPENDS
${DOSUTILS_OBJECTS}
"${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM
)
add_custom_target(dosutils_net ALL
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/net.exe"
)
set(MARS_DOSUTILS_NET_EXE "${CMAKE_CURRENT_BINARY_DIR}/net.exe")
else()
if(NOT EXISTS "${MARS_DOSUTILS_NET_EXE}")
message(FATAL_ERROR
"Prebuilt DOS utility missing: ${MARS_DOSUTILS_NET_EXE}. "
"Either commit net.exe into dosutils or configure with "
"-DMARS_NWE_BUILD_DOSUTILS=ON and Open Watcom installed."
)
endif()
endif()
foreach(tool IN LISTS MARS_DOSUTILS_PUBLIC_TOOLS)
if(tool STREQUAL "net")
install(FILES "${MARS_DOSUTILS_NET_EXE}"
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/public")
else()
install(FILES "${MARS_DOSUTILS_NET_EXE}"
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/public"
RENAME "${tool}.exe")
endif()
endforeach()
install(FILES "${MARS_DOSUTILS_NET_EXE}"
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
RENAME login.exe)
install(FILES "${MARS_DOSUTILS_NET_EXE}"
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
RENAME map.exe)
install(FILES "${MARS_DOSUTILS_NET_EXE}"
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
RENAME slist.exe)