Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

unable to force makefile to rebuild on headers changes

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
3 posts • Page 1 of 1
Author
Message
DaggyStyle
Watchman
Watchman
User avatar
Posts: 5969
Joined: Wed Mar 22, 2006 6:57 am

unable to force makefile to rebuild on headers changes

  • Quote

Post by DaggyStyle » Mon Apr 07, 2014 6:10 am

greetings, I have the following makefile:

Code: Select all

# The directories containing the source files, separated by ':'
VPATH = ../../../src/utils/:../../

SRCS = file1.c file2.c file3.c

OBJS = $(patsubst %.c, objs/%.o, ${SRCS})

ROOT = ../../../

CFLAGS = -g $(EXT_CC_FLAGS) 
INCLUDES = -I$(ROOT)/src/ -I$(ROOT)/src/hdr -I../../ -I.
DEFINES = -D_LARGEFILE64_SOURCE
LDFLAGS = -static -L$(ROOT)/libs/numactl -lnuma

TARGET=abc

all: $(TARGET)

.PHONY: clean help all

$(TARGET): $(OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)

objs/%.o: %.c
	@mkdir -p $(dir $@)
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<

install:
		# install stuff

clean:
	-rm -rf objs/ $(TARGET)

depend: .depend

.depend: $(SRCS)
	rm -f ./.depend
	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MM $^>>./.depend;

include .depend
file1.c includes a header named file1.h, I want to recompile the file1.c if file1.h is changed and I need it in a generic way.

it seems that .depend does holds a dep files list but when I change file1.h I run make, file1.c doesn't recompiles, any hints?

Thanks.
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Top
roseZ
n00b
n00b
User avatar
Posts: 31
Joined: Sat Dec 17, 2005 5:23 pm
Location: Finland

  • Quote

Post by roseZ » Wed Apr 09, 2014 11:09 am

What exactly does the .depend file look like?

It seems to me that $(TARGET) depends on file1.c via obj/file1.o, but obj/file1.o may not depend on file1.h.
At least this is the case if .depend contains, as I'm guessing, a line like

Code: Select all

file1.o: file1.c file1.h
instead of

Code: Select all

obj/file1.o: file1.c file1.h
Top
DaggyStyle
Watchman
Watchman
User avatar
Posts: 5969
Joined: Wed Mar 22, 2006 6:57 am

  • Quote

Post by DaggyStyle » Mon Apr 21, 2014 3:23 pm

thanks for the tip, I'd prefer not to do that but I'll check, thanks.
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Top
Post Reply

3 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic