Hej Michael! Thanks for the answer!
Michael Ludwig skriver Sat, 10 Mar 2012 21:45:47 +0100 >* GNU Make looks for GNUmakefile first, so you could provide > one specifically for GNU Make. Good hint! It can be used to distinguise between GNU Make and other make programs. If the Makefile is not intended for GNU Make, a GNUmakefile could be provided. If GNU Make was used by mistake an error message can be generated by the GNUmakefile. >* You often see build.bat/build.sh/build.pl/Makefile.PL to > provide portability. Yes I know: perl Makefile.PL make make test ... But I should have used DMAKE instead of make and spoiled some day trying to find the "non existing" errors. An error message (in the makefile generated by "perl Makefile.PL") telling me that I was using the wrong make program had saved me some work. > >Maybe people come up with ideas if you provide the concrete >circumstances of the situation. Why would you want to do that >instead of going for one of the established solutions? > Here is my current try. I run this makefile by GNU Make and dmake. --------------------------------- # 1] Find which make program is used ifeq "{xxx}" "xxx" MAKE_USED = dmake endif ifneq "$(.VARIABLES)" "" MAKE_USED = gnumake endif # "allign" GNU make and dmake ifeq "$(MAKE_USED)" "dmake" MAKE_VERSION = $(MAKEVERSION) endif LEFT_CBRACKETS = { RIGHT_CBRACKETS = } ifeq "$(MAKE_USED)" "dmake" LEFT_CBRACKETS = {{ RIGHT_CBRACKETS = }} endif AT_ARGV_IN_CBRACKETS = $(LEFT_CBRACKETS)@ARGV$(RIGHT_CBRACKETS) NORL =@# No Output of Recipe Line .PHONY: all test warning error all: test warning error $(NORL)echo ----------------- End of $@ test: $(NORL)echo MAKE_USED is $(MAKE_USED) $(NORL)echo MAKE_VERSION is $(MAKE_VERSION) $(NORL)echo { is $(LEFT_CBRACKETS) $(NORL)echo } is $(RIGHT_CBRACKETS) $(NORL)echo AT_ARGV_IN_CBRACKETS is $(AT_ARGV_IN_CBRACKETS) $(NORL)echo ----------------- End of $@ warning: # 2] Give a warning message ifeq "$(MAKE_USED)" "gnumake" $(warning WARNING: This is a warning message) else $(NORL)echo WARNING: This is NOT sent to STDERR endif $(NORL)echo ----------------- End of $@ error: # 3] Give an error message and stop the make program ifeq "$(MAKE_USED)" "gnumake" $(error ERROR: Using $(MAKE_USED) for a Makefile intended for dmake) else $(NORL)echo ERROR: This is NOT sent to STDERR #Generates an error message $(assign ERR OR = ERROR) $(NORL)IS_NOT_REACHED endif $(NORL)echo ----------------- End of $@ --------------------------------- For GNU Make I have found solutions. However I have not found any good way of generating warning and error messages in dmake and to stop dmake. So I am looking for "portable" makefile idioms to: *Find which make program is used *Give an error message and stop the make program I also want the idioms to be portable to more make programs than GNU Make and dmake. I expected that there was "libraries" with "portable" makefile idioms! See also the original post http://lists.gnu.org/archive/html/help-make/2012-02/msg00022.html. Best regards Bosse _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make