|
|
Makefile:how to force exit and show usage msg?
I'm not finding how to do this.
I want to force exit with a usage message if user doesn't enter correct
build parameters.
Also, I can't get my usage msg to show up in all cases where I want it
to. My usage msg is forced into a file, that I want to cat when it
should be shown.
Running in linux, gmake.
Example makefile:
#=======================================
USAGE:force
@$(ECHO) " usage text put in file for output on demand">usage
# force usage file to be recreated every time
force: ;
ifndef platform
platform=linux
else
ifneq "$(platform)" "linux"
showhelp::help
# exit # How can I force exit here?
else
PLATFORM_CODE=LX
endif
endif
ifndef build
build=internal
endif
ifdef build
ifneq "$(build)" "beta"
ifneq "$(build)" "patch"
ifneq "$(build)" "release"
ifneq "$(build)" "internal"
showhelp::help
# exit # How can I force exit here?
endif
endif
endif
endif
endif
include $(platform).env
help:
@cat usage
# other non pertinent stuff not included in example...
#================ end of example =====
What I find when I run this with the command
make platform=foo
is it tells me that foo.env cannot be found. It should cat the usage
file and then exit.
help is not a file in my current directory.
if I run make -n platform=foo then I can see that the usage file is NOT
being created.
But, when I run make -n platform=linux, or make -n, it is created! I
don't understand why the difference.
I want to create the usage msg every time, because I expect that there
may be other makefiles that also create their own usage messages.
Thanks,
Dave
ps. I'm posting from googleGroups2 beta, and the makefile indentation
and tabs are not showing up in my msg preview window, sorry about that
if they don't show up.
|
|
0
|
|
|
|
Reply
|
kaatzd
|
9/3/2004 6:57:47 PM |
|
kaatzd@hotmail.com <kaatzd@hotmail.com> wrote:
> I'm not finding how to do this.
> I want to force exit with a usage message if user doesn't enter correct
> build parameters.
> Also, I can't get my usage msg to show up in all cases where I want it
> to. My usage msg is forced into a file, that I want to cat when it
> should be shown.
> Running in linux, gmake.
> Example makefile:
> #=======================================
> USAGE:force
> @$(ECHO) " usage text put in file for output on demand">usage
> # force usage file to be recreated every time
> force: ;
> ifndef platform
> platform=linux
> else
> ifneq "$(platform)" "linux"
> showhelp::help
> # exit # How can I force exit here?
> else
> PLATFORM_CODE=LX
> endif
> endif
> ifndef build
> build=internal
> endif
> ifdef build
> ifneq "$(build)" "beta"
> ifneq "$(build)" "patch"
> ifneq "$(build)" "release"
> ifneq "$(build)" "internal"
> showhelp::help
> # exit # How can I force exit here?
> endif
> endif
> endif
> endif
> endif
> include $(platform).env
> help:
> @cat usage
> # other non pertinent stuff not included in example...
> #================ end of example =====
> What I find when I run this with the command
> make platform=foo
> is it tells me that foo.env cannot be found. It should cat the usage
> file and then exit.
You can't have any commands before the first target. Something like
this should work:
ifneq ($(shell ls $(platform).env 2>/dev/null),)
include $(platform).env
PLATFORM := $(platform)
endif
..PHONY: create_usage_file help
all: create_usage_file
ifndef PLATFORM
@$(MAKE) help
@exit 2
endif
@echo $(platform)
@echo "Success: Platform is defined and .env file exists"
create_usage_file:
@echo "Usage info written into a file" > usage
help:
@cat usage
This checks if the file of the form $platform.env exists and if yes
it includes it and sets another variable that's checked later. The
'usage' file gets created always (unless you use a different target
than the default target) and if PLATFORM hasn't been defined the
usage file is displayed and make then exits. I don't know if that's
what you're looking for, if not please try to explain what what you
need to do differently.
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.toerring.de
|
|
0
|
|
|
|
Reply
|
Jens
|
9/3/2004 10:18:48 PM
|
|
|
1 Replies
1502 Views
(page loaded in 0.106 seconds)
Similiar Articles: Makefile:how to force exit and show usage msg? - comp.unix ...I'm not finding how to do this. I want to force exit with a usage message if user doesn't enter correct build parameters. Also, I can't get my usage msg to show up in ... [Eclipse] How to fix indentations. - comp.lang.java.help ...Makefile:how to force exit and show usage msg? - comp.unix ... How to debug makefile project target in Eclipse - comp.lang.c++ ... Makefile:how ... Force a format - comp.soft-sys.matlabMakefile:how to force exit and show usage msg? - comp.unix ... I want to force exit with a usage message if user ... Example makefile: #===== USAGE:force @$(ECHO) " usage ... socket flushing/buffering problem, app hangs on close - comp.lang ...I need to 'kill -9' in order to force an exit... very ugly. Seems ... I write data to the channel but the client ... Makefile:how to force exit and show usage msg? - comp ... How to force a socket to close ? - comp.unix.programmerPaul -- Ce message a ete poste via la ... lsof, fuser, or whatever the system has to show ... data to the channel but the client ... Makefile:how to force exit and ... Program does not exit! - comp.graphics.api.openglHow can I make the program exit? Code sample is ... Fiber Optic wrote in message ... >I have to use the GLUT_DISABLE_ATEXIT ... to do if a program won't uninstall: How to force ... comp.unix.programmer - page 32Everything works find except if I send "exit\n" from p... ... I'll show you the narrowed code: #include #include ... 8/21/2003 11:32:42 AM) Hi, I would like to create Makefile ... How to save files into a specific folder - comp.soft-sys.matlab ...... Prepare a figure to show the images in the upper ... FontSize', fontSize); drawnow; % Force it ... msgbox(finishedMessage)); % Also pop up a message box. % Exit if ... how to get frames from .avi format. - comp.soft-sys.matlab ...... 3D 0; % Prepare a figure to show the images in ... FontSize', fontSize); drawnow; % Force it ... msgbox(finishedMessage)); % Also pop up a message box. % Exit if ... Invisible window, like console app - comp.os.ms-windows.programmer ...I have a tiny demo utility that shows how to use WM_COPYDATA ... that a window is needed in order to > use a message queue ... api.opengl It sounds like there is NO WAY to force ... Re: Makefile:how to force exit and show usage msg?Date: 3 Sep 2004 22:18:48 GMT kaatzd@hotmail.com <kaatzd@hotmail.com> wrote: > I'm not finding how to do this. > I want to force exit with a usage message if user ... Unix & Linux: Makefile:how to force exit and show usage msg ...programming.itags.org: Unix & Linux question: Makefile:how to force exit and show usage msg?, created at:Tue, 29 Apr 2008 20:24:00 GMT with 1,971 bytes, last updated ... 7/20/2012 1:05:22 PM
|
|
|
|
|
|
|
|
|