install_a :: $(ARLIB)
ifdef ARLIB
	-mkdir -p $(LIB)
	$(INS) $(ARLIB) $(LIB)
endif

SHLIB=lib$(SHBASE).$(SHLIB_EXT).$(MAJOR).$(MINOR).$(PATCH)

SONAME=lib$(SHBASE).$(SHLIB_EXT).$(MAJOR)

install_s :: $(SHLIB)
ifdef SHLIB
	-mkdir -p $(LIB)
	-mv -f $(LIB)/$(SHLIB) $(LIB)/$(SHLIB).OLD
	$(INSS) $(SHLIB) $(LIB)
	cd $(LIB); ln -sf $(SHLIB) $(SONAME); \
        ln -sf $(SHLIB) lib$(SHBASE).$(SHLIB_EXT)
endif

install_h :: $(HDRS)
ifdef HDRS
	-mkdir -p $(INC)
	$(INS) $(HDRS) $(INC)
endif

archive : $(ARLIB)

shared : $(SHLIB)

$(ARLIB) : $(OBJS)
ifdef ARLIB
	$(AR) $(ARFLAGS) $@ $?
	$(RANLIB) $@
endif
	
SOBJS = $(OBJS:.o=.pic.o)

$(SHLIB): $(SOBJS)
ifdef SHLIB
	rm -f $@
	$(CSOCMD) -o $@ $(CSOFLAGS) $(SOBJS) $(SLDFLAGS) -lc
	ln -sf $(SHLIB) lib$(SHBASE).$(SHLIB_EXT)
	ln -sf $(SHLIB) lib$(SHBASE).$(SHLIB_EXT).$(MAJOR)
endif

%.pic.o: %.c
	$(CC) -c $(CSOCCFLAGS) $(CFLAGS) $< -o $@

%.o: %.c
	$(CC) -c $(COFLAGS) $(CFLAGS) $< -o $@

$(APPS): % : %.o
	$(CC) $< -o $@ $(CUSESHLIBFLAGS) $(LOADLIBES) 

install_p : $(APPS)
ifdef APPS
	-mkdir -p $(BIN)
	$(INSX) $(APPS) $(BIN)
endif

progs: $(APPS)

#LOADLIBES=-L. -l$(SHBASE)

install_m :: install_m1 install_m3 install_m5

install_m1: $(MAN1S)
ifdef MAN1S
	-mkdir -p $(MAN1)
	$(INS) $(MAN1S) $(MAN1)
endif

install_m3: $(MAN3S)
ifdef MAN3S
	-mkdir -p $(MAN3)
	$(INS) $(MAN3S) $(MAN3)
endif

install_m5: $(MAN5S)
ifdef MAN5S
	-mkdir -p $(MAN5)
	$(INS) $(MAN5S) $(MAN5)
endif

clean::
	rm -f *.o $(ARLIB) $(SHLIB) $(APPS)
