From owner-freebsd-questions@FreeBSD.ORG Sun Nov 28 18:03:47 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8D2916A4CE for ; Sun, 28 Nov 2004 18:03:47 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id C184643D55 for ; Sun, 28 Nov 2004 18:03:45 +0000 (GMT) (envelope-from gert.cuykens@gmail.com) Received: by rproxy.gmail.com with SMTP id b11so323717rne for ; Sun, 28 Nov 2004 10:03:42 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=FQKyl1bCVubh42+Z2iYBZy1pSmggO6gV9SUFrDHQALmQLiaAQEW/Tb0ui2m16pZc62oCns2qac++tc5TV4uWrL8yBRdpnw7N2e7xe+R+liMvK+wkKRrJBo5PwrOSpkCkF1ijGo9snbS9EYqF9ESKc9UVpiDTwHNUf6sxfzS1XrM= Received: by 10.38.92.16 with SMTP id p16mr1218303rnb; Sun, 28 Nov 2004 10:03:42 -0800 (PST) Received: by 10.38.72.48 with HTTP; Sun, 28 Nov 2004 10:03:42 -0800 (PST) Message-ID: Date: Sun, 28 Nov 2004 19:03:42 +0100 From: Gert Cuykens To: freebsd-questions@freebsd.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20041127133242.52ca4bd1@dolphin.local.net> Subject: Re: Make Depend X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Gert Cuykens List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Nov 2004 18:03:48 -0000 On Sun, 28 Nov 2004 18:57:51 +0100, Gert Cuykens wrote: > On Sat, 27 Nov 2004 15:44:52 -0500 (EST), John Mills > > > wrote: > > Freebies - > > > > > > > > On Sat, 27 Nov 2004, Conrad J. Sabatier wrote: > > > > > On Sat, 27 Nov 2004 09:43:17 +0100, Gert Cuykens > > > wrote: > > > > > > > "A Makefile rule that typically scans all C/C++ source files in a > > > > directory, and generates rules that indicate that an object file > > > > depends on certain header files, and must be recompiled if they are > > > > recompiled." > > > > > > > > i dont understand this. how can a object depend on something that is > > > > not compiled yet? Would the freebsd world not be a happier place if > > > > make did the dependancy thingies what ever they are automatically ? > > ... > > > > > > > Re: dependencies, it should be simple to understand if you give it a > > > moment's thought. Let's say you have a file "main.c" that calls > > > functions in "foo.c". In order for main.c to compile and link properly > > > to create a complete, executable program, it's absolutely essential that > > > foo.c be compiled and linked in as well. > > > > > What Makefile dependencies are about is ensuring that, if a change is > > > made to foo.c, it will be recompiled and relinked with main.c to > > > guarantee that the final executable is up to date in all respects. > > > > Certainly a sensible point, but not the way I understood 'makedepend' to > > work. > > > > As Conrad said, 'make' can be directed to compare the currency of the > > files upon which a particular product file (compiled object, library, > > executable, or other type) depends, so that all product files for which > > the components have changed _are_ rebuilt, but a maximum number of product > > files (i.e., unchanged objects being linked into a library) are > > unnecessarily rebuilt. Many of these rules I put in manually. > > > > 'make' only knows some 'generic' rules (what is done to change a *.c into > > a *.o, for example), plus the explicit dependencies I have written into my > > Makefile. 'makedepend' is a way to automatically generate the > > file-specific rules that can be deduced from a [source] file's own > > contents: usually those secondary files that are brought into it by > > '#include' pragmas. These auxiliary rules are written onto the Makefile > > and become part of it. These files are not necessarily separately > > compiled; I find your definition a bit misleading on this. > > > > 'makedepend' is given a list of files to scan, and places to look for > > included files. My 'depend' rule looks like this: > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > depend: > > makedepend -- $(CFLAGS) -- $(SRCS) -- $(INCLUDES) > > > > # DO NOT DELETE THIS LINE -- make depend depends on it. > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > > That funky last line really tells 'makedepend' where it should write the > > new rules onto my Makefile. Before using a Makefile on a group of sources, > > or when source files are added to the build, I remove all the generate > > rules which have been added below the '# DO NOT DELETE ...' line and > > rebuild the 'depend' target - which is the Makefile itself: > > > > $ make depend > > > > Typical rules automagically added by 'makedepend' are: > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > ... > > BufRing.o: ../Llcommon/SEBase.h StdAfx.h BufRing.h > > Camera.o: ../Llcommon/SEBase.h StdAfx.h ../Llcommon/commonStruct.h > > Camera.o: ../Llcommon/secureeye.h ../Llcommon/memCtrl.h > > Camera.o: ../Llcommon/retCodes.h ../Llcommon/LiveShare.h Camera.h > > Camera.o: ../Llcommon/Common.h Pump.h BufRing.h CamData.h Snap.h INet.h > > Camera.o: Player.h > > INet.o: ../Llcommon/SEBase.h StdAfx.h /usr/include/stdlib.h > > ... > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > > The effect of these added rules is that if I change [say] 'BufRing.h' then > > do 'make all', 'BufRing.c' and 'Camera.c' would be recompiled, but not > > necessarily 'INet.c' > > > > 'make' isn't very bright, but (like 'cpp') it can be _very_ handy. > > > > - John Mills > > john.m.mills@alum.mit.edu > > > > so we have some machine code A from a compiled object file and we have machine code B from a other compiled object file. While A is running it points to B to do some stuff. so if i understand it right without make depend we would had to recompile A and B if A needed some source changes. with make depend we only need to recompile A that also means make depend is only a shortcut, if i dont use make depend and just do make it will just compile everything right ?