4.7. MakeThe make development tool in Linux is GNU Make. As of this writing, the latest version of GNU Make is 3.8, which this section is based on. The GNU Make home page is located at www.gnu.org/software/make/. Note that GNU Make 3.8 is also available on Solaris and can be downloaded from www.istec.org/sunfreeware/. Porting the build environment from Solaris to Linux means using GNU Make and making sure that the makefiles used to build the application are correctly ported to build all necessary application modules. Because both Solaris and GNU Make conform to the POSIX.2 standard, similarities between Solaris and GNU makefile syntax abound. However, there are still some differences, which are covered in this section. The first difference to take note of is the command-line switches. Table 4-9 shows a comparison between Solaris and GNU Make command-line switches.
4.7.1. Built-In Makefile Variables for C++The built-in makefile variable to specify a default C++ compiler in Solaris native Make is CCC, whereas for the GNU Make it is CXX. Similarly, the default compiler flag changes from CCFLAGS to CXXFLAGS. 4.7.2. Library DependenciesOn Solaris, a target name of the form lib(( symbol )) refers to the member of a randomized object library that defines the entry point named symbol. The GNU Make equivalent is lib(file.o). 4.7.3. Empty RulesEmpty rules are suffix rules specified without a command. To specify an empty rule in GNU Make, put a semicolon immediately after the dependency:
4.7.4. Current TargetsIn Solaris makefiles, the symbol $$@ is used in a dependency list to refer to the current target:
In GNU Make, you have to use the following:
4.7.5. SCCS and RCS FilesSuffix rules that handle System V makefiles to support SCCS files that contain ~ are not recognized by GNU Make. In Solaris, 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. 4.7.6. Conditional Macro Assignment$(targets) := special_flags = -g On Solaris, when any target in $(targets) is processed, set $(special_flags) equal to -g. The equivalent on Linux is this: $(targets) : special_flags= -g 4.7.7. Pattern-Replacement Macro ReferencesSolaris allows any number of percent metacharacters to appear after the equal sign. On the other hand, Linux only allows one. Here is an example: ORG=one two NEW=$(ORG:%=integer/%.o integer/%_backup.o) all: @echo ORG is $(ORG) @echo NEW is $(NEW) On Solaris, the output from the make command is as follows: ORG is one two NEW is integer/one.o integer/one_backup.o integer/two.o integer/two_backup.o For Linux, you will get this output instead: ORG is one two NEW is integer/one.o integer/%_backup.o integer/two.o integer/%_backup.o A possible workaround for Linux is this: NEW=$(ORG:%=integer/%.o) $(ORG:%=integer/%_backup.o) 4.7.8. VPATHIf a target or a dependency file is found using VPATH, any occurrences of the word that is the same as the target name in the subsequent rules will be substituted with the actual name of the target derived from VPATH. For example: VPATH=./subdir foo.o : foo.c cc -c foo.c -o foo.o On Solaris, if file.c is located in ./subdir, the following command will be executed: cc -c ./subdir/foo.c -o foo.o However, on Linux, this command will be executed instead: cc -c foo.c -o foo.o 4.7.9. Command ExecutionSolaris Make invokes the shell with the -e argument. This flag instructs the shell to exit immediately if any program it runs returns a nonzero status. This is not true for GNU Make. However, with the -S option in GNU Make, we can achieve the same effect. 4.7.10. Special TargetsSpecial targets are called by different names on various platforms. In Solaris, they are called special-function targets. In GNU Make, they are called special built-in targets. When special targets are incorporated in a makefile, they perform special functions. Consult the GNU Make manual for the meaning of special targets. Table 4-10 compares the special targets on Solaris and GNU.
4.7.11. Environment VariablesHere we list environment variables that affect the execution of GNU Make and Solaris Make. Table 4-11 compares environment variables between Solaris and Linux.
4.7.12. Exit StatusTable 4-12 provides the differences between Make exit status on Solaris and Linux.
|