/* $TOG: imake.c /main/104 1998/03/24 12:45:15 kaleb $ */ /*************************************************************************** * * * Porting Note * * * * Add the value of BOOTSTRAPCFLAGS to the cpp_argv table so that it will * * be passed to the template file. * * * ***************************************************************************/ /* @OPENGROUP_COPYRIGHT@ COPYRIGHT NOTICE Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc. Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for the full copyright text. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. This software is subject to an open license. It may only be used on, with or for operating systems which are themselves open source systems. You must contact The Open Group for a license allowing distribution and sublicensing of this software on, with, or for operating systems which are not Open Source programs. See http://www.opengroup.org/openmotif/license for full details of the license agreement. Any use, reproduction, or distribution of the program constitutes recipient's acceptance of this agreement. EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * * * Original Author: * Todd Brunhoff * Tektronix, inc. * While a guest engineer at Project Athena, MIT * * imake: the include-make program. * * Usage: imake [-Idir] [-Ddefine] [-T template] [-f imakefile ] [-C Imakefile.c ] [-s] [-e] [-v] [make flags] * * Imake takes a template file (Imake.tmpl) and a prototype (Imakefile) * and runs cpp on them producing a Makefile. It then optionally runs make * on the Makefile. * Options: * -D define. Same as cpp -D argument. * -I Include directory. Same as cpp -I argument. * -T template. Designate a template other * than Imake.tmpl * -f specify the Imakefile file * -C specify the name to use instead of Imakefile.c * -s[F] show. Show the produced makefile on the standard * output. Make is not run is this case. If a file * argument is provided, the output is placed there. * -e[F] execute instead of show; optionally name Makefile F * -v verbose. Show the make command line executed. * * Environment variables: * * IMAKEINCLUDE Include directory to use in addition to "." * IMAKECPP Cpp to use instead of /lib/cpp * IMAKEMAKE make program to use other than what is * found by searching the $PATH variable. * Other features: * imake reads the entire cpp output into memory and then scans it * for occurences of "@@". If it encounters them, it replaces it with * a newline. It also trims any trailing white space on output lines * (because make gets upset at them). This helps when cpp expands * multi-line macros but you want them to appear on multiple lines. * It also changes occurences of "XCOMM" to "#", to avoid problems * with treating commands as invalid preprocessor commands. * * The macros MAKEFILE and MAKE are provided as macros * to make. MAKEFILE is set to imake's makefile (not the constructed, * preprocessed one) and MAKE is set to argv[0], i.e. the name of * the imake program. * * Theory of operation: * 1. Determine the name of the imakefile from the command line (-f) * or from the content of the current directory (Imakefile or imakefile). * Call this . This gets added to the arguments for * make as MAKEFILE=. * 2. Determine the name of the template from the command line (-T) * or the default, Imake.tmpl. Call this