Makefile - If Statement?

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Makefile - If Statement?
# 1  
Makefile - If Statement?


I'm creating a Makefile, and in one of my targets, i need an IF statement to determine if two things are equal... but, I can't get it to run. Any ideas what is wrong?

Here's a snippet of the test from makefile:

        ifeq("a", "a")

# 2  

It helps if you say more than: I can't get it to run, versions, etc.

So, for this script:
#!/usr/bin/env bash

# @(#) s1       Demonstrate ifeq in make, with, without parens.

set +o nounset
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) make
set -o nounset


echo " Data file $FILE:"
cat $FILE

echo " Results:"

exit 0

We get:
% ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.11-x1, i686
Distribution        : Xandros Desktop 3.0.3 Business
GNU bash 2.05b.0
GNU Make 3.80

 Data file Makefile:
# Sat Jan 24 11:25:44 CST 2009

        @echo " No parens, whitespace ignored."
  ifeq    "a"    "a"
        @echo " Strings are equal."
        @echo " Strings differ."
        @echo " With parens -- tricky comparison of whitespace."
  ifeq ( "a", "a" )
        @echo " Strings are equal."
        @echo " Strings differ."


 No parens, whitespace ignored.
 Strings are equal.

 With parens -- tricky comparison of whitespace.
 Strings differ.

You can google for examples or read GNU Make Manual - GNU Project - Free Software Foundation (FSF) or try:
Title: Managing Projects with GNU Make
Author: R Mecklenburg
Edition: 3rd
Date: 2004
Publisher: O'Reilly
ISBN: 0-596-00610-1
Pages: 280
Categories: *nix, development, compiling, building, programming, tools
Comments: Visit O'Reilly Media | Spreading the knowledge of technology innovators to get the
Comments: corrections for a large number of errors.
Comments: GNU manual: GNU `make'
Comments: 43 page tutorial:
Comments: Conflicting opinions; 4 stars, 8 reviews, 2007.05.
Comments: see also cons, scons
cheers, drl
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #779
Difficulty: Medium
Spectrum analysis is also referred to as time domain analysis or time density estimation.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. UNIX for Dummies Questions & Answers

Help with MakeFile

I'm really confused how to use a makefile. Are you supposed to be make a file from emacs called MakeFile and put code in there to compile? I am trying to create a makefile to compile two .cpp files in my current directory to produce two .o files and then link them... What I did was make a... (1 Reply)
Discussion started by: jzhang172
1 Replies

3. UNIX for Dummies Questions & Answers

is this a Makefile?

file1.h : file2.h file3.h file1.exe : file4.c file5.c gcc -o file1.exe file4.c file5.c file4.c file5.c : file1.h I was looking up how to make a Makefile and i came across this can someone just explain what it is or does? Thanks. (2 Replies)
Discussion started by: syco__
2 Replies

4. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

5. UNIX for Advanced & Expert Users

Makefile executing another Makefile first?

I have 2 libraries in 2 different directories that I build with Makefiles. library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A? I am now rebuilding A, followed by B... but I'd like B to... (0 Replies)
Discussion started by: wwuster
0 Replies

6. Programming

[Makefile] nothing to be done for 'all'

hello, I have a firts makefile who call others makefile. for this i use: $ make -f linux.mak and output his: $ make -f linux.mak all make -C DerelictAL all PLATFORM=linux make: Entering directory `/home/builder/rpmbuild/SOURCES/derelict2-20100407/DerelictAL' make: Nothing to be done for... (2 Replies)
Discussion started by: bioinfornatics
2 Replies

7. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

8. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

9. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

10. UNIX for Advanced & Expert Users


Can anyone tell me what does ?= do example VARIABLE ?= /somepath This is being used in makefile (1 Reply)
Discussion started by: raagbansal
1 Replies

Featured Tech Videos