/*
  Rules to have a much cleaner compilation output

  derived from Imake.rules
*/

#define RemoveFileQuiet(file) @$(RM) -f file \&>/dev/null

#define RunPrintIfFailed(cmd)	@cmd || { echo failed command: cmd; exit 1; }

#define ObjectCompile(options) RemoveFileQuiet($@)			@@\
	ClearmakeOSName \
	@echo \ \ CC $*.c						@@\
	RunPrintIfFailed($(CC) -c $(CFLAGS) options $*.c)

#define NormalLibraryTarget(libname,objlist)				@@\
AllTarget(LibraryTargetName(libname))					@@\
									@@\
LibraryTargetName(libname): objlist $(EXTRALIBRARYDEPS)		@@\
	@echo \ \ CCLD $@						@@\
	RemoveFileQuiet($@)						@@\
	RunPrintIfFailed(MakeLibrary($@,objlist))			@@\
	RunPrintIfFailed(RanLibrary($@))				@@\
	RunPrintIfFailed(_LinkBuildLibrary($@))

#define	DependTarget()						@@\
DependDependency()							@@\
									@@\
depend::								@@\
	RunPrintIfFailed($(DEPEND) $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS))
