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
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make