lkml.org 
[lkml]   [1996]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectstrange Make behavior
While running the Byte benchmarks, I came across some strange Makefile
behavior. I don't know if it is a bug, but it is different from, say SUN
Solaris, and may lead to peculiar behavior.



Consider the two Makefiles (with your favorite simple source file source.c)

In Makefile-good, the variable TMPDIR is defined and everything works.
In Makefile-bad, the variable TMPDIR is undefined. It still creates the
file a.out, does not create the directory ./tmp. No error message. In
Solaris 2.5, it just bombs out (as it should).


#Makefile-good

SHELL = /bin/sh
CC=gcc
# local directories
TMPDIR = ./tmp

SOURCES = source.c
BINS = a.out

all: distr programs


distr:
@echo "Checking distribution of files"
# temporary work directory
@if test ! -d $(TMPDIR) \
; then \
mkdir $(TMPDIR) \
; else \
echo "$(TMPDIR) exists" \
; fi

programs: $(BINS)

a.out:
$(CC) -o a.out source.c


clean:
rm -f $(BINS)


#End of Makefile-good


########################################################################


#Makefile-bad

SHELL = /bin/sh
CC=gcc
# local directories
# TMPDIR = ./tmp


SOURCES = source.c
BINS = a.out

all: distr programs


distr:
@echo "Checking distribution of files"
# temporary work directory
@if test ! -d $(TMPDIR) \
; then \
mkdir $(TMPDIR) \
; else \
echo "$(TMPDIR) exists" \
; fi

programs: $(BINS)

a.out:
$(CC) -o a.out source.c


clean:
rm -f $(BINS)


#End of Makefile-bad



Any comments welcome,

-sen

---------------------------------------------------------------------------
| Sheldon E. Newhouse | mail: newhouse@math.msu.edu |
| Mathematics Department | www: http://www.mth.msu.edu/~sen |
| Michigan State University | telephone: 517-355-9684 |
| E. Lansing, MI 48824-1027 USA | FAX: 517-432-1562 |
---------------------------------------------------------------------------




\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.021 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site