From owner-freebsd-questions@FreeBSD.ORG Tue Apr 17 17:05:27 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6758C16A401 for ; Tue, 17 Apr 2007 17:05:27 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from mail-out4.apple.com (mail-out4.apple.com [17.254.13.23]) by mx1.freebsd.org (Postfix) with ESMTP id 5046F13C457 for ; Tue, 17 Apr 2007 17:05:27 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from relay7.apple.com (relay7.apple.com [17.128.113.37]) by mail-out4.apple.com (8.13.8/8.13.8) with ESMTP id l3HH5RAp020765; Tue, 17 Apr 2007 10:05:27 -0700 (PDT) Received: from relay7.apple.com (unknown [127.0.0.1]) by relay7.apple.com (Symantec Mail Security) with ESMTP id E6438304DB; Tue, 17 Apr 2007 10:05:26 -0700 (PDT) X-AuditID: 11807125-a0320bb0000007e5-6e-4624fe565db8 Received: from [17.214.13.96] (cswiger1.apple.com [17.214.13.96]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by relay7.apple.com (Apple SCV relay) with ESMTP id 1B5E4304D4; Tue, 17 Apr 2007 10:05:26 -0700 (PDT) In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <2BDA77FE-95B8-43E9-99AF-934756D3CC02@mac.com> Content-Transfer-Encoding: 7bit From: Chuck Swiger Date: Tue, 17 Apr 2007 10:05:25 -0700 To: Soo-Hyun Choi X-Mailer: Apple Mail (2.752.2) X-Brightmail-Tracker: AAAAAA== Cc: freebsd-questions@freebsd.org Subject: Re: BSD make vs. GNU make X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2007 17:05:27 -0000 On Apr 17, 2007, at 9:28 AM, Soo-Hyun Choi wrote: > This might be a dumb question, but would like get a clear idea about > the differences between BSD make and GNU make. Why do I have to do > 'gmake' in some cases instead of just plain 'make'? Because people write more complex makefiles using syntax which is specific to either BSD or GNU make. > What's the differences? The GNU make info pages include this: "Features of GNU `make' ********************** Here is a summary of the features of GNU `make', for comparison with and credit to other versions of `make'. We consider the features of `make' in 4.2 BSD systems as a baseline. If you are concerned with writing portable makefiles, you should not use the features of `make' listed here, nor the ones in *Note Missing::. Many features come from the version of `make' in System V. * The `VPATH' variable and its special meaning. *Note Searching Directories for Prerequisites: Directory Search. This feature exists in System V `make', but is undocumented. It is documented in 4.3 BSD `make' (which says it mimics System V's `VPATH' feature). * Included makefiles. *Note Including Other Makefiles: Include. Allowing multiple files to be included with a single directive is a GNU extension. * Variables are read from and communicated via the environment. *Note Variables from the Environment: Environment. * Options passed through the variable `MAKEFLAGS' to recursive invocations of `make'. *Note Communicating Options to a Sub-`make': Options/Recursion. * The automatic variable `$%' is set to the member name in an archive reference. *Note Automatic Variables: Automatic. * The automatic variables `$@', `$*', `$<', `$%', and `$?' have corresponding forms like `$(@F)' and `$(@D)'. We have generalized this to `$^' as an obvious extension. *Note Automatic Variables: Automatic. * Substitution variable references. *Note Basics of Variable References: Reference. * The command-line options `-b' and `-m', accepted and ignored. In System V `make', these options actually do something. * Execution of recursive commands to run `make' via the variable `MAKE' even if `-n', `-q' or `-t' is specified. *Note Recursive Use of `make': Recursion. * Support for suffix `.a' in suffix rules. *Note Archive Suffix Rules::. This feature is obsolete in GNU `make', because the general feature of rule chaining (*note Chains of Implicit Rules: Chained Rules.) allows one pattern rule for installing members in an archive (*note Archive Update::) to be sufficient. * The arrangement of lines and backslash-newline combinations in commands is retained when the commands are printed, so they appear as they do in the makefile, except for the stripping of initial whitespace. The following features were inspired by various other versions of `make'. In some cases it is unclear exactly which versions inspired which others. * Pattern rules using `%'. This has been implemented in several versions of `make'. We're not sure who invented it first, but it's been spread around a bit. *Note Defining and Redefining Pattern Rules: Pattern Rules. * Rule chaining and implicit intermediate files. This was implemented by Stu Feldman in his version of `make' for AT&T Eighth Edition Research Unix, and later by Andrew Hume of AT&T Bell Labs in his `mk' program (where he terms it "transitive closure"). We do not really know if we got this from either of them or thought it up ourselves at the same time. *Note Chains of Implicit Rules: Chained Rules. * The automatic variable `$^' containing a list of all prerequisites of the current target. We did not invent this, but we have no idea who did. *Note Automatic Variables: Automatic. The automatic variable `$+' is a simple extension of `$^'. * The "what if" flag (`-W' in GNU `make') was (as far as we know) invented by Andrew Hume in `mk'. *Note Instead of Executing the Commands: Instead of Execution. * The concept of doing several things at once (parallelism) exists in many incarnations of `make' and similar programs, though not in the System V or BSD implementations. *Note Command Execution: Execution. * Modified variable references using pattern substitution come from SunOS 4. *Note Basics of Variable References: Reference. This functionality was provided in GNU `make' by the `patsubst' function before the alternate syntax was implemented for compatibility with SunOS 4. It is not altogether clear who inspired whom, since GNU `make' had `patsubst' before SunOS 4 was released. * The special significance of `+' characters preceding command lines (*note Instead of Executing the Commands: Instead of Execution.) is mandated by `IEEE Standard 1003.2-1992' (POSIX.2). * The `+=' syntax to append to the value of a variable comes from SunOS 4 `make'. *Note Appending More Text to Variables: Appending. * The syntax `ARCHIVE(MEM1 MEM2...)' to list multiple members in a single archive file comes from SunOS 4 `make'. *Note Archive Members::. * The `-include' directive to include makefiles with no error for a nonexistent file comes from SunOS 4 `make'. (But note that SunOS 4 `make' does not allow multiple makefiles to be specified in one `-include' directive.) The same feature appears with the name `sinclude' in SGI `make' and perhaps others. The remaining features are inventions new in GNU `make': * Use the `-v' or `--version' option to print version and copyright information. * Use the `-h' or `--help' option to summarize the options to `make'. * Simply-expanded variables. *Note The Two Flavors of Variables: Flavors. * Pass command-line variable assignments automatically through the variable `MAKE' to recursive `make' invocations. *Note Recursive Use of `make': Recursion. * Use the `-C' or `--directory' command option to change directory. *Note Summary of Options: Options Summary. * Make verbatim variable definitions with `define'. *Note Defining Variables Verbatim: Defining. * Declare phony targets with the special target `.PHONY'. Andrew Hume of AT&T Bell Labs implemented a similar feature with a different syntax in his `mk' program. This seems to be a case of parallel discovery. *Note Phony Targets: Phony Targets. * Manipulate text by calling functions. *Note Functions for Transforming Text: Functions. * Use the `-o' or `--old-file' option to pretend a file's modification-time is old. *Note Avoiding Recompilation of Some Files: Avoiding Compilation. * Conditional execution. This feature has been implemented numerous times in various versions of `make'; it seems a natural extension derived from the features of the C preprocessor and similar macro languages and is not a revolutionary concept. *Note Conditional Parts of Makefiles: Conditionals. * Specify a search path for included makefiles. *Note Including Other Makefiles: Include. * Specify extra makefiles to read with an environment variable. *Note The Variable `MAKEFILES': MAKEFILES Variable. * Strip leading sequences of `./' from file names, so that `./FILE' and `FILE' are considered to be the same file. * Use a special search method for library prerequisites written in the form `-lNAME'. *Note Directory Search for Link Libraries: Libraries/Search. * Allow suffixes for suffix rules (*note Old-Fashioned Suffix Rules: Suffix Rules.) to contain any characters. In other versions of `make', they must begin with `.' and not contain any `/' characters. * Keep track of the current level of `make' recursion using the variable `MAKELEVEL'. *Note Recursive Use of `make': Recursion. * Provide any goals given on the command line in the variable `MAKECMDGOALS'. *Note Arguments to Specify the Goals: Goals. * Specify static pattern rules. *Note Static Pattern Rules: Static Pattern. * Provide selective `vpath' search. *Note Searching Directories for Prerequisites: Directory Search. * Provide computed variable references. *Note Basics of Variable References: Reference. * Update makefiles. *Note How Makefiles Are Remade: Remaking Makefiles. System V `make' has a very, very limited form of this functionality in that it will check out SCCS files for makefiles. * Various new built-in implicit rules. *Note Catalogue of Implicit Rules: Catalogue of Rules. * The built-in variable `MAKE_VERSION' gives the version number of `make'." Aren't you glad you asked? :-) -- -Chuck