.SUFFIXES: .o .obj .c
.PHONY: all clean

CC         =gcc -Wall -DOS_2 -I../h
CFLAGS     = -g -O
OMF        =-Zomf -Zsys -Zso
O          =o
LIB        =msgapi.a
OBJTARGET  =msgapi32.dll
FINALTARGET=msgapi32.a

.c.obj:
	$(CC) $(OMF) -c $<

OBJS=api_sdm.$(O) bld.$(O)     msgapi.$(O)  sq_area.$(O) sq_help.$(O) \
     sq_idx.$(O)  sq_kill.$(O) sq_lock.$(O) sq_misc.$(O) sq_msg.$(O)  \
     sq_read.$(O) sq_uid.$(O)  sq_write.$(O)

SLIB=1stchar.$(O) cvtdate.$(O) date2bin.$(O) dosdate.$(O) fexist.$(O)   \
     ffind.$(O)   flush.$(O)   parsenn.$(O)  qksort.$(O)  stristr.$(O)  \
     strocpy.$(O) trail.$(O)   _ctype.$(O)   nopen.$(O)   setfsize.$(O) \
     tdelay.$(O)  weekday.$(O)  ic_misc.$(O) months.$(O)

all: $(LIB) # $(FINALTARGET)
	-echo Done >all

$(LIB): $(OBJS) $(SLIB)
	-@rm -f $@
	ar rcs $@ $(OBJS) $(SLIB)
	cp $@ ../lib/msgapi-d.a

$(OBJTARGET): emxdll.$(O) $(OBJS) $(SLIB)
	-@rm -f $@
	gcc -s -Wall -Zdll $(OMF) -o $@ emxdll.$(O) $(OBJS) $(SLIB) msgapi.def

$(FINALTARGET): $(OBJTARGET)
	-@rm -f $@
	emximp -o msgapi.imp msgapi.def
	emximp -o $@ msgapi.imp

clean:
	-@rm *.imp *.$(O) *.a *.lib *.dll
