##############################################################################
# library-building rules

TARGETS = $(THISLIB)

all:
	@if [ "x$(CONDITIONAL_BUILD)" != "x" ] &&			      \
	       egrep -s FALSE ../../config/vdefs/$(CONDITIONAL_BUILD).h;      \
        then								      \
	       echo "skipping $(CUR)";					      \
	       rm -f .objects; touch .objects;				      \
	       ln -fs $(TOPSRC)/fe/dummy.a $(THISLIB);			      \
	else								      \
	    if test -r $(DEPFILE); then					      \
	       $(MAKE) CUR=$(CUR) -f Makefile -f $(DEPFILE) $(THISLIB);	      \
	    else							      \
	       $(MAKE) CUR=$(CUR) -f Makefile $(THISLIB);		      \
	    fi								      \
	fi

objects: .objects
	@if [ -r .objects ]; then cat .objects; fi

# This rule should not get run when the system is working.
# It can only happen thru version skew. Hence, rebuild completely.
.objects:
	@$(ECHO) "Oog... rebuilding, sorry"
	$(MAKE) clean
	$(MAKE)
	
$(THISLIB): $(OBJECTS)
	@if test -z "$(DEPENDING)"; then				      \
	  rm -f .objects; for f in $(OBJECTS); do echo $$f >> .objects; done; \
	  $(RM) -f $@;							      \
	  echo $(AR) cq $@ $(OBJECTS) '(and some more magic)';		      \
	       $(AR) cq $@ $(OBJECTS);					      \
	  $(RANLIB) $@;							      \
	fi || test ok
