#
# Makefile for the FreeDOS C Library
#

# What we should call the resulting library
LIBNAME=core

# Common definitions
include ..\common.mak

# The object files to be built normally
SRC=_calldos.c _dmyfct.c _getsp.asm _intr.c intr.c
OBJS=_calldos.obj _dmyfct.obj _getsp.obj _intr.obj intr.obj
OBJS_1=_calldos.obj _dmyfct.obj _getsp.obj _intr.obj intr.obj

# All the object files
OBJS_ALL=$(OBJS) $(OBJS_STARTUP) $(OBJS_TEST)

# Objects that should be built when testing
OBJS_TEST=t.c

# These objects are the C library startup (c0)
#OBJS_STARTUP=c0t.obj c0s.obj c0m.obj c0c.obj c0l.obj c0h.obj
OBJS_STARTUP= c0$(C_MODEL).obj

all:

library:   $(OBJS) $(OBJS_STARTUP) $(LIBNAME).lib
	-echo Library $(LIBNAME).lib successfully created

$(LIBNAME).lib: $(OBJS)
	-for %i in ($(LIBNAME).lib $(LIBNAME).lst) do if exist %i del %i >nul
	$(AR) $(LIBNAME) $(ARFLAGS) + $(OBJS_1)
	$(CP) $@ ..\obj\$@
#	$(CP) $(LIBNAME).lst ..\obj\$(LIBNAME).lst

c0$(C_MODEL).obj:
	$(AS) $(ASFLAGS) $(ASDEFINE)$(ASM_MODEL) c0.asm $(ASSEP) c0t.obj     \
	$(ASLST) $(ASCRF)
	$(CP) $@ ..\lib\$@

clean:
# I would have liked to have used OBJS_ALL, but command.com complains
# that the argument list is too long. Oh well
	-for %i in ($(OBJS_1)) do if exist %i del %i >nul
	-for %i in ($(LIBNAME).lib $(LIBNAME).lst) do if exist %i del %i >nul
	-for %i in (*.err) do del %i >nul
