6.9. Software Development ToolsThe make development tool in Linux is GNU Make. As of this writing, the latest version of GNU Make is version 3.8, which this section is based on. Porting the build environment from HP-UX to Linux means using the GNU Make as well as making sure project makefiles use syntax that the GNU Make understands. Because both HP-UX[27] and GNU Make conform to the POSIX standard, similarities between HP-UX and GNU makefile syntax abound. However, there are still some differences, which this section covers. The first differences to take note of are the command-line switches. Table 6-13 shows a comparison between HP-UX and GNU Make command-line switches.
6.9.1. Makefile Syntax6.9.1.1. Target for the Form file((entry))Library dependencies of the form libname ((entry)) are not supported by GNU Make. GNU Make supports libname(file.o), where file.o is the file containing the symbol. This feature was not put into GNU Make because of the nonmodularity of putting knowledge into make of the internal format of archive file symbol tables. 6.9.1.2. Use of :=Values assigned to a variable can be overridden by a conditional macro definition. A conditional macro definition takes on the form target := variable = value. When the target line associated with target is being processed, the macro value specified in the conditional macro definition is in effect. If variable was previously defined, the new value of variable overrides the previous definition. The new value of variable takes effect when target or any dependents of target are being processed. HP-UX Make Example: CFLAGS = -O foo_prog := CFLAGS = -g foo_prog : foo1.o foo2.o bar.o CFLAGS = -g will be in effect for foo_prog target and any dependents of the target processed. GNU Make In GNU Make, := is used for variable assignments. To override assigned values in GNU Make for target-specific variables, use the following syntax: target := variable = value target : foo1.o foo2.o bar.o variable = value will be in effect for target and any command scripts that create their prerequisites. 6.9.1.3. Use of $$@HP-UX make uses the $$@ syntax, which is a System V make syntax, as part of the dependency list to refer to the current target. The following subsection shows an example of how $$@ is used in HP-UX makefiles. HP-UX Make $(targets): $$@.o lib.a GNU Make The preceding syntax can be replaced in a GNU makefile by using the following syntax: $(target): %: %.o lib.a 6.9.1.4. Empty RulesIn HP-UX makefiles, you can specify a suffix rule with no commands (to override an implicit rule). This can be confusing and also meaningless to GNU Make because the command line looks empty (it contains a single tab character). To specify an empty suffix rule with GNU Make, put a semicolon after the dependency, as follows: .c.a: ; 6.9.1.5. Suffix SupportHP-UX supports old-fashioned suffix rules, which GNU Make considers obsolete because pattern rules are more general and cleaner (see Table 6-14). GNU Make supports suffix rules for compatibility with older makefile syntax only. Suffix rules come in two kinds: double-suffix and single-suffix. A single-suffix rule looks like this: .c .c~ .cxx .sh The equivalent pattern rule recognized by GNU Make for the .c suffix rule is as follows: % : %.c A double-suffix rule looks like this: .c.o .C.o .y.o The equivalent pattern rule for a .c.o suffix rule is as follows: %.o : %.c Suffix rules that handle System V makefiles to support SCCS files that contain ~ are not recognized by GNU Make. In HP-UX, the suffix rule .c~.o creates the file x.o from the SCCS file s.n.c. GNU Make handles SCCS and RCS files differently by applying two pattern rules for extraction from SCCS or RCS in combination with general rules of rule chaining. For more information, refer to the GNU Make reference.[29]
6.9.2. DebuggersOn all Linux systems, the default application debugger for non-Java programs is the GNU debuggergdb for short. For HP-UX developers, gdb is a familiar tool because HP-UX v11 supports a version of gdb that has been ported to the HP-UX platform. Invoking gdb on Linux yields the following: $ gdb GNU gdb 6.1 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux". Invoking gdb on HP-UX yields the following: $ gdb HP gdb 3.2 for PA-RISC 1.1 or 2.0 (narrow), HP-UX 11.00. Copyright 1986 - 2001 Free Software Foundation, Inc. Hewlett-Packard Wildebeest 3.2 (based on GDB) is covered by the GNU General Public License. Type "show copying" to see the conditions to change it and/or distribute copies. Type "show warranty" for warranty/support. See Chapter 7, "Testing and Debugging," for more information about the GNU debugger. |