close_output (mkfilename);
mkfile_output (struct commandline *cmd){  char *mkfilename;  const char *clientname, *clntname, *xdrname, *hdrname;  const char *servername, *svcname, *servprogname, *clntprogname;  char *temp;  svcname = file_name (cmd->infile, "_svc.c");  clntname = file_name (cmd->infile, "_clnt.c");  xdrname = file_name (cmd->infile, "_xdr.c");  hdrname = file_name (cmd->infile, ".h");  if (allfiles)    {      servername = extendfile (cmd->infile, "_server.c");      clientname = extendfile (cmd->infile, "_client.c");    }  else    {      servername = " ";      clientname = " ";    }  servprogname = extendfile (cmd->infile, "_server");  clntprogname = extendfile (cmd->infile, "_client");  if (allfiles)    {      mkfilename = alloc (strlen ("Makefile.") +			  strlen (cmd->infile) + 1);      temp = (char *) rindex (cmd->infile, '.');      strcat (mkfilename, "Makefile.");      strncat (mkfilename, cmd->infile,	       (temp - cmd->infile));    }  else    mkfilename = (char *) cmd->outfile;  checkfiles (NULL, mkfilename);  open_output (NULL, mkfilename);  fprintf (fout, "\n# This is a template Makefile generated by rpcgen\n");  f_print (fout, "\n# Parameters\n\n");  f_print (fout, "CLIENT = %s\nSERVER = %s\n\n", clntprogname, servprogname);  f_print (fout, "SOURCES_CLNT.c = \nSOURCES_CLNT.h = \n");  f_print (fout, "SOURCES_SVC.c = \nSOURCES_SVC.h = \n");  f_print (fout, "SOURCES.x = %s\n\n", cmd->infile);  f_print (fout, "TARGETS_SVC.c = %s %s %s \n",	   svcname, servername, xdrname);  f_print (fout, "TARGETS_CLNT.c = %s %s %s \n",	   clntname, clientname, xdrname);  f_print (fout, "TARGETS = %s %s %s %s %s %s\n\n",	   hdrname, xdrname, clntname,	   svcname, clientname, servername);  f_print (fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) \$(TARGETS_CLNT.c:%%.c=%%.o)");  f_print (fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) \$(TARGETS_SVC.c:%%.c=%%.o)");  f_print (fout, "\n# Compiler flags \n");  if (mtflag)    fprintf (fout, "\nCPPFLAGS += -D_REENTRANT\nCFLAGS += -g \nLDLIBS \+= -lnsl -lpthread \n ");  else    f_print (fout, "\nCFLAGS += -g \nLDLIBS += -lnsl\n");  f_print (fout, "RPCGENFLAGS = \n");  f_print (fout, "\n# Targets \n\n");  f_print (fout, "all : $(CLIENT) $(SERVER)\n\n");  f_print (fout, "$(TARGETS) : $(SOURCES.x) \n");  f_print (fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n");  f_print (fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \$(TARGETS_CLNT.c) \n\n");  f_print (fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \$(TARGETS_SVC.c) \n\n");  f_print (fout, "$(CLIENT) : $(OBJECTS_CLNT) \n");  f_print (fout, "\t$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) \$(LDLIBS) \n\n");  f_print (fout, "$(SERVER) : $(OBJECTS_SVC) \n");  f_print (fout, "\t$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n ");  f_print (fout, "clean:\n\t $(RM) core $(TARGETS) $(OBJECTS_CLNT) \$(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");}