.SILENT:

# string\string.lib (clibc_16.lib) Makefile
# Byron Young
# 2002

# NMAKE 1.20
# ML 6.14

!IFNDEF DIR_PROJ
DIR_PROJ=..
!ENDIF

!INCLUDE $(DIR_PROJ)\Makefile.g

# Macros passed to Makefile via Makefile.g
#       DEBUG       0 = release, 1 = debug
#       ASM         assembler to use
#       AFLAGS_G    global assembler flags
#       AFLAGS_D    debug assembler flags
#       AFLAGS_R    release assembler flags
#	DIR_C_INCLUDE
#	DIR_ASM_INCLUDE
#	DIRLIB

# Macros passed to Makefile via command line
#	DIR_PROJ    project root directory

SRCFILES =      strcpy.asm\
		strlen.asm\
		skipsp.asm\
		skiptosp.asm\
		strcat.asm\
		strcmp.asm\
		strchr.asm\
		strstr.asm\
		strrchr.asm\
		stricmp.asm\
		skipspr.asm\
		skiptosr.asm\
		strlwr.asm\
		strupr.asm\
		strncpy.asm\
		strncat.asm\
		memmove.asm\
		memset.asm\
		memcmp.asm\

OBJFILESA=$(SRCFILES:.asm=.obj)

!IF $(DEBUG)
OBJFILES=..\debug\string\$(OBJFILESA: = ..\debug\string\)
INTDIR=..\debug\string
!ELSE
OBJFILES=..\release\string\$(OBJFILESA: = ..\release\string\)
INTDIR=..\release\string
!ENDIF


LIBNAME=$(INTDIR)\string.lib

STRING_DEPEND = Makefile string.h string.inc ..\Makefile ..\Makefile.g

$(LIBNAME) : $(OBJFILES)
        echo Creating $(LIBNAME)
        del $(LIBNAME)
	LIB /NOL @<<lib.lrf
$(LIBNAME) +$(?: = &^
+)
$(LIBNAME:.lib=.lst);
<<
	rename $(LIBNAME) string.lib
	echo Copying $(@B).h to $(DIR_C_INCLUDE)
	copy $(@B).h $(DIR_C_INCLUDE)
	echo Copying $(@B).inc to $(DIR_ASM_INCLUDE)
	copy $(@B).inc $(DIR_ASM_INCLUDE)

# build descriptor block
$(OBJFILES) : $(SRCFILES) $(STRING_DEPEND)
!IF $(DEBUG)
	$(ASM) @<<clcd16.lrf
/c $(AFLAGS_G) $(AFLAGS_D) /Fo$@ $(@B).asm
<<NOKEEP
!ELSE
	$(ASM) @<<clcr16.lrf
/c $(AFLAGS_G) $(AFLAGS_R) /Fo$@ $(@B).asm
<<NOKEEP
!ENDIF

# clean psudotarget
clean:
    @erase *.obj
    @erase *.lst
    @erase *.bak
    @erase *.dbg
    @erase *.exe
    @erase *.lrf
    @deltree /Y ..\release\string
    @deltree /Y ..\debug\string
    @echo Making string directories
    @mkdir ..\release\string
    @mkdir ..\debug\string

# misc notes
# to add a source file:
#    add the .asm name to SRCFILES
