From owner-freebsd-standards Tue Mar 19 2:51:34 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id E839937B416 for ; Tue, 19 Mar 2002 02:50:00 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2JAo0s39300; Tue, 19 Mar 2002 02:50:00 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (211.c.004.mel.iprimus.net.au [210.50.38.211]) by hub.freebsd.org (Postfix) with ESMTP id E0A0437B404 for ; Tue, 19 Mar 2002 02:42:36 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2JAfO702880; Tue, 19 Mar 2002 21:41:24 +1100 (EST) (envelope-from tim) Message-Id: <200203191041.g2JAfO702880@descent.robbins.dropbear.id.au> Date: Tue, 19 Mar 2002 21:41:24 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36087: P1003.1-2001 c99 utility Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36087 >Category: standards >Synopsis: P1003.1-2001 c99 utility >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Mar 19 02:50:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD is missing the P1003.1-2001 c99 utility. >How-To-Repeat: c99 foo.c >Fix: Here is an implementation of the c99 utility. The manual page is based on Joerg Wunsch's page for c89. It's pretty much trivial, the only interesting thing it does is in addlib(), where it maps -lpthread to the -pthread gcc option, and removes -lxnet and -lrt because they are not available on FreeBSD, their functionality is in libc. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # c99.c # c99.1 # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $FreeBSD$ X# $Id: Makefile,v 1.1 2002/02/20 05:27:51 tim Exp $ X XPROG= c99 X X.include END-of-Makefile echo x - c99.c sed 's/^X//' >c99.c << 'END-of-c99.c' X/*- X * Copyright (c) 2002 Tim J. Robbins. X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X/* X * c99 -- compile standard C programs X * X * This is essentially a wrapper around the system C compiler that forces X * the compiler into C99 mode and modifies the libraries used. X */ X X#include X__FBSDID("$FreeBSD$"); X__RCSID("$Id: c99.c,v 1.3 2002/03/19 03:21:43 tim Exp $"); X X#include X X#include X#include X#include X#include X#include X Xchar **args; Xu_int cargs, nargs; X Xvoid addlib(const char *lib); Xvoid addarg(const char *item); Xvoid usage(void); X Xint Xmain(int argc, char *argv[]) X{ X int ch, i; X X args = NULL; X cargs = nargs = 0; X X /* Validate the options and find where they end */ X while ((ch = getopt(argc, argv, "cD:EgI:L:o:O:sU:l:")) != -1) { X if (ch == 'l') { X /* Gone too far. Back up and get out. */ X if (argv[optind - 1][0] == '-') X optind -= 1; X else X optind -= 2; X break; X } else if (ch == '?') X usage(); X } X if (optind == argc) X usage(); X X addarg("cc"); X addarg("-std=iso9899:199x"); X addarg("-pedantic"); X X /* Add the options */ X for (i = 1; i < optind; i++) X addarg(argv[i]); X /* Add the operands, with special processing for libraries */ X while (i < argc) { X if (strncmp(argv[i], "-l", 2) == 0) { X if (argv[i][2] != '\0') X addlib(argv[i++] + 2); X else { X /* -l foo */ X if (argv[++i] == NULL) X usage(); X addlib(argv[i++]); X } X } else X addarg(argv[i++]); X } X X execv("/usr/bin/cc", args); X err(1, "/usr/bin/cc"); X} X Xvoid Xaddlib(const char *lib) X{ X if (strcmp(lib, "pthread") == 0) X addarg("-pthread"); X else if (strcmp(lib, "rt") == 0) X ; X else if (strcmp(lib, "xnet") == 0) X ; X else { X addarg("-l"); X addarg(lib); X } X} X Xvoid Xaddarg(const char *item) X{ X if (nargs + 1 > cargs) { X cargs += 16; X if ((args = realloc(args, sizeof(*args) * cargs)) == NULL) X err(1, "malloc"); X } X if ((args[nargs++] = strdup(item)) == NULL) X err(1, "strdup"); X args[nargs] = NULL; X} X Xvoid Xusage(void) X{ X fprintf(stderr, X"usage: c99 [-cEgs] [-D name[=value]] [-I directory] ... [-L directory] ...\n"); X fprintf(stderr, X" [-o outfile] [-O optlevel] [-U name]... operand ...\n"); X exit(1); X} END-of-c99.c echo x - c99.1 sed 's/^X//' >c99.1 << 'END-of-c99.1' X.\" X.\" Copyright (c) 1997 Joerg Wunsch X.\" X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR X.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, X.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X.\" X.\" $FreeBSD: src/usr.bin/c89/c89.1,v 1.4.2.4 2001/08/02 01:11:13 obrien Exp $ X.\" $Id: c99.1,v 1.2 2002/03/19 03:05:28 tim Exp $ X.\" " X.Dd February 20, 2002 X.Os X.Dt C99 1 X.Sh NAME X.Nm c99 X.Nd standard C language compiler X.Sh SYNOPSIS X.Nm X.Op Fl cEgs X.Op Fl D Ar name Ns Op = Ns Ar value X.Ar ... X.Op Fl I Ar directory ... X.Op Fl L Ar directory ... X.Op Fl o Ar outfile X.Op Fl O Ar optlevel X.Op Fl U Ar name ... X.Ar operand ... X.Sh DESCRIPTION XThis is the name of the C language compiler as required by the X.St -p1003.1-2001 Xstandard. X.Pp XThe X.Nm Xcompiler accepts the following options: X.Bl -tag -width indent X.It Fl c XSuppress the link-edit phase of the compilation, and do not remove any Xobject files that are produced. X.It Fl D Ar name Ns Op = Ns Ar value XDefine name as if by a C-language X.Ic #define Xdirective. If Xno X.Dq = Ns Ar value Xis given, a value of 1 will be used. XThe X.Fl D Xoption has lower precedence than the X.Fl U Xoption. That is, if X.Ar name Xis used in both a X.Fl U Xand a X.Fl D Xoption, X.Ar name Xwill be undefined regardless of the order of the options. The X.Fl D Xoption may be specified more than once. X.It Fl E XCopy C-language source files to the standard output, expanding all Xpreprocessor directives; no compilation will be performed. X.It Fl g XProduce symbolic information in the object or executable files. X.It Fl I Ar directory XChange the algorithm for searching for headers whose names are not Xabsolute pathnames to look in the directory named by the X.Ar directory Xpathname before looking in the usual places. Thus, headers whose Xnames are enclosed in double-quotes ("") will be searched for first Xin the directory of the file with the X.Ic #include Xline, then in Xdirectories named in X.Fl I Xoptions, and last in the usual places. For Xheaders whose names are enclosed in angle brackets (<>), the header Xwill be searched for only in directories named in X.Fl I Xoptions and then in the usual places. Directories named in X.Fl I Xoptions shall be searched in the order specified. The X.Fl I Xoption may be specified more than once. X.It Fl L Ar directory XChange the algorithm of searching for the libraries named in the X.Fl l Xobjects to look in the directory named by the X.Ar directory Xpathname before looking in the usual places. Directories named in X.Fl L Xoptions will be searched in the order specified. The X.Fl L Xoption may be specified more than once. X.It Fl o Ar outfile XUse the pathname X.Ar outfile , Xinstead of the default X.Pa a.out , Xfor the executable file produced. X.It Fl O Ar optlevel XIf X.Ar optlevel Xis zero, disable all optimizations. Otherwise, enable optimizations at Xthe specified level. X.It Fl s XProduce object and/or executable files from which symbolic and other Xinformation not required for proper execution has been removed X(stripped). X.It Fl U Ar name XRemove any initial definition of X.Ar name . XThe X.Fl U Xoption may be specified more than once. X.El X.Pp XAn operand is either in the form of a pathname or the form X.Fl l Xlibrary. At least one operand of the pathname form needs to be Xspecified. Supported operands are of the form: X.Bl -tag -offset indent -width "-l library" X.It Ar file Ns Pa .c XA C-language source file to be compiled and optionally linked. The Xoperand must be of this form if the X.Fl c Xoption is used. X.It Ar file Ns Pa .a XA library of object files, as produced by X.Xr ar 1 , Xpassed directly to the link editor. X.It Ar file Ns Pa .o XAn object file produced by X.Nm Fl c , Xand passed directly to the link editor. X.It Fl l Ar library XSearch the library named X.Pa lib Ns Ar library Ns Pa .a . XA library will be searched when its name is encountered, so the Xplacement of a X.Fl l Xoperand is significant. X.El X.Sh SEE ALSO X.Xr ar 1 , X.Xr c89 1 , X.Xr cc 1 X.Sh STANDARDS XThe X.Nm Xcommand is believed to comply with X.St -p1003.1-2001 . X.Sh BUGS XThe standard X.Pa trace Xlibrary does not exist in X.Fx Xso X.Fl l Pa trace Xdoes not work. END-of-c99.1 exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message