kent@SUN.COM (Kent Hauser) (12/29/88)
The attached diff file for cccp.c adds support for the sun make's
automatic dependency checking. This version of `make' is known
as "sunpro make" under SunOS 3.5 & is the default `make' under SunOS 4.0.
Sun's automatic dependency checking works by having the pre-processor
log on a seperate file all include files as it processes the file.
The log file (and the current target name) are gotten from the
environment variable "SUNPRO_DEPENDENCIES", which is set by
"sunpro make".
As I don't have access to the source & none of this is documented,
this patch may not be exactly right. I figured this stuff out
by looking at a "make -dd" logfile & guessing. However, it
seems to work here.
--------------cut here ------------------
*** cccp.c~ Tue Dec 27 18:25:18 1988
--- cccp.c Wed Dec 28 11:10:55 1988
***************
*** 224,228 ****
/* Nonzero means print the names of included files rather than
the preprocessed output. 1 means just the #include "...",
! 2 means #include <...> as well. */
int print_deps = 0;
--- 224,229 ----
/* Nonzero means print the names of included files rather than
the preprocessed output. 1 means just the #include "...",
! 2 means #include <...> as well,
! 3 means print everything on the "sunpro_file" stream .*/
int print_deps = 0;
***************
*** 567,575 ****
so don't look for #include "foo" the source-file directory. */
int ignore_srcdir;
int
! main (argc, argv)
int argc;
char **argv;
{
int st_mode;
--- 568,583 ----
so don't look for #include "foo" the source-file directory. */
int ignore_srcdir;
+
+ #ifdef sun
+ /* For sunpro make -- log the include files as read */
+ FILE *sunpro_file;
+ char *sunpro_filename;
+ #endif
int
! main (argc, argv, envp)
int argc;
char **argv;
+ char **envp;
{
int st_mode;
***************
*** 796,799 ****
--- 804,836 ----
}
+ #ifdef sun
+ {
+ char *s, *getenv ();
+ if (print_deps == 0 &&
+ (sunpro_filename = getenv ("SUNPRO_DEPENDENCIES"))) {
+
+ print_deps = 3; /* print <files> also */
+ deps_allocated_size = 200;
+ deps_buffer = (char *) xmalloc (deps_allocated_size);
+ deps_buffer[0] = 0;
+ deps_size = 0;
+ deps_column = 0;
+
+ if (s = (char *)index (sunpro_filename, ' '))
+ *s++ = '\0';
+ else
+ s = "-";
+ deps_output (s, 0);
+ deps_output (":", 0);
+
+ sunpro_file = fopen (sunpro_filename, "a");
+ if (sunpro_file == 0) {
+ perror_with_name (sunpro_filename);
+ return FATAL_EXIT_CODE;
+ }
+ }
+ }
+ #endif
+
/* Now that dollars_in_ident is known, initialize is_idchar. */
initialize_char_syntax ();
***************
*** 876,880 ****
/* For -M, print the expected object file name
as the target of this Make-rule. */
! if (print_deps) {
if (*in_fname == 0)
deps_output ("-: ", 0);
--- 913,917 ----
/* For -M, print the expected object file name
as the target of this Make-rule. */
! if (print_deps && print_deps != 3) {
if (*in_fname == 0)
deps_output ("-: ", 0);
***************
*** 986,990 ****
if (dump_macros)
dump_all_macros ();
! else if (print_deps)
puts (deps_buffer);
else if (write (fileno (stdout), outbuf.buf, outbuf.bufp - outbuf.buf) < 0)
--- 1023,1027 ----
if (dump_macros)
dump_all_macros ();
! else if (print_deps && print_deps != 3)
puts (deps_buffer);
else if (write (fileno (stdout), outbuf.buf, outbuf.bufp - outbuf.buf) < 0)
***************
*** 991,996 ****
--- 1028,1042 ----
fatal ("I/O error on output");
if (ferror (stdout))
fatal ("I/O error on output");
+
+ #ifdef sun
+ if (sunpro_file != 0) {
+ fputs (deps_buffer, sunpro_file);
+ putc ('\n', sunpro_file);
+ if (ferror (sunpro_file))
+ perror_with_name (sunpro_filename);
+ }
+ #endif
if (errors)
----------
Kent Hauser UUCP: sun!sundc!tfd!kent
Twenty-First Designs INET: kent%tfd.uucp@sundc.east.sun.com