.SUFFIXES: .o .C .c  .cpp

include mkfiles.btron


##################################################################
include ../../sys/config/mkflags.btron


##################################################################

C++FLAGS += -I. -DWS
C++FLAGS2 += -I. -DWS
C++FLAGS_DLL += -I. -DWS
C++FLAGS2_DLL += -I. -DWS

CPPOBJECTS =$(CPPOBJS:%= $(OBJDIR)/%)
CCOBJECTS =$(CCOBJS:%= $(OBJDIR)/%)
CPPOBJECTSS =$(CPPOBJS2:%= $(OBJDIR)/%)

CPPOBJECTS2 =$(CPPOBJS:%= $(OBJDIR2)/%)
CCOBJECTS2 =$(CCOBJS:%= $(OBJDIR2)/%)
CPPOBJECTSS2 =$(CPPOBJS2:%= $(OBJDIR2)/%)

CPPOBJECTS-st =$(CPPOBJS:%= $(OBJDIR-st)/%)
CCOBJECTS-st =$(CCOBJS:%= $(OBJDIR-st)/%)
CPPOBJECTSS-st =$(CPPOBJS2:%= $(OBJDIR-st)/%)

CPPOBJECTS2-st =$(CPPOBJS:%= $(OBJDIR2-st)/%)
CCOBJECTS2-st =$(CCOBJS:%= $(OBJDIR2-st)/%)
CPPOBJECTSS2-st =$(CPPOBJS2:%= $(OBJDIR2-st)/%)



#.c.o:
#	$(CC1) $(C++FLAGS) -c $(*F).c  -o $(OBJDIR)/$*.o
#
#.C.o:
#	$(CC) $(C++FLAGS) -c $(*F).C   -o $(OBJDIR)/$*.o
#
#.cpp.o:
#	$(CC) $(C++FLAGS) -c $(*F).cpp -o $(OBJDIR)/$*.o
#

LIBDLLBASE  = $(LIBNAME)
#LIBDLL  = $(LIBNAME).$(VERSION).d
#LIBDLL2 = $(LIBNAME).$(VERSION)
LIBDLL  = $(LIBNAMED).$(VERSION)
LIBDLL2 = $(LIBNAME).$(VERSION)
LIBST   = $(LIBNAMED2)
LIBST2  = $(LIBNAME2)

#all: $(LIBDIR)/$(LIBDLL) $(LIBDIR)/$(LIBDLL2) $(LIBDIR)/$(LIBST) $(LIBDIR)/$(LIBST2)
all: static
static: $(LIBDIR)/$(LIBST2)
static-debug: $(LIBDIR)/$(LIBST)
debug: $(LIBDIR)/$(LIBDLL) 
runtime: $(LIBDIR)/$(LIBDLL2)

$(LIBDIR)/$(LIBDLL): $(CPPOBJECTS) $(CCOBJECTS) $(CPPOBJECTSS)
	$(CC) -o $(LIBDIR)/$(LIBDLL) $(SHARED)$(LIBDLL) $(CPPOBJECTS) $(CCOBJECTS) $(CPPOBJECTSS)
	cd $(LIBDIR);$(RM) -f $(LIBNAMED);\ln -s $(LIBDLL) $(LIBNAMED)
$(LIBDIR)/$(LIBDLL2): $(CPPOBJECTS2) $(CCOBJECTS2) $(CPPOBJECTSS2)
	$(CC) -o $(LIBDIR)/$(LIBDLL2) $(SHARED)$(LIBDLL2) $(CPPOBJECTS2) $(CCOBJECTS2) $(CPPOBJECTSS2)
	cd $(LIBDIR);$(RM) -f $(LIBNAME);\ln -s $(LIBDLL2) $(LIBNAME)

$(LIBDIR)/$(LIBST): $(CPPOBJECTS-st) $(CCOBJECTS-st) $(CPPOBJECTSS-st)
	$(STLD) $(STFLAGS) -o $(OBJDIR-st)/master_obj.o $(CPPOBJECTS-st) $(CCOBJECTS-st) $(CPPOBJECTSS-st)
	ar -rv $(LIBDIR)/$(LIBST) $(OBJDIR-st)/master_obj.o
	$(RANLIB) $(LIBDIR)/$(LIBST)

$(LIBDIR)/$(LIBST2): $(CPPOBJECTS2-st) $(CCOBJECTS2-st) $(CPPOBJECTSS2-st)
	$(STLD) $(STFLAGS) -o $(OBJDIR2-st)/master_obj.o $(CPPOBJECTS2-st) $(CCOBJECTS2-st) $(CPPOBJECTSS2-st)
	ar -rv $(LIBDIR)/$(LIBST2) $(OBJDIR2-st)/master_obj.o
	$(RANLIB) $(LIBDIR)/$(LIBST2)


$(OBJDIR)/%.o:%.cpp
	$(CC) $(C++FLAGS_DLL) -c $(*F).cpp -o $(OBJDIR)/$*.o
$(OBJDIR)/%.o:%.c
	$(CC1) $(C++FLAGS_DLL) -c $(*F).c   -o $(OBJDIR)/$*.o
$(OBJDIR2)/%.o:%.cpp
	$(CC) $(C++FLAGS2_DLL) -c $(*F).cpp -o $(OBJDIR2)/$*.o
$(OBJDIR2)/%.o:%.c
	$(CC1) $(C++FLAGS2_DLL) -c $(*F).c   -o $(OBJDIR2)/$*.o

$(OBJDIR-st)/%.o:%.cpp
	$(CC) $(C++FLAGS) -c $(*F).cpp -o $(OBJDIR-st)/$*.o
$(OBJDIR-st)/%.o:%.c
	$(CC1) $(C++FLAGS) -c $(*F).c   -o $(OBJDIR-st)/$*.o
$(OBJDIR2-st)/%.o:%.cpp
	$(CC) $(C++FLAGS2) -c $(*F).cpp -o $(OBJDIR2-st)/$*.o
$(OBJDIR2-st)/%.o:%.c
	$(CC1) $(C++FLAGS2) -c $(*F).c   -o $(OBJDIR2-st)/$*.o

#$(CPPOBJECTS):
#	$(CC) $(C++FLAGS) -c $(*F).cpp -o $*.o
#
#$(CCOBJECTS):
#	$(CC) $(C++FLAGS) -c $(*F).c -o $*.o


clean:
	$(RM) -f $(CPPOBJECTS) $(CPPOBJECTSS) $(CCOBJECTS) $(CPPOBJECTS2) $(CCOBJECTS2) $(CPPOBJECTSS) $(CPPOBJECTSS2) *.bak
	$(RM) -f $(CPPOBJECTS-st) $(CPPOBJECTSS-st) $(CCOBJECTS-st) $(CPPOBJECTS2-st) $(CCOBJECTS2-st) $(CPPOBJECTSS-st) $(CPPOBJECTSS2-st) *.bak
	$(RM) -f $(LIBDIR)/$(LIBDLL)  $(LIBDIR)/$(LIBDLL2) $(LIBDIR)/$(LIBST) $(LIBDIR)/$(LIBST2)
	$(RM) -f $(LIBDIR)/$(LIBNAMED)
	$(RM) -f $(LIBDIR)/$(LIBNAME)
	$(RM) -f $(LIBDIR)/$(LIBNAMED2)
	$(RM) -f $(LIBDIR)/$(LIBNAME2)
	$(RM) -f $(OBJDIR-st)/master_obj.o
	$(RM) -f $(OBJDIR2-st)/master_obj.o

