!include ..\makefile.inc
RES_DIR=.\messages\$(ALT_PROJECT)

.SUFFIXES:      .sym .map
SRCDIR = .
NAME1=$(DEST)\regedt16
NAME2=$(DEST)\regload

!ifdef NOHELP
DEF =/DNOHELP
!else
DEF=
!endif

INCLUDES=..\inc;$(SDK_INC_PATH)
CFLAGS  = -c -W3 -AS -G2sw -Zlp -Os $(DEF)
AFLAGS = -Mx
LFLAGS = /ALIGN:16/NOE/LI/MAP


!if !$(FREEBUILD)
DODEBUG=1
DEF = -DDEBUG $(DEF)
CFLAGS = $(CFLAGS) -Od -Zi
AFLAGS = $(AFLAGS) /Zi
LFLAGS = $(LFLAGS) /CO
!ENDIF

COMMON1 = $(DEST)\cutils1.obj $(DEST)\merge.obj $(DEST)\dbase.obj
COMMON2 = $(DEST)\utils1.obj $(DEST)\regporte.obj $(DEST)\regthunk.obj
OBJ1_1 = $(DEST)\regmain.obj $(DEST)\regedit.obj $(DEST)\filename.obj
OBJ1_2 = $(DEST)\sdkreged.obj $(DEST)\sdbase.obj $(DEST)\virt.obj
OBJ2_1 = $(NAME2).obj
LIB1 = ..\lib\$(ALT_PROJECT)\libw ..\lib\slibcew ..\lib\snocrt ..\lib\commdlg ..\lib\$(DEST)\shell
LIB2 = ..\lib\$(ALT_PROJECT)\libw ..\lib\slibcew ..\lib\snocrt ..\lib\$(DEST)\shell

all: $(NAME1).exe
allall: all $(NAME2).exe
!IFNDEF DODEBUG
!IFDEF DEBUG
        nmake DODEBUG=
!ENDIF
!ENDIF

$(DEST)\regedit.res: $(RES_DIR)\regedit.rc $(RES_DIR)\sdkreged.dlg $(RES_DIR)\regedit.rcv
        set INCLUDE=$(INCLUDES)
        rc16 -I..\inc -r $(DEF) -fo$(DEST)\regedit.res $(RES_DIR)\regedit.rc

$(NAME2).res: $(RES_DIR)\regedit.rc $(RES_DIR)\sdkreged.dlg $(RES_DIR)\regload.rcv
        set INCLUDE=$(INCLUDES)
        rc16 -I..\inc -r $(DEF) -DREGLOAD -fo$(NAME2).res $(RES_DIR)\regedit.rc

{$(SRCDIR)}.c{$(DEST)}.obj:
        set INCLUDE=$(INCLUDES)
        cl16 $(CFLAGS) /Fo$*.obj $<

{$(SRCDIR)}.asm{$(DEST)}.obj:
        masm $(AFLAGS) $<, $*.obj;

regedt16:        $(NAME1).exe
!IFNDEF DODEBUG
!IFDEF DEBUG
        nmake DODEBUG= regedt16
!ENDIF
!ENDIF

regload:        $(NAME2).exe
!IFNDEF DODEBUG
!IFDEF DEBUG
        nmake DODEBUG= regload
!ENDIF
!ENDIF

#International mods
iclean:
    del *.rc
    del *.dlg
    del *.res


$(DEST)\regedt16.exe:$(DEST)\regedt16.tmp $(DEST)\regedit.res
        rc16 -I..\inc -t -30 $(DEST)\regedit.res $(NAME1).exe
        -binplace -o $(ALT_PROJECT_TARGET) $@

$(NAME2).exe:   $(NAME2).tmp $(NAME2).res
        rc16 -I..\inc -t -30 $(NAME2).res $(NAME2).exe
        -binplace -o $(ALT_PROJECT_TARGET) $@

$(NAME1).tmp $(NAME1).map: $(OBJ1_1) $(OBJ1_2) $(COMMON1) $(COMMON2) regedit.def
        $(LINK16) $(LFLAGS) @<<
           $(OBJ1_1) +
           $(OBJ1_2) +
           $(COMMON1) +
           $(COMMON2),
           $(NAME1).exe,
           $(NAME1),
           $(LIB1),
           regedit.def
<<
	cd $(DEST)
        mapsym regedt16.map
	cd ..\..\..
        type regedit.def > $(NAME1).tmp

$(NAME2).tmp $(NAME2).map: $(OBJ2_1) $(COMMON1) $(COMMON2) regload.def
        $(LINK16) $(LFLAGS) @<<
           $(OBJ2_1) +
           $(COMMON1) +
           $(COMMON2),
           $(NAME2).exe,
           $(NAME2),
           $(LIB2),
           regload.def
<<
	cd $(DEST)
        mapsym regload.map
	cd ..\..\..
        type regload.def > $(NAME2).tmp

debug:
        nmake DODEBUG=

clean: cleanup all

cleanup:
        if exist debug\$(NAME1).exe del debug\$(NAME1).exe
        if exist debug\$(NAME2).exe del debug\$(NAME2).exe
        if exist debug\$(NAME1).tmp del debug\$(NAME1).tmp
        if exist debug\$(NAME2).tmp del debug\$(NAME2).tmp
        if exist debug\*.res        del debug\*.res
        if exist debug\*.obj        del debug\*.obj
        if exist debug\*.map        del debug\*.map
        if exist debug\*.sym        del debug\*.sym
        if exist $(NAME1).exe       del $(NAME1).exe
        if exist $(NAME2).exe       del $(NAME2).exe
        if exist $(NAME1).tmp       del $(NAME1).tmp
        if exist $(NAME2).tmp       del $(NAME2).tmp
        if exist *.res              del *.res
        if exist *.obj              del *.obj
        if exist *.map              del *.map
        if exist *.sym              del *.sym


$(NAME2).obj:   regmain.c
        set INCLUDE=$(INCLUDES)
        cl16 -c -Fo$(NAME2).obj -DREGLOAD $(CFLAGS) regmain.c

depend:
        mv makefile makefile.old
        sed "/^# START Dependencies/,/^# END Dependencies/D" makefile.old > makefile.sub
        del makefile.old
        echo # START Dependencies >> makefile.sub
        includes -l *.c *.asm >> makefile.sub
        echo # END Dependencies >> makefile.sub

# START Dependencies
$(DEST)\cutils1.obj: cutils1.c common.h

$(DEST)\dbase.obj: dbase.c RegEdit.h common.h

$(DEST)\filename.obj: filename.c common.h

$(DEST)\regedit.obj: regedit.c RegEdit.h common.h

$(DEST)\regmain.obj: regmain.c RegEdit.h SDKRegEd.h common.h

$(DEST)\sdbase.obj: sdbase.c SDKRegEd.h common.h

$(DEST)\sdkreged.obj: sdkreged.c SDKRegEd.h common.h

$(DEST)\utils1.obj: utils1.c

$(DEST)\virt.obj: virt.c SDKRegEd.h common.h

$(DEST)\merge.obj: merge.c common.h

$(DEST)\regporte.obj: regporte.c reg1632.h regdef.h regporte.h regresid.h

$(DEST)\regthunk.obj: regthunk.c regporte.h
# END Dependencies