remove duplicated code from sfctool.c, sftags.c

Link with hacklib to provide them instead
This commit is contained in:
nhmall
2025-06-01 15:32:55 -04:00
parent 79be47b1ad
commit 66007e6783
6 changed files with 233 additions and 315 deletions

View File

@@ -298,23 +298,24 @@ recover-version.o: ../src/version.c $(HACK_H)
# dependencies for optional sfctool
#
# object files for sfctool utility
SFCTOOLOBJS = $(TARGETPFX)sfctool.o $(TARGETPFX)sf-alloc.o \
$(TARGETPFX)sf-monst.o $(TARGETPFX)sf-objects.o \
$(TARGETPFX)sfbase.o $(TARGETPFX)sfstruct.o \
$(TARGETPFX)sfexpasc.o \
$(TARGETPFX)sfdata.o $(TARGETPFX)sf-nhlua.o \
$(TARGETPFX)panic.o $(TARGETPFX)sf-date.o \
$(TARGETPFX)sf-decl.o $(TARGETPFX)sf-artifact.o \
SFCTOOLOBJS = $(TARGETPFX)sfctool.o \
$(TARGETPFX)sf-alloc.o $(TARGETPFX)sfdata.o \
$(TARGETPFX)sfexpasc.o $(TARGETPFX)sf-cfgfiles.o \
$(TARGETPFX)sf-date.o $(TARGETPFX)sf-artifact.o \
$(TARGETPFX)sf-calendar.o $(TARGETPFX)sf-decl.o \
$(TARGETPFX)sf-dungeon.o $(TARGETPFX)sf-end.o \
$(TARGETPFX)sf-engrave.o $(TARGETPFX)sf-cfgfiles.o \
$(TARGETPFX)sf-files.o $(TARGETPFX)sf-light.o \
$(TARGETPFX)sf-mdlib.o $(TARGETPFX)sf-mkmaze.o \
$(TARGETPFX)sf-mkroom.o $(TARGETPFX)sf-o_init.o \
$(TARGETPFX)sf-region.o $(TARGETPFX)sf-restore.o \
$(TARGETPFX)sf-rumors.o $(TARGETPFX)sf-sys.o \
$(TARGETPFX)sf-engrave.o $(TARGETPFX)sf-files.o \
$(TARGETPFX)sf-light.o $(TARGETPFX)sf-mdlib.o \
$(TARGETPFX)sf-mkmaze.o $(TARGETPFX)sf-mkroom.o \
$(TARGETPFX)sf-monst.o $(TARGETPFX)sf-nhlua.o \
$(TARGETPFX)sf-objects.o $(TARGETPFX)sf-o_init.o \
$(TARGETPFX)panic.o $(TARGETPFX)sf-region.o \
$(TARGETPFX)sf-restore.o $(TARGETPFX)sf-rumors.o \
$(TARGETPFX)sfbase.o $(TARGETPFX)sf-struct.o \
$(TARGETPFX)strutil.o $(TARGETPFX)sf-sys.o \
$(TARGETPFX)sf-timeout.o $(TARGETPFX)sf-track.o \
$(TARGETPFX)sf-version.o $(TARGETPFX)sf-worm.o \
$(TARGETPFX)strutil.o
$(TARGETPFX)sf-version.o $(TARGETPFX)sf-worm.o
SFCTOOLBIN = sfctool
SFFLAGS=-DSFCTOOL -DNOPANICTRACE -DNOCRASHREPORT -DNO_CHRONICLE
@@ -324,26 +325,22 @@ $(SFCTOOLBIN): $(SFCTOOLOBJS) $(HACKLIB)
$(TARGET_CLINK) $(TARGET_LFLAGS) -o $@ $(SFCTOOLOBJS) $(HACKLIB) $(TARGET_LIBS)
$(TARGETPFX)sfctool.o: sfctool.c $(HACK_H) ../include/sfprocs.h
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c sfctool.c
$(TARGETPFX)sfdata.o: sfdata.c $(HACK_H) ../include/sfprocs.h ../include/sfproto.h
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c sfdata.c
$(TARGETPFX)sfexpasc.o: sfexpasc.c $(HACK_H) ../include/sfprocs.h ../include/sfproto.h
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c sfexpasc.c
$(TARGETPFX)sf-alloc.o: ../src/alloc.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/alloc.c
$(TARGETPFX)sf-calendar.o: ../src/calendar.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/calendar.c
$(TARGETPFX)sf-cfgfiles.o: ../src/cfgfiles.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/cfgfiles.c
$(TARGETPFX)sf-date.o: ../src/date.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/date.c
$(TARGETPFX)sf-decl.o: ../src/decl.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/decl.c
$(TARGETPFX)sf-panic.o: panic.c $(CONFIG_H)
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c panic.c
$(TARGETPFX)sf-monst.o: ../src/monst.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/monst.c
$(TARGETPFX)sf-objects.o: ../src/objects.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/objects.c
$(TARGETPFX)sf-sfbase.o: ../src/sfbase.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/sfbase.c
$(TARGETPFX)sfstruct.o: ../src/sfstruct.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/sfstruct.c
$(TARGETPFX)sf-panic.o: panic.c $(CONFIG_H)
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c panic.c
$(TARGETPFX)sf-artifact.o: ../src/artifact.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/artifact.c
$(TARGETPFX)sf-dungeon.o: ../src/dungeon.c
@@ -352,8 +349,6 @@ $(TARGETPFX)sf-end.o: ../src/end.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/end.c
$(TARGETPFX)sf-engrave.o: ../src/engrave.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/engrave.c
$(TARGETPFX)sf-cfgfiles.o: ../src/cfgfiles.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/cfgfiles.c
$(TARGETPFX)sf-files.o: ../src/files.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/files.c
$(TARGETPFX)sf-light.o: ../src/light.c
@@ -364,6 +359,8 @@ $(TARGETPFX)sf-mkmaze.o: ../src/mkmaze.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/mkmaze.c
$(TARGETPFX)sf-mkroom.o: ../src/mkroom.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/mkroom.c
$(TARGETPFX)sf-nhlua.o: ../src/nhlua.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/nhlua.c
$(TARGETPFX)sf-o_init.o: ../src/o_init.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/o_init.c
$(TARGETPFX)sf-region.o: ../src/region.c
@@ -372,6 +369,16 @@ $(TARGETPFX)sf-restore.o: ../src/restore.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/restore.c
$(TARGETPFX)sf-rumors.o: ../src/rumors.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/rumors.c
$(TARGETPFX)sfbase.o: ../src/sfbase.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/sfbase.c
$(TARGETPFX)sfdata.o: sfdata.c $(HACK_H) ../include/sfprocs.h ../include/sfproto.h
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c sfdata.c
$(TARGETPFX)sfexpasc.o: sfexpasc.c $(HACK_H) ../include/sfprocs.h ../include/sfproto.h
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c sfexpasc.c
$(TARGETPFX)sf-struct.o: ../src/sfstruct.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/sfstruct.c
$(TARGETPFX)strutil.o: ../src/strutil.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/strutil.c
$(TARGETPFX)sf-sys.o: ../src/sys.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/sys.c
$(TARGETPFX)sf-timeout.o: ../src/timeout.c
@@ -382,15 +389,9 @@ $(TARGETPFX)sf-version.o: ../src/version.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/version.c
$(TARGETPFX)sf-worm.o: ../src/worm.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/worm.c
$(TARGETPFX)sf-nhlua.o: ../src/nhlua.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/nhlua.c
$(TARGETPFX)sfbase.o: ../src/sfbase.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/sfbase.c
$(TARGETPFX)strutil.o: ../src/strutil.c
$(TARGET_CC) $(TARGET_CFLAGS) $(SFFLAGS) -o $@ -c ../src/strutil.c
sftags: sftags.o
$(CLINK) $(LFLAGS) -o $@ sftags.o $(LIBS)
sftags: sftags.o $(HACKLIB)
$(CLINK) $(LFLAGS) -o $@ sftags.o $(HACKLIB) $(LIBS)
sftags.o: sftags.c $(HACK_H)
$(CC) $(CFLAGS) -c sftags.c
../include/sfproto.h: sf.tags sftags

