How to put shell script to Makefile

Gavin Li gavinl at optech.ca
Mon Dec 5 20:06:30 UTC 2005


Steven,

Thanks for your reply.
What I can do in make file is:

KNL_VER     := $(shell uname -r)
KNL_MAJOR   := $(shell echo $(KNL_VER) | cut -c -3)
ifeq (2.4, $(KNL_MAJOR))
MAKE_FILE   := makefile
else
MAKE_FILE   := Makefile
endif

all: 
	$(MAKE) -C AppDir -f $(MAKE_FILE)


I just want to know how to put a bash script in make file instead of those
ifeq....endif statements.


KNL_VER     := $(shell uname -r)
KNL_MAJOR   := $(shell echo $(KNL_VER) | cut -c -3)

all:
	$(SHELL) if [2.4 == $(KNL_MAJOR)]; then \
		$(MAKE) -C AppDir -f makefile \
	else \
		$(MAKE) -C AppDir -f Makefile \
	fi
 But it doesn't work, I don't know how to do it.
I found some project use something like this in makefile

all:
	- at if [ ! -f .config ]; then \
		cp a.file b.file \
	fi


Why my make file doesn't work?



-----Original Message-----
From: Steven W. Orr [mailto:steveo at syslang.net] 
Sent: Friday, December 02, 2005 4:58 PM
To: Gavin Li
Cc: fedora-list at redhat.com
Subject: Re: How to put shell script to Makefile

On Friday, Dec 2nd 2005 at 16:07 -0500, quoth Gavin Li:

=>I have a script like this:
=>
=>KNL_VER=2.6.9
=>echo ${KNL_VER) | cut -c -3
=>if [ $? == "2.6"] ; then
=>            Make -f Makefile
=>else
=>            Make -f Makefile-2.4
=>endif
=>
=>How can I put in make file?

Gavin, you're very confused. $? is always the exit status code of the 
previous command. I'm not sure what you're looking for.

For starters:

KNL_VER=2.6.9
if [[ $(echo ${KNL_VER) | cut -c -3) = 2.6 ]]
then
    Make -f Makefile
else
    Make -f Makefile-2.4
fi

Now, please try again and tell me what you're trying to ask.

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have
.0.
happened but none stranger than this. Does your driver's license say Organ
..0
Donor?Black holes are where God divided by zero. Listen to me! We are all-
000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net




More information about the users mailing list