[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Implement Check on Input Values
From: |
Ajay Jain |
Subject: |
Implement Check on Input Values |
Date: |
Mon, 8 Aug 2011 21:43:21 +0530 |
Hi,
In my make system, I need to implement check on the value of some
input parameters. For example, my makefile excepts WORK_DIR from
environment and checks the following:
1) Check to make sure that WORK_DIR is not NULL
2) Check to make sure that WORK_DIR exists
3) Check to make sure that WORK_DIR is NOT a part of TOP_DIR/Parent Directory
I need to check this logic within a rule and not otherwise as this is
not applicable to all targets.
So I wrote a (dirty) logic as follows:
check_work_dir :
$(SET) -ex ; \
if [ "$(WORK_DIR)" = "" ]; \
then $(ECHO) "WORK_DIR is NULL" ; \
exit -1; \
fi; \
if [ ! -d "$(WORK_DIR)" ]; \
then $(ECHO) "$(WORK_DIR) does NOT exist .." ;\
exit -1;\
fi; \
cd "$(WORK_DIR)"; \
tmp_dir1=`pwd`; \
tmp_dir2=$(dir $(dir $(TOP_DIR))); \
$(ECHO) "$$tmp_dir1" \| grep "$$tmp_dir2" ; \
if [ $$? -eq 0 ]; \
then $(ECHO) "WORK_DIR : $(WORK_DIR) should NOT be contained inside
$$tmp_dir2"; \
exit -1; \
fi
Is there a better way to implement this logic?
Many TIA,
Ajay
- Implement Check on Input Values,
Ajay Jain <=
- Re: Implement Check on Input Values, Stephan Beal, 2011/08/08
- Re: Implement Check on Input Values, Stephan Beal, 2011/08/08
- Re: Implement Check on Input Values, David Boyce, 2011/08/08
- Re: Implement Check on Input Values, Stephan Beal, 2011/08/08
- Re: Implement Check on Input Values, David Boyce, 2011/08/08
- Re: Implement Check on Input Values, Lane Schwartz, 2011/08/08
- Re: Implement Check on Input Values, David Boyce, 2011/08/08
Re: Implement Check on Input Values, Lane Schwartz, 2011/08/08