##!dmake -f

.SWAP :

# main goal of this Makefile:
# LLIB.EXE, Librarian for OBJ files

# source in the Free-Dos initialization 
.INCLUDE .FIRST .IGNORE : fd_init.mk ../fd_init.mk ../../fd_init.mk

#
#Project related settings
#
PRG = llib.exe
SRC = lib.c libber.c list.c mktmp.c mlib.c tmplist.c types.c
OBJ = lib.obj libber.obj list.obj mktmp.obj mlib.obj tmplist.obj types.obj
HDR = dbug.h config.h list.h mlib.h lib.h yerror.h types.h tmplist.h
MYCFLAGS = # TEST=YES
MSGLIB !:= msg.lib
MSGDCL !:= yerror.h
LDLIBS = $(MSGLIB) $(FDLIB)\$(_MODEL)_$(LNG).lib $(FDLIB)\Suppl_$(_MODEL).lib
.IF $(_COMPTYPE) == BC
# Disable all the exception handling stuff
LDLIBS += noeh$(eq,$(_MODEL),t s $(_MODEL)).lib
.ENDIF

.IF $(_COMPILER) != MC
.IF $(NDEBUG)
.ELSE
OBJ += dbug.obj
SRC += dbug.c
.ENDIF
.ENDIF
#
#First target
#
all : $(PRG)	# copy library into Free-Dos library dir

.INIT : $(CFG) tags refs errlist # Will make the utilizing files

#
#C initialization file
#
.IF $(CFG)
# Compiler configuration file, for Borland C only
# options: no Windows, no RTTI, use pre-compiled headers, no floating point

CONFIGURATION = -W-	\
-X-	\
-H	\
-I.;$(INCDIR)	\
-L.;$(LIBDIR)	\
-H=libber.csm	\
-f-	\
-ff-	\
-m$(_MODEL)

.IF $(NDEBUG)
.ELSE
CONFIGURATION += -N
.ENDIF

.IF $(_COMPILER) == BC45
CONFIGURATION += -RT- -lye -lyx
.ENDIF

$(CFG) : $(MAKEFILE:s/-f//)
	Cat $(mktmp $(CONFIGURATION:t"\n")\n) >$@

.ENDIF


$(PRG) .SWAP : $(MSGLIB) $(OBJ) 
	@+if exist $(PRG) del $(PRG) >nul
.IF $(_COMPILER) == MC
	$(LD) $(LDFLAGS) $(MCDIR)\Pc86rl_s @$(mktmp $(OBJ:t" ") \n), $@, NUL,@$(mktmp $(LDLIBS:t" ") $(MCDIR)\Mclib\n)
.ELSE
	$(CC) $(CCLDFLAGS) -e$@ @$(mktmp $(OBJ:t"\n") $(LDLIBS:t"\n")\n)
.ENDIF

dbug.obj : dbug.c dbug.h

#MAKEDEP START
lib.obj : lib.c \
	 .\config.h .\dbug.h .\lib.h .\list.h .\mlib.h .\tmplist.h .\types.h \
	.\yerror.h
libber.obj : libber.c \
	 .\config.h .\dbug.h .\lib.h .\list.h .\tmplist.h .\types.h .\yerror.h
list.obj : list.c \
	 .\config.h .\dbug.h .\lib.h .\list.h .\types.h .\yerror.h
mktmp.obj : mktmp.c \
	 .\config.h .\dbug.h .\types.h .\yerror.h
mlib.obj : mlib.c \
	 .\config.h .\dbug.h .\lib.h .\list.h .\mlib.h .\tmplist.h .\types.h \
	.\yerror.h
tmplist.obj : tmplist.c \
	 .\config.h .\dbug.h .\lib.h .\list.h .\tmplist.h .\types.h .\yerror.h
types.obj : types.c \
	 .\config.h .\dbug.h .\types.h .\yerror.h
#MAKEDEP STOP

clean ::
	$(RM) $(RMFLAGS) -s yerror.h__ q*.asm q*.cp q*.co $$*.asm $$*.cp $$*.co
	$(RM) /fs $(LNG).man $(LNG).tx

# source in the Free-Dos standard targets 
.INCLUDE .FIRST .IGNORE : fd_exit.mk ../fd_exit.mk ../../fd_exit.mk
