.SILENT:

NLM_NAME=nsapi_rd

JDKPATH=k:\jdk\jdk-1_2_2
NOVELLNDK=r:\nwsdk
NSSDK=r:\netscape
METROWERKSPATH=k:\mw\5.3

CC=$(METROWERKSPATH)\bin\mwccnlm
LINK=$(METROWERKSPATH)\bin\mwldnlm

JK_OBJS=\
	jk_ajp12_worker.obj \
	jk_ajp13_worker.obj \
	jk_ajp13.obj \
	jk_msg_buff.obj \
	jk_connect.obj \
	jk_jni_worker.obj \
	jk_lb_worker.obj \
	jk_uri_worker_map.obj \
	jk_map.obj \
	jk_pool.obj \
	jk_sockbuf.obj \
	jk_util.obj \
	jk_worker.obj \
	jk_nsapi_plugin.obj \
	jk_nwmain.obj \
	
all: $(NLM_NAME).nlm

$(NLM_NAME).nlm: $(JK_OBJS) link.opt
	@echo Linking $@
	@$(LINK) @link.opt

%.obj: %.c cc.opt
	@echo Compiling $<
	@$(CC) $< -o=$(@F) @cc.opt
	

%.obj: ../jk/%.c cc.opt
	@echo Compiling $<
	@$(CC) $< -o=$(@F) @cc.opt
	

cc.opt: Makefile.nw
	-@del cc.opt 2> NUL
	@echo Generating $@
	@echo -nosyspath -ext obj -c -align 1 -w nocmdline -bool on >> $@
ifdef DEBUG
	@echo -g >> $@
endif
	@echo -I$(NOVELLNDK)\include\nlm >> $@
	@echo -I$(NOVELLNDK)\include >> $@
	@echo -I$(NSSDK)\include >> $@
	@echo -I. >> $@
	@echo -I..\jk >> $@
	@echo -I$(METROWERKSPATH)\include >> $@
	@echo -I$(JDKPATH)\include >> $@
	@echo -I$(JDKPATH)\include\netware >> $@
	@echo -DN_PLAT_NLM >> $@
	@echo -DNETWARE >> $@
	@echo -DXP_NETWARE >> $@
	
link.opt: Makefile.nw
	-@del link.opt 2> NUL
	-@del link.def 2> NUL
	@echo -warnings off >> $@
	@echo -zerobss >> $@
	@echo -desc "Netscape Plugin for Tomcat" >> $@
	@echo -o $(NLM_NAME).nlm >> $@
	@echo -screenname "System Console" >> $@
	@echo -nlmversion 0,1,0 >> $@
ifdef DEBUG
	@echo -g >> $@
	@echo -sym internal >> $@
	@echo -sym codeview4 >> $@
	@echo -osym $(NLM_NAME).sym >> $@
endif
	@echo -nodefaults >> $@
	@echo -map $(NLM_NAME).map >> $@
	@echo -threadname "NSTomcat Thread" >> $@
	@echo -stacksize 64000 >> $@
	@echo $(METROWERKSPATH)\lib\nwpre.obj $(strip $(JK_OBJS)) >> $@
	@echo -commandfile link.def >> $@
	@echo module nsapi >> link.def
	@echo Import @$(NOVELLNDK)\imports\clib.imp >> link.def
	@echo Import @$(NOVELLNDK)\imports\lib0.imp >> link.def
	@echo Import @$(NOVELLNDK)\imports\nlmlib.imp >> link.def
	@echo Import @$(NOVELLNDK)\imports\threads.imp >> link.def
	@echo Import @$(NOVELLNDK)\imports\socklib.imp >> link.def
	@echo Import @$(NSSDK)\imports\nsapi.imp >> link.def
	@echo Export jk_init, jk_service >> link.def

clean:
	-@del *.obj 2> NUL
	-@del *.map 2> NUL
	-@del link.* 2> NUL
	-@del cc.opt 2> NUL
	-@del *.nlm 2> NUL
	