View File

@@ -2479,21 +2479,18 @@ $(DAT)bogusmon: $(U)makedefs.exe $(DAT)bogusmon.txt
#===============================================================================
# sfutil
#===============================================================================
SFCTOOLOBJS = $(OUTL)sfctool.o $(OUTL)sf-alloc.o \
$(OUTL)sf-monst.o $(OUTL)sf-objects.o \
$(OUTL)sfbase.o $(OUTL)sf-struct.o \
$(OUTL)sfexpasc.o \
$(OUTL)sfdata.o $(OUTL)sf-nhlua.o \
$(OUTL)panic.o $(OUTL)sf-date.o $(OUTL)sf-decl.o \
$(OUTL)sf-artifact.o $(OUTL)sf-cfgfiles.o \
$(OUTL)sf-dungeon.o $(OUTL)sf-end.o \
SFCTOOLOBJS = $(OUTL)sfctool.o \
$(OUTL)sf-alloc.o $(OUTL)sf-artifact.o $(OUTL)sfdata.o \
$(OUTL)sf-date.o $(OUTL)sf-decl.o $(OUTL)sf-calendar.o \
$(OUTL)sf-cfgfiles.o $(OUTL)sf-dungeon.o $(OUTL)sf-end.o \
$(OUTL)sf-engrave.o $(OUTL)sf-files.o $(OUTL)sf-light.o \
$(OUTL)sf-mdlib.o $(OUTL)sf-mkmaze.o $(OUTL)sf-mkroom.o \
$(OUTL)sf-o_init.o $(OUTL)sf-region.o \
$(OUTL)sf-restore.o $(OUTL)sf-rumors.o \
$(OUTL)sf-monst.o $(OUTL)sf-nhlua.o $(OUTL)sf-objects.o \
$(OUTL)sf-o_init.o $(OUTL)panic.o $(OUTL)sf-region.o \
$(OUTL)sf-restore.o $(OUTL)sf-rumors.o $(OUTL)sfbase.o \
$(OUTL)sfexpasc.o $(OUTL)sf-struct.o $(OUTL)strutil.o \
$(OUTL)sf-sys.o $(OUTL)sf-timeout.o $(OUTL)sf-track.o \
$(OUTL)sf-version.o $(OUTL)sf-worm.o \
$(OUTL)strutil.o $(OUTL)sf-windsys.o
$(OUTL)sf-version.o $(OUTL)sf-worm.o $(OUTL)sf-windsys.o
SFCTOOLBIN = $(BinDir)sfctool.exe
SFFLAGS = -DSFCTOOL -DNOPANICTRACE -DNOCRASHREPORT -DNO_CHRONICLE
@@ -2534,6 +2531,8 @@ $(OUTL)sf-struct.o: $(SRC)sfstruct.c
$(Q)$(CC) $(CFLAGS) $(SFFLAGS) -Fo$@ -c $(SRC)sfstruct.c
$(OUTL)sf-artifact.o: $(SRC)artifact.c
$(Q)$(CC) $(CFLAGS) $(SFFLAGS) -Fo$@ -c $(SRC)artifact.c
$(OUTL)sf-calendar.o: $(SRC)calendar.c
$(Q)$(CC) $(CFLAGS) $(SFFLAGS) -Fo$@ -c $(SRC)calendar.c
$(OUTL)sf-cfgfiles.o: $(SRC)cfgfiles.c
$(Q)$(CC) $(CFLAGS) $(SFFLAGS) -Fo$@ -c $(SRC)cfgfiles.c
$(OUTL)sf-dungeon.o: $(SRC)dungeon.c
@@ -2575,8 +2574,8 @@ $(OUTL)sf-sys.o: $(SRC)sys.c
$(OUTL)sf-windsys.o: $(MSWSYS)windsys.c
$(Q)$(CC) $(CFLAGS) $(SFFLAGS) -Fo$@ -c $(MSWSYS)windsys.c
$(UTIL)sftags.exe: $(OUTL)sftags.o
$(link) $(LFLAGS) /OUT:$@ $(OUTL)sftags.o
$(UTIL)sftags.exe: $(OUTL)sftags.o $(OUTLHACKLIB)
$(link) $(LFLAGS) /OUT:$@ $(OUTL)sftags.o $(OUTLHACKLIB)
$(OUTL)sftags.o: $(UTIL)sftags.c $(HACK_H)
$(Q)$(CC) $(CFLAGS) -Fo$@ -c $(UTIL)sftags.c
$(INCL)sfproto.h: $(UTIL)sftags.exe $(UTIL)sf.tags

View File

@@ -62,6 +62,7 @@
<ClCompile Include="$(UtilDir)sfexpasc.c" />
<ClCompile Include="$(UtilDir)sfdata.c" />
<ClCompile Include="$(SysWindDir)windsys.c" />
<ClCompile Include="$(SrcDir)calendar.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(IncDir)extern.h" />

View File

@@ -91,6 +91,8 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ToolsDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>hacklib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -108,6 +110,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ToolsDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>hacklib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -121,6 +125,8 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ToolsDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>hacklib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -139,6 +145,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ToolsDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>hacklib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />