$(TARGET):  $(FLAGS) $(LIBS) $(DEPS) $(OBJECTS)
	$(CXX) $(WARNFLAGS) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) $(LDLIBS) -o $(TARGET)
ifneq ($(POST_BUILD),)
	$(POST_BUILD) $(TARGET)
endif

ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif

.PHONY: clean install $(SUBDIRS)

# NOTE: empty command for LIBS - must be made by subdir makes
$(LIBS): $(SUBDIRS) ;

# Rule for making subdir targets
$(SUBDIRS):
	@$(MAKE) -C $@ $(findstring clean, $(MAKECMDGOALS))


$(FLAGS):
	$(error No configuration found - please run $(PROJECT_ROOT)/configure first)

ifeq ($(findstring Windows,$(OS)),)
install: $(TARGET)
	 $(INSTALL) $(TARGET) $(INSTALL_DIR)

clean: $(SUBDIRS)
	@$(RM) $(TARGET)
	@$(RM) $(OBJECTS)
	@$(RM) $(DEPS)
else
install: $(TARGET)
	 copy $(subst /,\,$(TARGET)) $(INSTALL_DIR)
RM := del /F /Q
clean: $(SUBDIRS)
	@$(RM) $(subst /,\,$(TARGET))  2>nul
	@$(RM) $(subst /,\,$(OBJECTS)) 2>nul
	@$(RM) $(subst /,\,$(DEPS))    2>nul
endif

