help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

autodependency generation - inifinite loop problem


From: Srivathsan S
Subject: autodependency generation - inifinite loop problem
Date: Thu, 17 Feb 2005 17:30:47 +0530

Hi,

    I need some help in figuring out why my Makefile goes into an infinite loop while generating dependencies. I am using SCO-unix and I have run my Makefile on 3 different SCO machines. It runs fine on 2 of them (i.e., the .d files are generated, they are properly included, object files are created and executables are generated. Also, when a .h file is changed, it finds out the proper dependencies and  rebuilds them), but, on the 3rd, generating prerequisites goes into an infinite loop. I am unable to pin-point the issue. But, I know that the sed command pattern (to generate .d files) may be an issue (if I comment that line, it does not go into infinite loop). I am not sure if it is a SCO installation (on that machine) issue or my Makefile issue. I do not know where to begin looking. Can anyone help me out?

 

Below is the Makefile I have written:

 

 

SHELL           = /bin/sh

BIN             = /usr/gnu/bin

RM              = /bin/rm -f

MYSQLBIN        = /usr/local/mysql/bin

MYSQLLIB        = /usr/local/mysql/lib

LXmX11PATH      = /usr/X11R6.1/lib

LXtPATH         = /usr/lib

MYSQLINC        = /usr/local/mysql/include

OBJDIR          = obj

EXECNAME        = seiko

MINIMAKEDIR     = mini_makes

 

# compiler

CC              = $(BIN)/gcc

 

# prefix -l for library name and -L for library path.

LDFLAGS         = -lmysqlclient -lXm -lXt -lX11 -lsocket -lc -lm -ldmalloc

LOADLIBS        = -L$(MYSQLLIB)

 

# Compiler flags. All warnings disabled (-Wall).

CFLAGS          = -g

COMPILE         = $(CC) $(CFLAGS)

INCLUDES        = -I/usr/local/include

SOURCE          = l_main.c seikocfg.c lgraphics.c lgcomm_func.c lgcolor_func.c lcreat_config.c \

                  lgcomm_menu.c lgconn_diag.c lgtask_bar.c lgdsw.c lgdsw_config.c lgdsw_conn.c \

                  lgdswdir.c lgvsw.c lgvsw_config.c lgvsw_conn.c lgvswdir.c lghkdhk.c lghkdhk_stat.c \

                  lsdh_comm.c leucomm_proc.c laux_comm.c lbeu_comm.c lpr_process.c lgsatrft.c seiko_gist.c \

                  seiko_debug.c lguseradmin_main.c

 

# This will replace every occurance of .c file to .o file

# equivalent to OBJS = abc.o def.o

OBJS            = $(SOURCE:.c=.o)

 

# This will replace every occurance of .c file to .d file

DEPS            = $(SOURCE:.c=.d)

 

.SUFFIXES:     # clear all existing suffixes

.SUFFIXES: .o .c

 

.c.o:

        $(COMPILE) -c $< -o $@

 

 

# Pattern rule to generate a file of pre-requisites (i.e., a mini-makefile)

# called <source-file.d> from a C source-file call source-file.c

# I got the below pattern-rule from the GNU Make  online manual.

# http://www.gnu.org/software/make/manual/html_mono/make.html#SEC51

 

%.d: %.c

        @echo "Generating prerequisites for $< . Please wait."

        @set -e; rm -f $@; \

        $(CC) -MM $(CFLAGS) $< > address@hidden; \

        sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < address@hidden > $@; \

        rm -f address@hidden

 

# target: source-file(s)

#       command(must be preceded by a tab)

 

$(EXECNAME): $(OBJS)

        @echo "\nMaking the executable $(EXECNAME)\n"

        $(COMPILE) $^ $(INCLUDES) $(LOADLIBS) $(LDFLAGS) -o $@

        @echo "\n"

        @date

        @echo "\n"

 

# I don't want Make to get confused if a file named "all"

# should happen to exist. So, I make "all" a phony target,

# i.e., a target that Make should always try to update. I do

# that making "all" the dependency for the phony target.

 

.PHONY : all

all: $(EXECNAME)

 

# To avoid Make creating .d files and deleting all of them

# when 'make clean' is called.

# I am now including all the mini-makefiles I had generated

# before and integrating into the master Makefile.

 

ifneq ($(MAKECMDGOALS), clean)

-include $(DEPS)

endif

 

# This is to make sure that 'clean' is a phony target and will run

# the commands irrespective of whether there is a file named 'clean'.

.PHONY: clean

 

clean:

        @$(RM) *.o

        @$(RM) *.d

        @$(RM) $(EXECNAME)

        @$(RM) core

        @$(RM) *~

        @echo "\n\tYour LNMS is nice and clean now!\n"

==============================================================================

 

 

 

 

Thanks much,

Sri

26587072  x340

Deccanet Designs - A Flextronics Company

Bangalore

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]