.SUFFIXES: .o .C .c  .cpp

include mkfiles.mac

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

include ../../sys/config/mkflags

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

CPPOBJECTS =$(CPPOBJS:%= $(OBJDIR)/%)
CCOBJECTS =$(CCOBJS:%= $(OBJDIR)/%)
CPPOBJECTS2 =$(CPPOBJS:%= $(OBJDIR2)/%)
CCOBJECTS2 =$(CCOBJS:%= $(OBJDIR2)/%)

#.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  = libwsx11d.dylib
LIBDLL2 = libwsx11.dylib
LIBST   = $(LIBNAMED2)
LIBST2  = $(LIBNAME2)

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

$(LIBDIR)/$(LIBDLL): $(CPPOBJECTS) $(CCOBJECTS)
	$(CC) -r -keep_private_externs -nostdlib -o debug/master_obj.o $(CPPOBJECTS) $(CCOBJECTS) $(XLIBS)
	$(CC) -dynamiclib -current_version $(VERSION) -compatibility_version $(VERSION) -o $(LIBDLL) debug/master_obj.o $(XLIBS) -lwsd  /usr/X11R6/lib/libxpm.a /usr/X11R6/lib/libjpeg.a /usr/X11R6/lib/libpng.a -lz -framework carbon
	cp $(LIBDLL) ../../lib/$(LIBDLL)
	cp $(LIBDLL) /usr/lib/$(LIBDLL)
#	cd $(LIBDIR);\rm -f $(LIBNAMED);\ln -s $(LIBDLL) $(LIBNAMED)
$(LIBDIR)/$(LIBDLL2): $(CPPOBJECTS2) $(CCOBJECTS2)
	$(CC) -r -keep_private_externs -nostdlib -o runtime/master_obj.o $(CPPOBJECTS2) $(CCOBJECTS2) $(XLIBS)
	$(CC) -dynamiclib -current_version $(VERSION) -compatibility_version $(VERSION) -o $(LIBDLL2) runtime/master_obj.o $(XLIBS) -lws  /usr/X11R6/lib/libxpm.a /usr/X11R6/lib/libjpeg.a /usr/X11R6/lib/libpng.a -lz -framework carbon
	cp $(LIBDLL2) ../../lib/$(LIBDLL2)
	cp $(LIBDLL2) /usr/lib/$(LIBDLL2)
#	cd $(LIBDIR);\rm -f $(LIBNAME);\ln -s $(LIBDLL2) $(LIBNAME)

$(LIBDIR)/$(LIBST): $(CPPOBJECTS) $(CCOBJECTS)
	ar -rv $(LIBDIR)/$(LIBST) $(CPPOBJECTS) $(CCOBJECTS)
	$(RANLIB) $(LIBDIR)/$(LIBST)

$(LIBDIR)/$(LIBST2): $(CPPOBJECTS2) $(CCOBJECTS2)
	ar -rv $(LIBDIR)/$(LIBST2) $(CPPOBJECTS2) $(CCOBJECTS2)
	$(RANLIB) $(LIBDIR)/$(LIBST2)


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

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


clean:
	\rm -f $(CPPOBJECTS) $(CCOBJECTS) $(CPPOBJECTS2) $(CCOBJECTS2) *.bak
	\rm -f $(LIBDIR)/$(LIBDLL) $(LIBDIR)/$(LIBDLL2) 
	\rm -f $(LIBDIR)/$(LIBST) $(LIBDIR)/$(LIBST2)
	\rm -f $(LIBDIR)/$(LIBNAMED)
	\rm -f $(LIBDIR)/$(LIBNAME)
	\rm -f $(LIBDLL)
	\rm -f $(LIBDLL2)
	\rm -f runtime/master_obj.o
	\rm -f runtime-st/master_obj.o
	\rm -f debug/master_obj.o     
	\rm -f debug-st/master_obj.o



