help-make
[Top][All Lists]
Advanced

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

Dependencies


From: Uri Shkolnik
Subject: Dependencies
Date: Wed, 3 Jan 2007 06:52:42 -0800 (PST)

Hi,

I'm quite novice to Make :-( ,  and I'm using 
1) GNU Make 3.81 i386-pc-mingw32 
and 
2) GNU Make version 3.79 (RedHat v9)

My problem is that when modifying (or just "touch") a source file (*.c) the 
Make detects it and recompiles that specific file. (without re-compiling the 
rest of the project, and that's just fine)

BUT, when modifying an included header file (*.h) the Make does not detect it 
and that causes a major problem (I need to forcedly rebuild the entire project).

The relevant part of my makefile is attached below. Any assist will be more 
than welcome.


Best Regards,

Uri

=========================================================
###############################################################################

#    Files directives
####################

MODULE_COMMON_SRC_DIR    = $(MODULE_ROOT_DIR)/src

SRC_C    := $(notdir $(wildcard $(MODULE_COMMON_SRC_DIR)/*.c)) \
            $(notdir $(wildcard $(MODULE_LOCAL_SRC_DIR)/*.c)) 
SRC_S    := $(notdir $(wildcard $(MODULE_COMMON_SRC_DIR)/*.s)) \
            $(notdir $(wildcard $(MODULE_LOCAL_SRC_DIR)/*.c)) 
DEP_C    := $(SRC_C:.c=.d)
DEP_S    := $(SRC_S:.s=.d)
OBJ_C    := $(SRC_C:.c=.o)
OBJ_S    := $(SRC_S:.s=.o)
SRC        := $(SRC_S) $(SRC_C)
DEP        := $(DEP_S) $(DEP_C)
OBJ        := $(OBJ_S) $(OBJ_C)
OBJ_INC    := $(patsubst %.o, $(LOCAL_OBJ)/%.o, $(OBJ))
DEP_INC    := $(patsubst %.d, $(LOCAL_DEP)/%.d, $(DEP))

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

#    vpath directive
###################

vpath %c $(MODULE_LOCAL_SRC_DIR)
vpath %s $(MODULE_LOCAL_SRC_DIR)
vpath %c $(MODULE_COMMON_SRC_DIR)
vpath %s $(MODULE_COMMON_SRC_DIR)
vpath %h $(CCINC)
vpath %d $(LOCAL_DEP)
vpath %o $(LOCAL_OBJ)

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

#    Dependencies
################

.PHONY: MakeDep
MakeDep: $(DEP)

%.d: %.s
    @echo [Depend] $(notdir $*.s)
    @$(MKDIR) $(LOCAL_DEP)
    @$(CC) $(CCFLAGS) $(CCINC) $< -Hmake -Hmakeof=$(LOCAL_DEP)/$@
    @$(CP) $(LOCAL_DEP)/$@ $(LOCAL_DEP)/$(subst .d,.dt,$@)
    @$(SED) -e "s/$(notdir $(subst .s,.o,$<))[ :]*/$(notdir $(subst .s,.o,$<)) 
$(notdir $@) : /g" $(LOCAL_DEP)/$(subst .d,.dt,$@) > $(LOCAL_DEP)/$@
    @$(RM) $(LOCAL_DEP)/*.dt
    @$(RM) *.o

%.d: %.c
    @echo [Depend] $(notdir $*.c)
    @$(MKDIR) $(LOCAL_DEP)
    @$(CC) $(CCFLAGS) $(CCINC) $< -Hmake -Hmakeof=$(LOCAL_DEP)/$@
    @$(CP) $(LOCAL_DEP)/$@ $(LOCAL_DEP)/$(subst .d,.dt,$@)
    @$(SED) -e "s/$(notdir $(subst .c,.o,$<))[ :]*/$(notdir $(subst .c,.o,$<)) 
$(notdir $@) : /g" $(LOCAL_DEP)/$(subst .d,.dt,$@) > $(LOCAL_DEP)/$@
    @$(RM) $(LOCAL_DEP)/*.dt


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

#    Compilation
###############

MakeObjects: $(OBJ)

%.o: %.c
    @echo [Compile] $(notdir $*.c)
    @$(MKDIR) $(LOCAL_OBJ)
    @$(CC) -c $< $(CCFLAGS) $(CCINC) -o $(LOCAL_OBJ)/$@
    
%.o: %.s
    @echo [Compile] $(notdir $*.s)
    @$(MKDIR) $(LOCAL_OBJ)
    @$(CC) -c $< $(CCFLAGS) $(CCINC) -o $(LOCAL_OBJ)/$@
            

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




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com




reply via email to

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