.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
#   ASM	    assembler to use
#   CC	    c compiler to use
#   AFLAGS_G	  global assembler flags
#   AFLAGS_D	  debug assembler flags
#   AFLAGS_R	  release assembler flags
#   CFLAGS_G	global c compiler flags
#   CFLAGS_D	debug c compiler flags
#   CFLAGS_R	release c compiler flags
#   DIR_C_INCLUDE
#   DIR_ASM_INCLUDE
#   DIRLIB
#   CLIBC_16_FN_CALL - near or far function call
#   CLIBC_16_FUNCTION_SEG_NAME - name for function
#   CLIBC_16_FN_CALL_FARCALL_SEG - combine method
#   CLIBC_16_FUNCTION_SEG - name of function code segment
#   CLIBC_16_EXTERN_PTRS - if generated pointers to functions
#   CLIBC_16_EXTERN_PTRS_SEG_NAME - data seg name for pointers

# Macros passed to Makefile via command line
#   DIR_PROJ - project root directory
#   DEBUG -  build debug, or release object files
#   DIR_CURRENT - current directory

# source file filenames
# AAABBBFO
# AAA letters, defining the function group
#	      str=string, mis=misc
# BBB digits, defining the function number within group
# F   digit, 0=normal call, 1=fastcall
# O   digit, 0=normal, 1=_sss, 2=_dss

# 000 strcpy 6
# 001 strlen 4
# 002 skipsp 4
# 003 skiptosp 4
# 004 strcat 6
# 005 strcmp 6
# 006 strchr 4
# 007 strstr 6
# 008 strrchr 4
# 009 stricmp 6
# 010 skipspr 4
# 011 skiptosr 4
# 012 strlwr   4
# 013 strupr   4
# 014 strncpy  6
# 015 strncat  6
# 016 memmove  6
# 017 memset   4
# 018 memcmp   6

SRCFILES =	str00000.asm\
		str00010.asm\
		str00001.asm\
		str00011.asm\
		str00002.asm\
		str00012.asm\
		str00100.asm\
		str00110.asm\
		str00101.asm\
		str00111.asm\
		str00200.asm\
		str00210.asm\
		str00201.asm\
		str00211.asm\
		str00300.asm\
		str00310.asm\
		str00301.asm\
		str00311.asm\
		str00400.asm\
		str00410.asm\
		str00401.asm\
		str00411.asm\
		str00402.asm\
		str00412.asm\
		str00500.asm\
		str00510.asm\
		str00501.asm\
		str00511.asm\
		str00502.asm\
		str00512.asm\
		str00600.asm\
		str00610.asm\
		str00601.asm\
		str00611.asm\
		str00700.asm\
		str00710.asm\
		str00701.asm\
		str00711.asm\
		str00702.asm\
		str00712.asm\
		str00800.asm\
		str00810.asm\
		str00801.asm\
		str00811.asm\
		str00900.asm\
		str00910.asm\
		str00901.asm\
		str00911.asm\
		str00902.asm\
		str00912.asm\
		str01000.asm\
		str01010.asm\
		str01001.asm\
		str01011.asm\
		str01100.asm\
		str01110.asm\
		str01101.asm\
		str01111.asm\
		str01200.asm\
		str01210.asm\
		str01201.asm\
		str01211.asm\
		str01300.asm\
		str01310.asm\
		str01301.asm\
		str01311.asm\
		str01400.asm\
		str01410.asm\
		str01401.asm\
		str01411.asm\
		str01402.asm\
		str01412.asm\
		str01500.asm\
		str01510.asm\
		str01501.asm\
		str01511.asm\
		str01502.asm\
		str01512.asm\
		str01600.asm\
		str01610.asm\
		str01601.asm\
		str01611.asm\
		str01602.asm\
		str01612.asm\
		str01700.asm\
		str01710.asm\
		str01701.asm\
		str01711.asm\
		str01800.asm\
		str01810.asm\
		str01801.asm\
		str01811.asm\
		str01802.asm\
		str01812.asm





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

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

LIST_FILE = /Sa /Sc

LIBNAME=$(INTDIR)\string.lib

STRING_DEPEND = Makefile string.h string.inc

#!IF $(CLIBC_16_FN_CALL_FARCALL_SEG)==$(CLIBC_16_FN_CALL_FARCALL_SEG_MULTIPLE)
#CLIBC_16_FUNCTION_SEG_NAME=STRING$(CLIBC_16_FUNCTION_SEG_NAME)
#!ENDIF

CLIBC_16_MODULE=STRING

GLOBAL_DEFINES=\
       /DDEBUG=$(DEBUG)\
       /DCLIBC_16_FN_CALL=$(CLIBC_16_FN_CALL)\
!IFDEF CLIBC_16_FN_CALL_FARCALL_SEG
       /DCLIBC_16_FN_CALL_FARCALL_SEG=$(CLIBC_16_FN_CALL_FARCALL_SEG)\
!ENDIF
       /DCLIBC_16_FUNCTION_SEG_NAME=$(CLIBC_16_FUNCTION_SEG_NAME)\
       /DCLIBC_16_EXTERN_PTRS=$(CLIBC_16_EXTERN_PTRS)\
!IFDEF CLIBC_16_EXTERN_PTRS_SEG_NAME
       /DCLIBC_16_EXTERN_PTRS_SEG_NAME=$(CLIBC_16_EXTERN_PTRS_SEG_NAME)\
!ENDIF
       /DCLIBC_16_MODULE=$(CLIBC_16_MODULE)


$(LIBNAME) : $(OBJFILES)
        echo Creating $(LIBNAME)
        del $(LIBNAME)
	LIB /NOL @<<lib.lrf
$(LIBNAME) +$(?: = &^
+)
$(LIBNAME:.lib=.lst);
<<
	rename $(LIBNAME) string.lib
	if NOT EXIST $(DIR_C_INCLUDE) mkdir $(DIR_C_INCLUDE)
	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)
!IF $(DEBUG)==$(DEBUG_YES)
	$(ASM) @<<clcd16.lrf
/c $(AFLAGS_G) $(AFLAGS_D) $(GLOBAL_DEFINES) $(LIST_FILE) /Fl$(@R).lst /Fo$@ $(@B).asm
<<NOKEEP
!ELSE
	$(ASM) @<<clcr16.lrf
/c $(AFLAGS_G) $(AFLAGS_R) $(GLOBAL_DEFINES) $(LIST_FILE) /Fl$(@R).lst /Fo$@ $(@B).asm
<<NOKEEP
!ENDIF


$(INTDIR) : $(LIBNAME) $(STRING_DEPENDS)
    ECHO STRING_HEREEEEE

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

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