# ***************************************************************************
#     PRIM_RULES.msvc      (!INCLUDE ed by "makefile-dllmod.msvc")
# --------------------------------------------------------------------------
# (C) Copyright Roger Bowler, 2005-2010
# --------------------------------------------------------------------------
#
#  Primary generic build rules...  ('all', 'clean', etc...)
#
# ***************************************************************************

# ---------------------------------------------------------------------
#  Primary build rules
# ---------------------------------------------------------------------

all: allzlib alllibbz2 allpcre allrexx allHercules
    if exist $(EXEDIR)\*.manifest del /f /q $(EXEDIR)\*.manifest
    echo.
    echo -- Hercules build complete --

allHercules: $(OBJDIR) $(EXEDIR) $(PDBDIR) $(MAPDIR) $(ASMDIR) \
    $(O)build_pch.pch \
    $(MODULES) \
    $(EXECUTABLES)

clean: $(OBJDIR) $(EXEDIR) $(PDBDIR) $(MAPDIR) $(ASMDIR)
    if exist $(OBJDIR)\*.* rmdir /s /q $(OBJDIR)
    if exist $(EXEDIR)\*.* rmdir /s /q $(EXEDIR)
    if exist $(PDBDIR)\*.* rmdir /s /q $(PDBDIR)
    if exist $(MAPDIR)\*.* rmdir /s /q $(MAPDIR)
!IFDEF ASSEMBLY_LISTINGS
    if exist $(ASMDIR)\*.* rmdir /s /q $(ASMDIR)
!ENDIF
!IFDEF DYNDIR
    if exist $(DYNDIR)\*.* rmdir /s /q $(DYNDIR)
!ENDIF
!IFDEF fna
    if exist $(fna) del /f /q $(fna)
!ENDIF
    echo.
    echo -- Hercules clean complete --

MT_EXE_CMD=if exist $@.manifest mt.exe -nologo -outputresource:$@;1 -manifest $@.manifest
MT_DLL_CMD=if exist $@.manifest mt.exe -nologo -outputresource:$@;2 -manifest $@.manifest

linkexe = $(link) -nologo $(ldebug) $(conlflags) $(O)build_pch.obj $** $(LIBS) -out:$@ -implib:$(O)$(@B).lib $(conlibsdll) $(MAPFILE)
linkdll = $(link) -nologo $(ldebug) $(dlllflags) $(O)build_pch.obj $** $(LIBS) -out:$@ -implib:$(O)$(@B).lib $(conlibsdll) $(MAPFILE)

{$(OBJDIR)}.obj{$(EXEDIR)}.exe:
    $(linkexe)
    $(MT_EXE_CMD)

{$(OBJDIR)}.obj{$(EXEDIR)}.dll:
    $(linkdll)
    $(MT_DLL_CMD)

# Dummy target entry: Since the primary target is .DLL
# and .LIB is generated in the same step.. And .LIB
# are used as input, the following generates an effective
# rule, with no side effect

{$(EXEDIR)}.dll{$(OBJDIR)}.lib:
    echo $* $@

.c{$(OBJDIR)}.obj::
    $(cc) $(cdebug) $(cflags) /I. $(use_pch_opt) $(cvarsdll) /Fo"$(OBJDIR)\\" /Fd"$(OBJDIR)\\" $<

# NOTE: to be safe, since this member contains build rules, we need to
# make sure there's always a blank line following the last build rule
# in the member so that nmake doesn't complain or otherwise treat the
# statements immediately following the original !INCLUDE statement as
# part of the build rule actions. Thus the purpose of the comments you
# are now reading as the very last few lines in every build rule member.
