# # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2004 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" debug : TARGET += debug # Hammerhead: amd64-only SUBDIRS = $(MACH64) debug: $(SUBDIRS) include ../../Makefile.subdirs # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # .KEEP_STATE: PROG = esc include $(SRC)/cmd/fm/eversholt/Makefile.esc.com EFTCLASS = writer LOCALOBJS = escmain.o OBJS = $(LOCALOBJS) $(COMMONOBJS) SRCS = $(LOCALOBJS:.o=.c) $(COMMONSRCS) CPPFLAGS += -I../common CFLAGS += -DESC $(CTF_FLAGS) CFLAGS64 += -DESC $(CTF_FLAGS_64) LDLIBS += -lumem all debug: $(PROG) install: all $(ROOTPROG) $(PROG): $(OBJS) $(LINK.c) -o $@ $(OBJS) $(LDLIBS) $(CTFMRG) $(POST_PROCESS) clean: $(RM) $(OBJS) y.output y.tab.c y.tab.h clobber: clean $(RM) $(PROG) esclex.o: escparse.o %.o: ../common/%.c $(COMPILE.c) $< $(CTFCONVO) # # This file and its contents are supplied under the terms of the # Common Development and Distribution License ("CDDL"), version 1.0. # You may only use this file in accordance with the terms of version # 1.0 of the CDDL. # # A full copy of the text of the CDDL should have accompanied this # source. A copy of the CDDL is also available via the Internet at # http://www.illumos.org/license/CDDL. # # Copyright 2025 Hammerhead Project # # Hammerhead: Include Makefile.cmd first to load Makefile.master # (defines COMPILE.c, COMPILE64.c needed by Makefile.esc.com's pattern rules) include $(SRC)/cmd/Makefile.cmd include ../Makefile.com include $(SRC)/cmd/Makefile.cmd.64 install: all $(ROOTPROG64) /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * escmain.c -- main routine for esc, the eversholt compiler * * argument processing and the general flow through all the other * modules is driven by this file. */ #include #include #ifdef sun #include #else #include #endif /* sun */ #include "out.h" #include "stats.h" #include "alloc.h" #include "stable.h" #include "literals.h" #include "lut.h" #include "esclex.h" #include "eftwrite.h" #include "ptree.h" #include "tree.h" #include "check.h" #include "version.h" /* stuff exported by yacc-generated parsers */ extern void yyparse(void); extern int yydebug; /* * This external definition has to be here. If we put it in literals.h * lint complains about the declaration not being used within the block * when compiling literals.c. */ extern void literals_init(void); static const char *Usage = "[-SYdghpqvy] [-Dname[=def]] [-I dir] [-Uname] [-o outfile] esc-files..."; static const char *Help = "\tinput files are run through cpp and concatenated.\n" "\t-D name[=def] Pass to cpp\n" "\t-I dir Pass to cpp\n" "\t-S Print stats for compiler memory usage, etc.\n" "\t-U name Pass to cpp\n" "\t-Y Enable parser debug output\n" "\t-d Enable general debug output\n" "\t-g Print generated iterators (use with -p)\n" "\t-h Print this help message\n" "\t-o outfile Emit compiled EFT to \"outfile\"\n" "\t-p Print complete parse tree\n" "\t-q Quiet mode: suppress warnings\n" "\t-v Enable verbose output\n" "\t-y Enable lexer debug output"; int Debug; int Verbose; int Warn = 1; /* the esc compiler should issue language warnings */ extern int Pchildgen; /* flag to ptree for printing generated iterators */ #define MAXARGS 8192 char Args[MAXARGS]; #define MAXCPPARGS 4000 static char Cppargs[MAXCPPARGS]; int main(int argc, char *argv[]) { char flagbuf[] = " -D"; char **av; int c; int stats = 0; int lexecho = 0; const char *outfile = NULL; int count; int i; int pflag = 0; alloc_init(); out_init(argv[0]); stats_init(1); /* extended stats always enabled for esc */ stable_init(0); literals_init(); lut_init(); tree_init(); eftwrite_init(); /* built a best effort summary of args for eftwrite() */ count = 0; for (i = 1; i < argc; i++) { char *ptr = argv[i]; if (count < MAXARGS - 1) Args[count++] = ' '; while (count < MAXARGS - 1 && *ptr) Args[count++] = *ptr++; } Args[count] = '\0'; while ((c = getopt(argc, argv, "D:I:SU:Ydgho:pqvy")) != EOF) { switch (c) { case 'D': case 'I': case 'U': if (strlen(optarg) + strlen(Cppargs) + 4 >= MAXCPPARGS) out(O_DIE, "cpp args too long (max %d bytes)", MAXCPPARGS); flagbuf[2] = c; (void) strcat(Cppargs, flagbuf); (void) strcat(Cppargs, optarg); break; case 'S': stats++; break; case 'Y': yydebug++; break; case 'd': Debug++; break; case 'g': Pchildgen++; break; case 'h': case '?': out(O_PROG, "eversholt compiler version %d.%d", VERSION_MAJOR, VERSION_MINOR); out(O_DIE|O_USAGE, "%s\n%s", Usage, Help); /*NOTREACHED*/ break; case 'o': outfile = optarg; break; case 'p': pflag++; break; case 'q': Warn = 0; break; case 'v': Verbose++; break; case 'y': lexecho++; break; default: out(O_DIE|O_USAGE, Usage); /*NOTREACHED*/ } } out(O_PROG|O_VERB, "eversholt compiler version %d.%d", VERSION_MAJOR, VERSION_MINOR); argc -= optind; av = &argv[optind]; if (argc < 1) { out(O_ERR, "no esc source files given"); out(O_DIE|O_USAGE, Usage); /*NOTREACHED*/ } lex_init(av, Cppargs, lexecho); check_init(); yyparse(); (void) lex_fini(); tree_report(); if (count = out_errcount()) out(O_DIE, "%d language error%s encountered, exiting.", OUTS(count)); if (outfile) eftwrite(outfile); if (pflag) ptree_name_iter(O_OK, tree_root(NULL)); if (stats) { out(O_OK, "Stats:"); stats_publish(); } out_exit(0); /*NOTREACHED*/ return (0); }