2 * Generate include file dependencies
4 * Copyright 1996, 2013 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NO_LIBWINE_PORT
23 #include "wine/port.h"
36 #include "wine/list.h"
43 char *sourcename
; /* source file name for generated headers */
44 struct incl_file
*included_by
; /* file that included this one */
45 int included_line
; /* line where this file was included */
46 unsigned int flags
; /* flags (see below) */
47 struct incl_file
*owner
;
48 unsigned int files_count
; /* files in use */
49 unsigned int files_size
; /* total allocated size */
50 struct incl_file
**files
;
53 #define FLAG_SYSTEM 0x0001 /* is it a system include (#include <name>) */
54 #define FLAG_GENERATED 0x0002 /* generated file */
55 #define FLAG_IDL_PROXY 0x0004 /* generates a proxy (_p.c) file */
56 #define FLAG_IDL_CLIENT 0x0008 /* generates a client (_c.c) file */
57 #define FLAG_IDL_SERVER 0x0010 /* generates a server (_s.c) file */
58 #define FLAG_IDL_IDENT 0x0020 /* generates an ident (_i.c) file */
59 #define FLAG_IDL_REGISTER 0x0040 /* generates a registration (_r.res) file */
60 #define FLAG_IDL_TYPELIB 0x0080 /* generates a typelib (.tlb) file */
61 #define FLAG_IDL_REGTYPELIB 0x0100 /* generates a registered typelib (_t.res) file */
62 #define FLAG_IDL_HEADER 0x0200 /* generates a header (.h) file */
63 #define FLAG_RC_PO 0x0400 /* rc file contains translations */
64 #define FLAG_C_IMPLIB 0x0800 /* file is part of an import library */
72 { FLAG_IDL_TYPELIB
, ".tlb" },
73 { FLAG_IDL_REGTYPELIB
, "_t.res" },
74 { FLAG_IDL_CLIENT
, "_c.c" },
75 { FLAG_IDL_IDENT
, "_i.c" },
76 { FLAG_IDL_PROXY
, "_p.c" },
77 { FLAG_IDL_SERVER
, "_s.c" },
78 { FLAG_IDL_REGISTER
, "_r.res" },
79 { FLAG_IDL_HEADER
, ".h" }
82 static struct list sources
= LIST_INIT(sources
);
83 static struct list includes
= LIST_INIT(includes
);
87 unsigned int count
; /* strings in use */
88 unsigned int size
; /* total allocated size */
92 static const struct strarray empty_strarray
;
94 static struct strarray include_args
;
95 static struct strarray define_args
;
96 static struct strarray appmode
;
97 static struct strarray dllflags
;
98 static struct strarray imports
;
99 static struct strarray make_vars
;
100 static struct strarray cmdline_vars
;
102 static const char *base_dir
= ".";
103 static const char *src_dir
;
104 static const char *top_src_dir
;
105 static const char *top_obj_dir
;
106 static const char *parent_dir
;
107 static const char *tools_dir
;
108 static const char *tools_ext
;
109 static const char *makefile_name
= "Makefile";
110 static const char *Separator
= "### Dependencies";
111 static const char *input_file_name
;
112 static const char *output_file_name
;
113 static const char *temp_file_name
;
114 static int parse_makefile_mode
;
115 static int relative_dir_mode
;
116 static int input_line
;
117 static int output_column
;
118 static FILE *output_file
;
120 static const char Usage
[] =
121 "Usage: makedep [options] [files]\n"
123 " -Idir Search for include files in directory 'dir'\n"
124 " -Cdir Search for source files in directory 'dir'\n"
125 " -Sdir Set the top source directory\n"
126 " -Tdir Set the top object directory\n"
127 " -Pdir Set the parent source directory\n"
128 " -M dirs Parse the makefiles from the specified directories\n"
129 " -R from to Compute the relative path between two directories\n"
130 " -fxxx Store output in file 'xxx' (default: Makefile)\n"
131 " -sxxx Use 'xxx' as separator (default: \"### Dependencies\")\n";
135 #define __attribute__(x)
138 static void fatal_error( const char *msg
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
139 static void fatal_perror( const char *msg
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
140 static void output( const char *format
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
141 static char *strmake( const char* fmt
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
143 /*******************************************************************
146 static void fatal_error( const char *msg
, ... )
149 va_start( valist
, msg
);
152 fprintf( stderr
, "%s:", input_file_name
);
153 if (input_line
) fprintf( stderr
, "%d:", input_line
);
154 fprintf( stderr
, " error: " );
156 else fprintf( stderr
, "makedep: error: " );
157 vfprintf( stderr
, msg
, valist
);
163 /*******************************************************************
166 static void fatal_perror( const char *msg
, ... )
169 va_start( valist
, msg
);
172 fprintf( stderr
, "%s:", input_file_name
);
173 if (input_line
) fprintf( stderr
, "%d:", input_line
);
174 fprintf( stderr
, " error: " );
176 else fprintf( stderr
, "makedep: error: " );
177 vfprintf( stderr
, msg
, valist
);
184 /*******************************************************************
187 static void cleanup_files(void)
189 if (temp_file_name
) unlink( temp_file_name
);
190 if (output_file_name
) unlink( output_file_name
);
194 /*******************************************************************
197 static void exit_on_signal( int sig
)
199 exit( 1 ); /* this will call the atexit functions */
203 /*******************************************************************
206 static void *xmalloc( size_t size
)
209 if (!(res
= malloc (size
? size
: 1)))
210 fatal_error( "Virtual memory exhausted.\n" );
215 /*******************************************************************
218 static void *xrealloc (void *ptr
, size_t size
)
222 if (!(res
= realloc( ptr
, size
)))
223 fatal_error( "Virtual memory exhausted.\n" );
227 /*******************************************************************
230 static char *xstrdup( const char *str
)
232 char *res
= strdup( str
);
233 if (!res
) fatal_error( "Virtual memory exhausted.\n" );
238 /*******************************************************************
241 static char *strmake( const char* fmt
, ... )
249 char *p
= xmalloc (size
);
251 n
= vsnprintf (p
, size
, fmt
, ap
);
253 if (n
== -1) size
*= 2;
254 else if ((size_t)n
>= size
) size
= n
+ 1;
261 /*******************************************************************
264 static int strendswith( const char* str
, const char* end
)
269 return l
>= m
&& strcmp(str
+ l
- m
, end
) == 0;
273 /*******************************************************************
276 static void output( const char *format
, ... )
281 va_start( valist
, format
);
282 ret
= vfprintf( output_file
, format
, valist
);
284 if (ret
< 0) fatal_perror( "output" );
285 if (format
[0] && format
[strlen(format
) - 1] == '\n') output_column
= 0;
286 else output_column
+= ret
;
290 /*******************************************************************
293 static void strarray_add( struct strarray
*array
, const char *str
)
295 if (array
->count
== array
->size
)
297 if (array
->size
) array
->size
*= 2;
298 else array
->size
= 16;
299 array
->str
= xrealloc( array
->str
, sizeof(array
->str
[0]) * array
->size
);
301 array
->str
[array
->count
++] = str
;
305 /*******************************************************************
308 static void strarray_addall( struct strarray
*array
, struct strarray added
)
312 for (i
= 0; i
< added
.count
; i
++) strarray_add( array
, added
.str
[i
] );
316 /*******************************************************************
319 static void strarray_insert( struct strarray
*array
, unsigned int pos
, const char *str
)
323 strarray_add( array
, NULL
);
324 for (i
= array
->count
- 1; i
> pos
; i
--) array
->str
[i
] = array
->str
[i
- 1];
325 array
->str
[pos
] = str
;
329 /*******************************************************************
332 static void strarray_add_uniq( struct strarray
*array
, const char *str
)
336 for (i
= 0; i
< array
->count
; i
++) if (!strcmp( array
->str
[i
], str
)) return;
337 strarray_add( array
, str
);
341 /*******************************************************************
344 static void output_filename( const char *name
)
346 if (output_column
+ strlen(name
) + 1 > 100)
351 else if (output_column
) output( " " );
352 output( "%s", name
);
356 /*******************************************************************
359 static void output_filenames( struct strarray array
)
363 for (i
= 0; i
< array
.count
; i
++) output_filename( array
.str
[i
] );
367 /*******************************************************************
370 static char *get_extension( char *filename
)
372 char *ext
= strrchr( filename
, '.' );
373 if (ext
&& strchr( ext
, '/' )) ext
= NULL
;
378 /*******************************************************************
381 static char *replace_extension( const char *name
, const char *old_ext
, const char *new_ext
)
384 int name_len
= strlen( name
);
385 int ext_len
= strlen( old_ext
);
387 if (name_len
>= ext_len
&& !strcmp( name
+ name_len
- ext_len
, old_ext
)) name_len
-= ext_len
;
388 ret
= xmalloc( name_len
+ strlen( new_ext
) + 1 );
389 memcpy( ret
, name
, name_len
);
390 strcpy( ret
+ name_len
, new_ext
);
395 /*******************************************************************
396 * strarray_replace_extension
398 static struct strarray
strarray_replace_extension( const struct strarray
*array
,
399 const char *old_ext
, const char *new_ext
)
404 ret
.count
= ret
.size
= array
->count
;
405 ret
.str
= xmalloc( sizeof(ret
.str
[0]) * ret
.size
);
406 for (i
= 0; i
< array
->count
; i
++) ret
.str
[i
] = replace_extension( array
->str
[i
], old_ext
, new_ext
);
411 /*******************************************************************
414 static char *replace_substr( const char *str
, const char *start
, unsigned int len
, const char *replace
)
416 unsigned int pos
= start
- str
;
417 char *ret
= xmalloc( pos
+ strlen(replace
) + strlen(start
+ len
) + 1 );
418 memcpy( ret
, str
, pos
);
419 strcpy( ret
+ pos
, replace
);
420 strcat( ret
+ pos
, start
+ len
);
425 /*******************************************************************
428 * Determine where the destination path is located relative to the 'from' path.
430 static char *get_relative_path( const char *from
, const char *dest
)
434 unsigned int dotdots
= 0;
436 /* a path of "." is equivalent to an empty path */
437 if (!strcmp( from
, "." )) from
= "";
441 while (*from
== '/') from
++;
442 while (*dest
== '/') dest
++;
443 start
= dest
; /* save start of next path element */
446 while (*from
&& *from
!= '/' && *from
== *dest
) { from
++; dest
++; }
447 if ((!*from
|| *from
== '/') && (!*dest
|| *dest
== '/')) continue;
449 /* count remaining elements in 'from' */
453 while (*from
&& *from
!= '/') from
++;
454 while (*from
== '/') from
++;
460 if (!start
[0] && !dotdots
) return NULL
; /* empty path */
462 ret
= xmalloc( 3 * dotdots
+ strlen( start
) + 1 );
463 for (p
= ret
; dotdots
; dotdots
--, p
+= 3) memcpy( p
, "../", 3 );
465 if (start
[0]) strcpy( p
, start
);
466 else p
[-1] = 0; /* remove trailing slash */
471 /*******************************************************************
474 static char *src_dir_path( const char *path
)
476 if (src_dir
) return strmake( "%s/%s", src_dir
, path
);
477 return xstrdup( path
);
481 /*******************************************************************
484 static char *top_obj_dir_path( const char *path
)
486 if (top_obj_dir
) return strmake( "%s/%s", top_obj_dir
, path
);
487 return xstrdup( path
);
491 /*******************************************************************
494 static char *top_dir_path( const char *path
)
496 if (top_src_dir
) return strmake( "%s/%s", top_src_dir
, path
);
497 return top_obj_dir_path( path
);
501 /*******************************************************************
504 static char *tools_dir_path( const char *path
)
506 if (tools_dir
) return strmake( "%s/tools/%s", tools_dir
, path
);
507 if (top_obj_dir
) return strmake( "%s/tools/%s", top_obj_dir
, path
);
508 return strmake( "tools/%s", path
);
512 /*******************************************************************
515 static char *tools_path( const char *name
)
517 if (tools_dir
) return strmake( "%s/tools/%s/%s%s", tools_dir
, name
, name
, tools_ext
);
518 if (top_obj_dir
) return strmake( "%s/tools/%s/%s%s", top_obj_dir
, name
, name
, tools_ext
);
519 return strmake( "tools/%s/%s%s", name
, name
, tools_ext
);
523 /*******************************************************************
526 static void init_paths(void)
528 /* ignore redundant source paths */
529 if (src_dir
&& !strcmp( src_dir
, "." )) src_dir
= NULL
;
530 if (top_src_dir
&& top_obj_dir
&& !strcmp( top_src_dir
, top_obj_dir
)) top_src_dir
= NULL
;
531 if (tools_dir
&& top_obj_dir
&& !strcmp( tools_dir
, top_obj_dir
)) tools_dir
= NULL
;
533 strarray_insert( &include_args
, 0, strmake( "-I%s", top_dir_path( "include" )));
537 /*******************************************************************
540 static char *get_line( FILE *file
)
543 static unsigned int size
;
548 buffer
= xmalloc( size
);
550 if (!fgets( buffer
, size
, file
)) return NULL
;
555 char *p
= buffer
+ strlen(buffer
);
556 /* if line is larger than buffer, resize buffer */
557 while (p
== buffer
+ size
- 1 && p
[-1] != '\n')
559 buffer
= xrealloc( buffer
, size
* 2 );
560 if (!fgets( buffer
+ size
- 1, size
+ 1, file
)) break;
561 p
= buffer
+ strlen(buffer
);
564 if (p
> buffer
&& p
[-1] == '\n')
567 if (p
> buffer
&& p
[-1] == '\r') *(--p
) = 0;
568 if (p
> buffer
&& p
[-1] == '\\')
571 /* line ends in backslash, read continuation line */
572 if (!fgets( p
, size
- (p
- buffer
), file
)) return buffer
;
581 /*******************************************************************
584 static struct incl_file
*find_src_file( const char *name
)
586 struct incl_file
*file
;
588 LIST_FOR_EACH_ENTRY( file
, &sources
, struct incl_file
, entry
)
589 if (!strcmp( name
, file
->name
)) return file
;
593 /*******************************************************************
596 static struct incl_file
*find_include_file( const char *name
)
598 struct incl_file
*file
;
600 LIST_FOR_EACH_ENTRY( file
, &includes
, struct incl_file
, entry
)
601 if (!strcmp( name
, file
->name
)) return file
;
605 /*******************************************************************
608 * Add an include file if it doesn't already exists.
610 static struct incl_file
*add_include( struct incl_file
*parent
, const char *name
, int system
)
612 struct incl_file
*include
;
615 if (parent
->files_count
>= parent
->files_size
)
617 parent
->files_size
*= 2;
618 if (parent
->files_size
< 16) parent
->files_size
= 16;
619 parent
->files
= xrealloc( parent
->files
, parent
->files_size
* sizeof(*parent
->files
) );
622 /* enforce some rules for the Wine tree */
624 if (!memcmp( name
, "../", 3 ))
625 fatal_error( "#include directive with relative path not allowed\n" );
627 if (!strcmp( name
, "config.h" ))
629 if ((ext
= strrchr( parent
->filename
, '.' )) && !strcmp( ext
, ".h" ))
630 fatal_error( "config.h must not be included by a header file\n" );
631 if (parent
->files_count
)
632 fatal_error( "config.h must be included before anything else\n" );
634 else if (!strcmp( name
, "wine/port.h" ))
636 if ((ext
= strrchr( parent
->filename
, '.' )) && !strcmp( ext
, ".h" ))
637 fatal_error( "wine/port.h must not be included by a header file\n" );
638 if (!parent
->files_count
) fatal_error( "config.h must be included before wine/port.h\n" );
639 if (parent
->files_count
> 1)
640 fatal_error( "wine/port.h must be included before everything except config.h\n" );
641 if (strcmp( parent
->files
[0]->name
, "config.h" ))
642 fatal_error( "config.h must be included before wine/port.h\n" );
645 LIST_FOR_EACH_ENTRY( include
, &includes
, struct incl_file
, entry
)
646 if (!strcmp( name
, include
->name
)) goto found
;
648 include
= xmalloc( sizeof(*include
) );
649 memset( include
, 0, sizeof(*include
) );
650 include
->name
= xstrdup(name
);
651 include
->included_by
= parent
;
652 include
->included_line
= input_line
;
653 if (system
) include
->flags
|= FLAG_SYSTEM
;
654 list_add_tail( &includes
, &include
->entry
);
656 parent
->files
[parent
->files_count
++] = include
;
661 /*******************************************************************
664 static FILE *open_file( const char *path
)
668 if (path
[0] != '/' && strcmp( base_dir
, "." ))
670 char *full_path
= strmake( "%s/%s", base_dir
, path
);
671 ret
= fopen( full_path
, "r" );
674 else ret
= fopen( path
, "r" );
679 /*******************************************************************
682 static FILE *open_src_file( struct incl_file
*pFile
)
686 /* first try name as is */
687 if ((file
= open_file( pFile
->name
)))
689 pFile
->filename
= xstrdup( pFile
->name
);
692 /* now try in source dir */
695 pFile
->filename
= src_dir_path( pFile
->name
);
696 file
= open_file( pFile
->filename
);
698 /* now try parent dir */
699 if (!file
&& parent_dir
)
701 pFile
->filename
= src_dir_path( strmake( "%s/%s", parent_dir
, pFile
->name
));
702 file
= open_file( pFile
->filename
);
704 if (!file
) fatal_perror( "open %s", pFile
->name
);
709 /*******************************************************************
712 static FILE *open_include_file( struct incl_file
*pFile
)
720 /* check for generated bison header */
722 if (strendswith( pFile
->name
, ".tab.h" ))
724 filename
= src_dir_path( replace_extension( pFile
->name
, ".tab.h", ".y" ));
725 if ((file
= open_file( filename
)))
727 pFile
->sourcename
= filename
;
728 pFile
->filename
= xstrdup( pFile
->name
);
729 /* don't bother to parse it */
736 /* check for corresponding idl file in source dir */
738 if (strendswith( pFile
->name
, ".h" ))
740 filename
= src_dir_path( replace_extension( pFile
->name
, ".h", ".idl" ));
741 if ((file
= open_file( filename
)))
743 pFile
->sourcename
= filename
;
744 pFile
->filename
= xstrdup( pFile
->name
);
750 /* now try in source dir */
751 filename
= src_dir_path( pFile
->name
);
752 if ((file
= open_file( filename
))) goto found
;
755 /* now try in parent source dir */
758 filename
= src_dir_path( strmake( "%s/%s", parent_dir
, pFile
->name
));
759 if ((file
= open_file( filename
))) goto found
;
763 /* check for corresponding idl file in global includes */
765 if (strendswith( pFile
->name
, ".h" ))
767 filename
= top_dir_path( strmake( "include/%s", replace_extension( pFile
->name
, ".h", ".idl" )));
768 if ((file
= open_file( filename
)))
770 pFile
->sourcename
= filename
;
771 pFile
->filename
= top_obj_dir_path( strmake( "include/%s", pFile
->name
));
777 /* check for corresponding .in file in global includes (for config.h.in) */
779 if (strendswith( pFile
->name
, ".h" ))
781 filename
= top_dir_path( strmake( "include/%s", replace_extension( pFile
->name
, ".h", ".h.in" )));
782 if ((file
= open_file( filename
)))
784 pFile
->sourcename
= filename
;
785 pFile
->filename
= top_obj_dir_path( strmake( "include/%s", pFile
->name
));
791 /* check for corresponding .x file in global includes */
793 if (strendswith( pFile
->name
, "tmpl.h" ))
795 filename
= top_dir_path( strmake( "include/%s", replace_extension( pFile
->name
, ".h", ".x" )));
796 if ((file
= open_file( filename
)))
798 pFile
->sourcename
= filename
;
799 pFile
->filename
= top_obj_dir_path( strmake( "include/%s", pFile
->name
));
805 /* now search in include paths */
806 for (i
= 0; i
< include_args
.count
; i
++)
808 const char *dir
= include_args
.str
[i
] + 2; /* skip -I */
811 /* ignore absolute paths that don't point into the source dir */
812 if (!top_src_dir
) continue;
813 len
= strlen( top_src_dir
);
814 if (strncmp( dir
, top_src_dir
, len
)) continue;
815 if (dir
[len
] && dir
[len
] != '/') continue;
817 filename
= strmake( "%s/%s", dir
, pFile
->name
);
818 if ((file
= open_file( filename
))) goto found
;
821 if (pFile
->flags
& FLAG_SYSTEM
) return NULL
; /* ignore system files we cannot find */
823 /* try in src file directory */
824 if ((p
= strrchr(pFile
->included_by
->filename
, '/')))
826 int l
= p
- pFile
->included_by
->filename
+ 1;
827 filename
= xmalloc(l
+ strlen(pFile
->name
) + 1);
828 memcpy( filename
, pFile
->included_by
->filename
, l
);
829 strcpy( filename
+ l
, pFile
->name
);
830 if ((file
= open_file( filename
))) goto found
;
834 fprintf( stderr
, "%s:%d: error: ", pFile
->included_by
->filename
, pFile
->included_line
);
835 perror( pFile
->name
);
836 pFile
= pFile
->included_by
;
837 while (pFile
&& pFile
->included_by
)
839 const char *parent
= pFile
->included_by
->sourcename
;
840 if (!parent
) parent
= pFile
->included_by
->name
;
841 fprintf( stderr
, "%s:%d: note: %s was first included here\n",
842 parent
, pFile
->included_line
, pFile
->name
);
843 pFile
= pFile
->included_by
;
848 pFile
->filename
= filename
;
853 /*******************************************************************
854 * parse_include_directive
856 static void parse_include_directive( struct incl_file
*source
, char *str
)
858 char quote
, *include
, *p
= str
;
860 while (*p
&& isspace(*p
)) p
++;
861 if (*p
!= '\"' && *p
!= '<' ) return;
863 if (quote
== '<') quote
= '>';
865 while (*p
&& (*p
!= quote
)) p
++;
866 if (!*p
) fatal_error( "malformed include directive '%s'\n", str
);
868 add_include( source
, include
, (quote
== '>') );
872 /*******************************************************************
873 * parse_pragma_directive
875 static void parse_pragma_directive( struct incl_file
*source
, char *str
)
877 char *flag
, *p
= str
;
879 if (!isspace( *p
)) return;
880 while (*p
&& isspace(*p
)) p
++;
881 p
= strtok( p
, " \t" );
882 if (strcmp( p
, "makedep" )) return;
884 while ((flag
= strtok( NULL
, " \t" )))
886 if (!strcmp( flag
, "depend" ))
888 while ((p
= strtok( NULL
, " \t" ))) add_include( source
, p
, 0 );
891 if (strendswith( source
->name
, ".idl" ))
893 if (!strcmp( flag
, "header" )) source
->flags
|= FLAG_IDL_HEADER
;
894 else if (!strcmp( flag
, "proxy" )) source
->flags
|= FLAG_IDL_PROXY
;
895 else if (!strcmp( flag
, "client" )) source
->flags
|= FLAG_IDL_CLIENT
;
896 else if (!strcmp( flag
, "server" )) source
->flags
|= FLAG_IDL_SERVER
;
897 else if (!strcmp( flag
, "ident" )) source
->flags
|= FLAG_IDL_IDENT
;
898 else if (!strcmp( flag
, "typelib" )) source
->flags
|= FLAG_IDL_TYPELIB
;
899 else if (!strcmp( flag
, "register" )) source
->flags
|= FLAG_IDL_REGISTER
;
900 else if (!strcmp( flag
, "regtypelib" )) source
->flags
|= FLAG_IDL_REGTYPELIB
;
902 else if (strendswith( source
->name
, ".rc" ))
904 if (!strcmp( flag
, "po" )) source
->flags
|= FLAG_RC_PO
;
906 else if (!strcmp( flag
, "implib" )) source
->flags
|= FLAG_C_IMPLIB
;
911 /*******************************************************************
912 * parse_cpp_directive
914 static void parse_cpp_directive( struct incl_file
*source
, char *str
)
916 while (*str
&& isspace(*str
)) str
++;
917 if (*str
++ != '#') return;
918 while (*str
&& isspace(*str
)) str
++;
920 if (!strncmp( str
, "include", 7 ))
921 parse_include_directive( source
, str
+ 7 );
922 else if (!strncmp( str
, "import", 6 ) && strendswith( source
->name
, ".m" ))
923 parse_include_directive( source
, str
+ 6 );
924 else if (!strncmp( str
, "pragma", 6 ))
925 parse_pragma_directive( source
, str
+ 6 );
929 /*******************************************************************
932 * If for_h_file is non-zero, it means we are not interested in the idl file
933 * itself, but only in the contents of the .h file that will be generated from it.
935 static void parse_idl_file( struct incl_file
*pFile
, FILE *file
, int for_h_file
)
937 char *buffer
, *include
;
942 /* generated .h file always includes these */
943 add_include( pFile
, "rpc.h", 1 );
944 add_include( pFile
, "rpcndr.h", 1 );
947 while ((buffer
= get_line( file
)))
951 while (*p
&& isspace(*p
)) p
++;
953 if (!strncmp( p
, "import", 6 ))
956 while (*p
&& isspace(*p
)) p
++;
957 if (*p
!= '"') continue;
959 while (*p
&& (*p
!= '"')) p
++;
960 if (!*p
) fatal_error( "malformed import directive\n" );
962 if (for_h_file
&& strendswith( include
, ".idl" )) strcpy( p
- 4, ".h" );
963 add_include( pFile
, include
, 0 );
967 if (for_h_file
) /* only check for #include inside cpp_quote */
969 if (strncmp( p
, "cpp_quote", 9 )) continue;
971 while (*p
&& isspace(*p
)) p
++;
972 if (*p
++ != '(') continue;
973 while (*p
&& isspace(*p
)) p
++;
974 if (*p
++ != '"') continue;
975 if (*p
++ != '#') continue;
976 while (*p
&& isspace(*p
)) p
++;
977 if (strncmp( p
, "include", 7 )) continue;
979 while (*p
&& isspace(*p
)) p
++;
980 if (*p
== '\\' && p
[1] == '"')
987 if (*p
++ != '<' ) continue;
991 while (*p
&& (*p
!= quote
)) p
++;
992 if (!*p
|| (quote
== '"' && p
[-1] != '\\'))
993 fatal_error( "malformed #include directive inside cpp_quote\n" );
994 if (quote
== '"') p
--; /* remove backslash */
996 add_include( pFile
, include
, (quote
== '>') );
1000 parse_cpp_directive( pFile
, p
);
1004 /*******************************************************************
1007 static void parse_c_file( struct incl_file
*pFile
, FILE *file
)
1012 while ((buffer
= get_line( file
)))
1014 parse_cpp_directive( pFile
, buffer
);
1019 /*******************************************************************
1022 static void parse_rc_file( struct incl_file
*pFile
, FILE *file
)
1024 char *buffer
, *include
;
1027 while ((buffer
= get_line( file
)))
1031 while (*p
&& isspace(*p
)) p
++;
1033 if (p
[0] == '/' && p
[1] == '*') /* check for magic makedep comment */
1036 while (*p
&& isspace(*p
)) p
++;
1037 if (strncmp( p
, "@makedep:", 9 )) continue;
1039 while (*p
&& isspace(*p
)) p
++;
1044 while (*p
&& *p
!= quote
) p
++;
1049 while (*p
&& !isspace(*p
) && *p
!= '*') p
++;
1052 fatal_error( "malformed makedep comment\n" );
1054 add_include( pFile
, include
, (quote
== '>') );
1058 parse_cpp_directive( pFile
, buffer
);
1063 /*******************************************************************
1066 static void parse_in_file( struct incl_file
*source
, FILE *file
)
1070 /* make sure it gets rebuilt when the version changes */
1071 add_include( source
, "config.h", 1 );
1073 if (!strendswith( source
->filename
, ".man.in" )) return; /* not a man page */
1076 while ((buffer
= get_line( file
)))
1078 if (strncmp( buffer
, ".TH", 3 )) continue;
1079 if (!(p
= strtok( buffer
, " \t" ))) continue; /* .TH */
1080 if (!(p
= strtok( NULL
, " \t" ))) continue; /* program name */
1081 if (!(p
= strtok( NULL
, " \t" ))) continue; /* man section */
1082 source
->sourcename
= xstrdup( p
); /* abuse source name to store section */
1088 /*******************************************************************
1091 static void parse_file( struct incl_file
*source
, int src
)
1095 /* don't try to open certain types of files */
1096 if (strendswith( source
->name
, ".tlb" ))
1098 source
->filename
= xstrdup( source
->name
);
1102 file
= src
? open_src_file( source
) : open_include_file( source
);
1104 input_file_name
= source
->filename
;
1106 if (source
->sourcename
&& strendswith( source
->sourcename
, ".idl" ))
1107 parse_idl_file( source
, file
, 1 );
1108 else if (strendswith( source
->filename
, ".idl" ))
1109 parse_idl_file( source
, file
, 0 );
1110 else if (strendswith( source
->filename
, ".c" ) ||
1111 strendswith( source
->filename
, ".m" ) ||
1112 strendswith( source
->filename
, ".h" ) ||
1113 strendswith( source
->filename
, ".l" ) ||
1114 strendswith( source
->filename
, ".y" ))
1115 parse_c_file( source
, file
);
1116 else if (strendswith( source
->filename
, ".rc" ))
1117 parse_rc_file( source
, file
);
1118 else if (strendswith( source
->filename
, ".in" ))
1119 parse_in_file( source
, file
);
1121 input_file_name
= NULL
;
1125 /*******************************************************************
1128 * Add a source file to the list.
1130 static struct incl_file
*add_src_file( const char *name
)
1132 struct incl_file
*file
;
1134 if ((file
= find_src_file( name
))) return file
; /* we already have it */
1135 file
= xmalloc( sizeof(*file
) );
1136 memset( file
, 0, sizeof(*file
) );
1137 file
->name
= xstrdup(name
);
1138 list_add_tail( &sources
, &file
->entry
);
1139 parse_file( file
, 1 );
1144 /*******************************************************************
1147 static char *get_make_variable( const char *name
)
1151 for (i
= 0; i
< cmdline_vars
.count
; i
+= 2)
1152 if (!strcmp( cmdline_vars
.str
[i
], name
))
1153 return xstrdup( cmdline_vars
.str
[i
+ 1] );
1155 for (i
= 0; i
< make_vars
.count
; i
+= 2)
1156 if (!strcmp( make_vars
.str
[i
], name
))
1157 return xstrdup( make_vars
.str
[i
+ 1] );
1162 /*******************************************************************
1163 * get_expanded_make_variable
1165 static char *get_expanded_make_variable( const char *name
)
1167 char *p
, *end
, *var
, *expand
, *tmp
;
1169 expand
= get_make_variable( name
);
1170 if (!expand
) return NULL
;
1173 while ((p
= strchr( p
, '$' )))
1177 if (!(end
= strchr( p
+ 2, ')' ))) fatal_error( "syntax error in '%s'\n", expand
);
1179 if (strchr( p
+ 2, ':' )) fatal_error( "pattern replacement not supported for '%s'\n", p
+ 2 );
1180 var
= get_make_variable( p
+ 2 );
1181 tmp
= replace_substr( expand
, p
, end
- p
, var
? var
: "" );
1184 else if (p
[1] == '{') /* don't expand ${} variables */
1186 if (!(end
= strchr( p
+ 2, '}' ))) fatal_error( "syntax error in '%s'\n", expand
);
1190 else if (p
[1] == '$')
1192 tmp
= replace_substr( expand
, p
, 2, "$" );
1194 else fatal_error( "syntax error in '%s'\n", expand
);
1196 /* switch to the new string */
1197 p
= tmp
+ (p
- expand
);
1202 /* consider empty variables undefined */
1204 while (*p
&& isspace(*p
)) p
++;
1205 if (*p
) return expand
;
1211 /*******************************************************************
1212 * get_expanded_make_var_array
1214 static struct strarray
get_expanded_make_var_array( const char *name
)
1216 struct strarray ret
= empty_strarray
;
1217 char *value
, *token
;
1219 if ((value
= get_expanded_make_variable( name
)))
1220 for (token
= strtok( value
, " \t" ); token
; token
= strtok( NULL
, " \t" ))
1221 strarray_add( &ret
, token
);
1226 /*******************************************************************
1229 static int set_make_variable( struct strarray
*array
, const char *assignment
)
1234 p
= name
= xstrdup( assignment
);
1235 while (isalnum(*p
) || *p
== '_') p
++;
1236 if (name
== p
) return 0; /* not a variable */
1240 while (isspace(*p
)) p
++;
1242 if (*p
!= '=') return 0; /* not an assignment */
1244 while (isspace(*p
)) p
++;
1246 /* redefining a variable replaces the previous value */
1247 for (i
= 0; i
< array
->count
; i
+= 2)
1249 if (strcmp( array
->str
[i
], name
)) continue;
1250 array
->str
[i
+ 1] = p
;
1253 strarray_add( array
, name
);
1254 strarray_add( array
, p
);
1259 /*******************************************************************
1262 static void parse_makefile(void)
1267 input_file_name
= strmake( "%s/%s", base_dir
, makefile_name
);
1268 if (!(file
= fopen( input_file_name
, "r" )))
1270 fatal_perror( "open" );
1275 while ((buffer
= get_line( file
)))
1277 if (Separator
&& !strncmp( buffer
, Separator
, strlen(Separator
) )) break;
1278 if (*buffer
== '\t') continue; /* command */
1279 while (isspace( *buffer
)) buffer
++;
1280 if (*buffer
== '#') continue; /* comment */
1281 set_make_variable( &make_vars
, buffer
);
1284 input_file_name
= NULL
;
1288 /*******************************************************************
1289 * add_generated_source
1291 * Add a generated source file to the list.
1293 static struct incl_file
*add_generated_source( const char *name
, const char *filename
)
1295 struct incl_file
*file
;
1297 if ((file
= find_src_file( name
))) return file
; /* we already have it */
1298 file
= xmalloc( sizeof(*file
) );
1299 memset( file
, 0, sizeof(*file
) );
1300 file
->name
= xstrdup( name
);
1301 file
->filename
= xstrdup( filename
? filename
: name
);
1302 file
->flags
= FLAG_GENERATED
;
1303 list_add_tail( &sources
, &file
->entry
);
1308 /*******************************************************************
1309 * add_generated_sources
1311 static void add_generated_sources(void)
1313 struct incl_file
*source
, *next
, *file
;
1315 LIST_FOR_EACH_ENTRY_SAFE( source
, next
, &sources
, struct incl_file
, entry
)
1317 if (source
->flags
& FLAG_IDL_CLIENT
)
1319 file
= add_generated_source( replace_extension( source
->name
, ".idl", "_c.c" ), NULL
);
1320 add_include( file
, replace_extension( source
->name
, ".idl", ".h" ), 0 );
1322 if (source
->flags
& FLAG_IDL_SERVER
)
1324 file
= add_generated_source( replace_extension( source
->name
, ".idl", "_s.c" ), NULL
);
1325 add_include( file
, "wine/exception.h", 0 );
1326 add_include( file
, replace_extension( source
->name
, ".idl", ".h" ), 0 );
1328 if (source
->flags
& FLAG_IDL_IDENT
)
1330 file
= add_generated_source( replace_extension( source
->name
, ".idl", "_i.c" ), NULL
);
1331 add_include( file
, "rpc.h", 0 );
1332 add_include( file
, "rpcndr.h", 0 );
1333 add_include( file
, "guiddef.h", 0 );
1335 if (source
->flags
& FLAG_IDL_PROXY
)
1337 file
= add_generated_source( "dlldata.o", "dlldata.c" );
1338 add_include( file
, "objbase.h", 0 );
1339 add_include( file
, "rpcproxy.h", 0 );
1340 file
= add_generated_source( replace_extension( source
->name
, ".idl", "_p.c" ), NULL
);
1341 add_include( file
, "objbase.h", 0 );
1342 add_include( file
, "rpcproxy.h", 0 );
1343 add_include( file
, "wine/exception.h", 0 );
1344 add_include( file
, replace_extension( source
->name
, ".idl", ".h" ), 0 );
1346 if (source
->flags
& FLAG_IDL_REGTYPELIB
)
1348 add_generated_source( replace_extension( source
->name
, ".idl", "_t.res" ), NULL
);
1350 if (source
->flags
& FLAG_IDL_REGISTER
)
1352 add_generated_source( replace_extension( source
->name
, ".idl", "_r.res" ), NULL
);
1354 if (strendswith( source
->name
, ".y" ))
1356 file
= add_generated_source( replace_extension( source
->name
, ".y", ".tab.c" ), NULL
);
1357 /* steal the includes list from the source file */
1358 file
->files_count
= source
->files_count
;
1359 file
->files_size
= source
->files_size
;
1360 file
->files
= source
->files
;
1361 source
->files_count
= source
->files_size
= 0;
1362 source
->files
= NULL
;
1364 if (strendswith( source
->name
, ".l" ))
1366 file
= add_generated_source( replace_extension( source
->name
, ".l", ".yy.c" ), NULL
);
1367 /* steal the includes list from the source file */
1368 file
->files_count
= source
->files_count
;
1369 file
->files_size
= source
->files_size
;
1370 file
->files
= source
->files
;
1371 source
->files_count
= source
->files_size
= 0;
1372 source
->files
= NULL
;
1375 if (get_make_variable( "TESTDLL" ))
1377 file
= add_generated_source( "testlist.o", "testlist.c" );
1378 add_include( file
, "wine/test.h", 0 );
1383 /*******************************************************************
1386 static void output_include( struct incl_file
*pFile
, struct incl_file
*owner
)
1390 if (pFile
->owner
== owner
) return;
1391 if (!pFile
->filename
) return;
1392 pFile
->owner
= owner
;
1393 output_filename( pFile
->filename
);
1394 for (i
= 0; i
< pFile
->files_count
; i
++) output_include( pFile
->files
[i
], owner
);
1398 /*******************************************************************
1401 static struct strarray
output_sources(void)
1403 struct incl_file
*source
;
1404 int i
, is_win16
= 0;
1405 const char *dllext
= ".so";
1406 struct strarray object_files
= empty_strarray
;
1407 struct strarray crossobj_files
= empty_strarray
;
1408 struct strarray res_files
= empty_strarray
;
1409 struct strarray clean_files
= empty_strarray
;
1410 struct strarray po_files
= empty_strarray
;
1411 struct strarray mo_files
= empty_strarray
;
1412 struct strarray mc_files
= empty_strarray
;
1413 struct strarray test_files
= empty_strarray
;
1414 struct strarray dlldata_files
= empty_strarray
;
1415 struct strarray c2man_files
= empty_strarray
;
1416 struct strarray implib_objs
= empty_strarray
;
1417 struct strarray includes
= empty_strarray
;
1418 struct strarray phony_targets
= empty_strarray
;
1419 struct strarray linguas
= get_expanded_make_var_array( "LINGUAS" );
1420 struct strarray all_targets
= get_expanded_make_var_array( "PROGRAMS" );
1421 struct strarray targetflags
= get_expanded_make_var_array( "TARGETFLAGS" );
1422 struct strarray delayimports
= get_expanded_make_var_array( "DELAYIMPORTS" );
1423 struct strarray extradllflags
= get_expanded_make_var_array( "EXTRADLLFLAGS" );
1424 char *module
= get_expanded_make_variable( "MODULE" );
1425 char *exeext
= get_expanded_make_variable( "EXEEXT" );
1426 char *testdll
= get_expanded_make_variable( "TESTDLL" );
1427 char *staticlib
= get_expanded_make_variable( "STATICLIB" );
1428 char *crosstarget
= get_expanded_make_variable( "CROSSTARGET" );
1430 if (exeext
&& !strcmp( exeext
, ".exe" )) dllext
= "";
1431 if (module
&& strendswith( module
, ".a" )) staticlib
= module
;
1432 for (i
= 0; i
< extradllflags
.count
; i
++) if (!strcmp( extradllflags
.str
[i
], "-m16" )) is_win16
= 1;
1434 for (i
= 0; i
< linguas
.count
; i
++)
1435 strarray_add( &mo_files
, strmake( "%s/po/%s.mo", top_obj_dir
, linguas
.str
[i
] ));
1437 strarray_add( &includes
, "-I." );
1438 if (src_dir
) strarray_add( &includes
, strmake( "-I%s", src_dir
));
1439 if (parent_dir
) strarray_add( &includes
, strmake( "-I%s", src_dir_path( parent_dir
)));
1440 if (top_src_dir
&& top_obj_dir
) strarray_add( &includes
, strmake( "-I%s/include", top_obj_dir
));
1441 strarray_addall( &includes
, include_args
);
1443 LIST_FOR_EACH_ENTRY( source
, &sources
, struct incl_file
, entry
)
1445 struct strarray extradefs
;
1446 char *subdir
= NULL
;
1447 char *obj
= xstrdup( source
->name
);
1448 char *ext
= get_extension( obj
);
1450 if (!ext
) fatal_error( "unsupported file type %s\n", source
->name
);
1453 if (src_dir
&& strchr( obj
, '/' ))
1455 subdir
= xstrdup( obj
);
1456 *strrchr( subdir
, '/' ) = 0;
1459 extradefs
= get_expanded_make_var_array( strmake( "%s_EXTRADEFS", obj
));
1461 if (!strcmp( ext
, "y" )) /* yacc file */
1463 /* add source file dependency for parallel makes */
1464 char *header
= strmake( "%s.tab.h", obj
);
1466 if (find_include_file( header
))
1468 output( "%s.tab.h: %s\n", obj
, source
->filename
);
1469 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1470 output( "\t$(BISON) -p %s_ -o %s.tab.c -d %s\n",
1471 obj
, obj
, source
->filename
);
1472 output( "%s.tab.c: %s %s\n", obj
, source
->filename
, header
);
1473 strarray_add( &clean_files
, strmake( "%s.tab.h", obj
));
1475 else output( "%s.tab.c: %s\n", obj
, source
->filename
);
1477 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1478 output( "\t$(BISON) -p %s_ -o $@ %s\n", obj
, source
->filename
);
1480 continue; /* no dependencies */
1482 else if (!strcmp( ext
, "x" )) /* template file */
1484 output( "%s.h: %s%s %s\n", obj
, tools_dir_path( "make_xftmpl" ), tools_ext
, source
->filename
);
1485 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1486 output( "\t%s%s -H -o $@ %s\n", tools_dir_path( "make_xftmpl" ), tools_ext
, source
->filename
);
1487 strarray_add( &clean_files
, strmake( "%s.h", obj
));
1488 continue; /* no dependencies */
1490 else if (!strcmp( ext
, "l" )) /* lex file */
1492 output( "%s.yy.c: %s\n", obj
, source
->filename
);
1493 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1494 output( "\t$(FLEX) -o$@ %s\n", source
->filename
);
1495 continue; /* no dependencies */
1497 else if (!strcmp( ext
, "rc" )) /* resource file */
1499 strarray_add( &res_files
, strmake( "%s.res", obj
));
1500 output( "%s.res: %s %s\n", obj
, tools_path( "wrc" ), source
->filename
);
1501 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1502 output( "\t%s -o $@ %s", tools_path( "wrc" ), source
->filename
);
1503 if (is_win16
) output_filename( "-m16" );
1504 else output_filenames( targetflags
);
1505 output_filename( "--nostdinc" );
1506 output_filenames( includes
);
1507 output_filenames( define_args
);
1508 output_filenames( extradefs
);
1509 if (mo_files
.count
&& (source
->flags
& FLAG_RC_PO
))
1511 strarray_add( &po_files
, source
->filename
);
1512 output_filename( strmake( "--po-dir=%s/po", top_obj_dir
));
1514 output( "%s.res:", obj
);
1515 output_filenames( mo_files
);
1517 output( "rsrc.pot " );
1519 else output( "\n" );
1520 output( "%s.res:", obj
);
1522 else if (!strcmp( ext
, "mc" )) /* message file */
1524 strarray_add( &res_files
, strmake( "%s.res", obj
));
1525 output( "%s.res: %s %s\n", obj
, tools_path( "wmc" ), source
->filename
);
1526 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1527 output( "\t%s -U -O res -o $@ %s", tools_path( "wmc" ), source
->filename
);
1530 strarray_add( &mc_files
, source
->filename
);
1531 output_filename( strmake( "--po-dir=%s/po", top_obj_dir
));
1533 output( "%s.res:", obj
);
1534 output_filenames( mo_files
);
1536 output( "msg.pot " );
1538 else output( "\n" );
1539 output( "%s.res:", obj
);
1541 else if (!strcmp( ext
, "idl" )) /* IDL file */
1543 struct strarray targets
= empty_strarray
;
1547 if (!source
->flags
|| find_include_file( strmake( "%s.h", obj
)))
1548 source
->flags
|= FLAG_IDL_HEADER
;
1550 for (i
= 0; i
< sizeof(idl_outputs
) / sizeof(idl_outputs
[0]); i
++)
1552 if (!(source
->flags
& idl_outputs
[i
].flag
)) continue;
1553 dest
= strmake( "%s%s", obj
, idl_outputs
[i
].ext
);
1554 if (!find_src_file( dest
)) strarray_add( &clean_files
, dest
);
1555 strarray_add( &targets
, dest
);
1557 if (source
->flags
& FLAG_IDL_PROXY
) strarray_add( &dlldata_files
, source
->name
);
1558 output_filenames( targets
);
1559 output( ": %s\n", tools_path( "widl" ));
1560 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1561 output( "\t%s -o $@ %s", tools_path( "widl" ), source
->filename
);
1562 output_filenames( targetflags
);
1563 output_filenames( includes
);
1564 output_filenames( define_args
);
1565 output_filenames( extradefs
);
1566 output_filenames( get_expanded_make_var_array( "EXTRAIDLFLAGS" ));
1568 output_filenames( targets
);
1569 output( ": %s", source
->filename
);
1571 else if (!strcmp( ext
, "in" )) /* .in file or man page */
1573 if (strendswith( obj
, ".man" ) && source
->sourcename
)
1575 char *dir
, *dest
= replace_extension( obj
, ".man", "" );
1576 char *lang
= strchr( dest
, '.' );
1580 dir
= strmake( "$(DESTDIR)$(mandir)/%s/man%s", lang
, source
->sourcename
);
1582 else dir
= strmake( "$(DESTDIR)$(mandir)/man%s", source
->sourcename
);
1583 output( "install-man-pages:: %s\n", obj
);
1584 output( "\t$(INSTALL_DATA) %s %s/%s.%s\n",
1585 obj
, dir
, dest
, source
->sourcename
);
1586 output( "uninstall::\n" );
1587 output( "\t$(RM) %s/%s.%s\n",
1588 dir
, dest
, source
->sourcename
);
1591 strarray_add( &all_targets
, xstrdup(obj
) );
1592 strarray_add_uniq( &phony_targets
, "install-man-pages" );
1594 else strarray_add( &clean_files
, xstrdup(obj
) );
1595 output( "%s: %s\n", obj
, source
->filename
);
1596 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1597 output( "\t$(SED_CMD) %s >$@ || ($(RM) $@ && false)\n", source
->filename
);
1598 output( "%s:", obj
);
1600 else if (!strcmp( ext
, "sfd" )) /* font file */
1602 char *fontforge
= get_expanded_make_variable( "FONTFORGE" );
1603 if (fontforge
&& !src_dir
)
1605 output( "%s.ttf: %s\n", obj
, source
->filename
);
1606 output( "\t%s -script %s %s $@\n",
1607 fontforge
, top_dir_path( "fonts/genttf.ff" ), source
->filename
);
1610 continue; /* no dependencies */
1612 else if (!strcmp( ext
, "svg" )) /* svg file */
1614 char *convert
= get_expanded_make_variable( "CONVERT" );
1615 char *rsvg
= get_expanded_make_variable( "RSVG" );
1616 char *icotool
= get_expanded_make_variable( "ICOTOOL" );
1617 if (convert
&& rsvg
&& icotool
&& !src_dir
)
1619 output( "%s.ico %s.bmp: %s\n", obj
, obj
, source
->filename
);
1620 output( "\tCONVERT=\"%s\" ICOTOOL=\"%s\" RSVG=\"%s\" %s %s $@\n",
1621 convert
, icotool
, rsvg
, top_dir_path( "tools/buildimage" ), source
->filename
);
1626 continue; /* no dependencies */
1628 else if (!strcmp( ext
, "res" ))
1630 strarray_add( &res_files
, source
->name
);
1631 continue; /* no dependencies */
1635 int need_cross
= testdll
|| (source
->flags
& FLAG_C_IMPLIB
) || (module
&& staticlib
);
1637 if (source
->flags
& FLAG_GENERATED
) strarray_add( &clean_files
, source
->filename
);
1638 if (source
->flags
& FLAG_C_IMPLIB
) strarray_add( &implib_objs
, strmake( "%s.o", obj
));
1639 strarray_add( &object_files
, strmake( "%s.o", obj
));
1640 output( "%s.o: %s\n", obj
, source
->filename
);
1641 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1642 output( "\t$(CC) -c -o $@ %s", source
->filename
);
1643 output_filenames( includes
);
1644 output_filenames( define_args
);
1645 output_filenames( extradefs
);
1646 if (module
|| staticlib
|| testdll
) output_filenames( dllflags
);
1647 output_filenames( get_expanded_make_var_array( "EXTRACFLAGS" ));
1648 output_filenames( get_expanded_make_var_array( "CPPFLAGS" ));
1649 output_filename( "$(CFLAGS)" );
1651 if (crosstarget
&& need_cross
)
1653 strarray_add( &crossobj_files
, strmake( "%s.cross.o", obj
));
1654 output( "%s.cross.o: %s\n", obj
, source
->filename
);
1655 if (subdir
) output( "\t$(MKDIR_P) -m 755 %s\n", subdir
);
1656 output( "\t$(CROSSCC) -c -o $@ %s", source
->filename
);
1657 output_filenames( includes
);
1658 output_filenames( define_args
);
1659 output_filenames( extradefs
);
1660 output_filename( "-DWINE_CROSSTEST" );
1661 output_filenames( get_expanded_make_var_array( "CPPFLAGS" ));
1662 output_filename( "$(CFLAGS)" );
1665 if (testdll
&& !strcmp( ext
, "c" ) && !(source
->flags
& FLAG_GENERATED
))
1667 strarray_add( &test_files
, source
->name
);
1668 output( "%s.ok:\n", obj
);
1669 output( "\t%s $(RUNTESTFLAGS) -T %s -M %s -p %s%s %s && touch $@\n",
1670 top_dir_path( "tools/runtest" ), top_obj_dir
,
1671 testdll
, replace_extension( testdll
, ".dll", "_test.exe" ), dllext
, obj
);
1673 if (!strcmp( ext
, "c" ) && !(source
->flags
& FLAG_GENERATED
))
1674 strarray_add( &c2man_files
, source
->filename
);
1675 output( "%s.o", obj
);
1676 if (crosstarget
&& need_cross
) output( " %s.cross.o", obj
);
1681 for (i
= 0; i
< source
->files_count
; i
++) output_include( source
->files
[i
], source
);
1685 /* rules for files that depend on multiple sources */
1689 output( "rsrc.pot: %s", tools_path( "wrc" ) );
1690 output_filenames( po_files
);
1692 output( "\t%s -O pot -o $@", tools_path( "wrc" ));
1693 output_filenames( po_files
);
1694 if (is_win16
) output_filename( "-m16" );
1695 else output_filenames( targetflags
);
1696 output_filename( "--nostdinc" );
1697 output_filenames( includes
);
1698 output_filenames( define_args
);
1700 strarray_add( &clean_files
, "rsrc.pot" );
1705 output( "msg.pot: %s", tools_path( "wmc" ));
1706 output_filenames( mc_files
);
1708 output( "\t%s -O pot -o $@", tools_path( "wmc" ));
1709 output_filenames( mc_files
);
1711 strarray_add( &clean_files
, "msg.pot" );
1714 if (dlldata_files
.count
)
1716 output( "dlldata.c: %s %s\n", tools_path( "widl" ), src_dir_path( "Makefile.in" ));
1717 output( "\t%s --dlldata-only -o $@", tools_path( "widl" ));
1718 output_filenames( dlldata_files
);
1722 if (module
&& !staticlib
)
1724 char *importlib
= get_expanded_make_variable( "IMPORTLIB" );
1725 struct strarray all_libs
= empty_strarray
;
1726 char *spec_file
= NULL
;
1728 if (!appmode
.count
) spec_file
= src_dir_path( replace_extension( module
, ".dll", ".spec" ));
1729 for (i
= 0; i
< delayimports
.count
; i
++)
1730 strarray_add( &all_libs
, strmake( "-l%s", delayimports
.str
[i
] ));
1731 for (i
= 0; i
< imports
.count
; i
++)
1732 strarray_add( &all_libs
, strmake( "-l%s", imports
.str
[i
] ));
1733 for (i
= 0; i
< delayimports
.count
; i
++)
1734 strarray_add( &all_libs
, strmake( "-Wb,-d%s", delayimports
.str
[i
] ));
1735 strarray_add( &all_libs
, "-lwine" );
1736 strarray_addall( &all_libs
, get_expanded_make_var_array( "LIBPORT" ));
1737 strarray_addall( &all_libs
, get_expanded_make_var_array( "EXTRALIBS" ));
1738 strarray_addall( &all_libs
, get_expanded_make_var_array( "LIBS" ));
1742 strarray_add( &all_targets
, strmake( "%s%s", module
, dllext
));
1743 strarray_add( &all_targets
, strmake( "%s.fake", module
));
1744 output( "%s%s %s.fake:", module
, dllext
, module
);
1748 strarray_add( &all_targets
, module
);
1749 output( "%s:", module
);
1751 if (spec_file
) output_filename( spec_file
);
1752 output_filenames( object_files
);
1753 output_filenames( res_files
);
1755 output( "\t%s -o $@", tools_path( "winegcc" ));
1756 output_filename( strmake( "-B%s", tools_dir_path( "winebuild" )));
1757 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir
));
1758 output_filenames( targetflags
);
1759 output_filenames( get_expanded_make_var_array( "UNWINDFLAGS" ));
1762 output( " -shared %s", spec_file
);
1763 output_filenames( extradllflags
);
1765 else output_filenames( appmode
);
1766 output_filenames( object_files
);
1767 output_filenames( res_files
);
1768 output_filenames( all_libs
);
1769 output_filename( "$(LDFLAGS)" );
1772 if (spec_file
&& importlib
)
1776 strarray_add( &clean_files
, strmake( "lib%s.def", importlib
));
1777 output( "lib%s.def: %s %s\n", importlib
, tools_path( "winebuild" ), spec_file
);
1778 output( "\t%s -w --def -o $@ --export %s", tools_path( "winebuild" ), spec_file
);
1779 output_filenames( targetflags
);
1780 if (is_win16
) output_filename( "-m16" );
1782 if (implib_objs
.count
)
1784 strarray_add( &clean_files
, strmake( "lib%s.def.a", importlib
));
1785 output( "lib%s.def.a:", importlib
);
1786 output_filenames( implib_objs
);
1788 output( "\t$(RM) $@\n" );
1789 output( "\t$(AR) $(ARFLAGS) $@" );
1790 output_filenames( implib_objs
);
1792 output( "\t$(RANLIB) $@\n" );
1797 strarray_add( &clean_files
, strmake( "lib%s.a", importlib
));
1798 output( "lib%s.a: %s %s", importlib
, tools_path( "winebuild" ), spec_file
);
1799 output_filenames( implib_objs
);
1801 output( "\t%s -w --implib -o $@ --export %s", tools_path( "winebuild" ), spec_file
);
1802 output_filenames( targetflags
);
1803 output_filenames( implib_objs
);
1806 if (crosstarget
&& !is_win16
)
1808 struct strarray cross_files
= strarray_replace_extension( &implib_objs
, ".o", ".cross.o" );
1809 strarray_add( &clean_files
, strmake( "lib%s.cross.a", importlib
));
1810 output( "lib%s.cross.a: %s %s", importlib
, tools_path( "winebuild" ), spec_file
);
1811 output_filenames( cross_files
);
1813 output( "\t%s -b %s -w --implib -o $@ --export %s",
1814 tools_path( "winebuild" ), crosstarget
, spec_file
);
1815 output_filenames( cross_files
);
1822 if (c2man_files
.count
&& top_obj_dir
)
1824 char *manext
= get_expanded_make_variable( "api_manext" );
1826 output( "manpages::\n" );
1827 output( "\t%s -w %s -R%s", top_dir_path( "tools/c2man.pl" ), spec_file
, top_obj_dir
);
1828 output_filename( strmake( "-I%s", top_dir_path( "include" )));
1829 output_filename( strmake( "-o %s/documentation/man%s", top_obj_dir
, manext
? manext
: "3w" ));
1830 output_filenames( c2man_files
);
1832 output( "htmlpages::\n" );
1833 output( "\t%s -Th -w %s -R%s", top_dir_path( "tools/c2man.pl" ), spec_file
, top_obj_dir
);
1834 output_filename( strmake( "-I%s", top_dir_path( "include" )));
1835 output_filename( strmake( "-o %s/documentation/html", top_obj_dir
));
1836 output_filenames( c2man_files
);
1838 output( "sgmlpages::\n" );
1839 output( "\t%s -Ts -w %s -R%s", top_dir_path( "tools/c2man.pl" ), spec_file
, top_obj_dir
);
1840 output_filename( strmake( "-I%s", top_dir_path( "include" )));
1841 output_filename( strmake( "-o %s/documentation/api-guide", top_obj_dir
));
1842 output_filenames( c2man_files
);
1844 output( "xmlpages::\n" );
1845 output( "\t%s -Tx -w %s -R%s", top_dir_path( "tools/c2man.pl" ), spec_file
, top_obj_dir
);
1846 output_filename( strmake( "-I%s", top_dir_path( "include" )));
1847 output_filename( strmake( "-o %s/documentation/api-guide-xml", top_obj_dir
));
1848 output_filenames( c2man_files
);
1850 strarray_add( &phony_targets
, "manpages" );
1851 strarray_add( &phony_targets
, "htmlpages" );
1852 strarray_add( &phony_targets
, "sgmlpages" );
1853 strarray_add( &phony_targets
, "xmlpages" );
1855 else output( "manpages htmlpages sgmlpages xmlpages::\n" );
1861 strarray_add( &all_targets
, staticlib
);
1862 output( "%s:", staticlib
);
1863 output_filenames( object_files
);
1864 output( "\n\t$(RM) $@\n" );
1865 output( "\t$(AR) $(ARFLAGS) $@" );
1866 output_filenames( object_files
);
1867 output( "\n\t$(RANLIB) $@\n" );
1868 if (crosstarget
&& module
)
1870 char *name
= replace_extension( staticlib
, ".a", ".cross.a" );
1872 strarray_add( &all_targets
, name
);
1873 output( "%s:", name
);
1874 output_filenames( crossobj_files
);
1875 output( "\n\t$(RM) $@\n" );
1876 output( "\t%s-ar $(ARFLAGS) $@", crosstarget
);
1877 output_filenames( crossobj_files
);
1878 output( "\n\t%s-ranlib $@\n", crosstarget
);
1884 struct strarray ok_files
= strarray_replace_extension( &test_files
, ".c", ".ok" );
1885 char *testmodule
= replace_extension( testdll
, ".dll", "_test.exe" );
1886 char *stripped
= replace_extension( testdll
, ".dll", "_test-stripped.exe" );
1887 struct strarray all_libs
= empty_strarray
;
1889 for (i
= 0; i
< imports
.count
; i
++) strarray_add( &all_libs
, strmake( "-l%s", imports
.str
[i
] ));
1890 strarray_addall( &all_libs
, get_expanded_make_var_array( "LIBS" ));
1892 strarray_add( &all_targets
, strmake( "%s%s", testmodule
, dllext
));
1893 strarray_add( &clean_files
, strmake( "%s%s", stripped
, dllext
));
1894 output( "%s%s:\n", testmodule
, dllext
);
1895 output( "\t%s -o $@", tools_path( "winegcc" ));
1896 output_filename( strmake( "-B%s", tools_dir_path( "winebuild" )));
1897 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir
));
1898 output_filenames( targetflags
);
1899 output_filenames( get_expanded_make_var_array( "UNWINDFLAGS" ));
1900 output_filenames( appmode
);
1901 output_filenames( object_files
);
1902 output_filenames( res_files
);
1903 output_filenames( all_libs
);
1904 output_filename( "$(LDFLAGS)" );
1906 output( "%s%s:\n", stripped
, dllext
);
1907 output( "\t%s -o $@", tools_path( "winegcc" ));
1908 output_filename( strmake( "-B%s", tools_dir_path( "winebuild" )));
1909 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir
));
1910 output_filenames( targetflags
);
1911 output_filenames( get_expanded_make_var_array( "UNWINDFLAGS" ));
1912 output_filename( strmake( "-Wb,-F,%s", testmodule
));
1913 output_filenames( appmode
);
1914 output_filenames( object_files
);
1915 output_filenames( res_files
);
1916 output_filenames( all_libs
);
1917 output_filename( "$(LDFLAGS)" );
1919 output( "%s%s %s%s:", testmodule
, dllext
, stripped
, dllext
);
1920 output_filenames( object_files
);
1921 output_filenames( res_files
);
1926 char *testres
= replace_extension( testdll
, ".dll", "_test.res" );
1927 output( "all: %s/%s\n", top_obj_dir_path( "programs/winetest" ), testres
);
1928 output( "%s/%s: %s%s\n", top_obj_dir_path( "programs/winetest" ), testres
, stripped
, dllext
);
1929 output( "\techo \"%s TESTRES \\\"%s%s\\\"\" | %s -o $@\n",
1930 testmodule
, stripped
, dllext
, tools_path( "wrc" ));
1935 char *crosstest
= replace_extension( testdll
, ".dll", "_crosstest.exe" );
1937 strarray_add( &clean_files
, crosstest
);
1938 output( "crosstest: %s\n", crosstest
);
1939 output( "%s:", crosstest
);
1940 output_filenames( crossobj_files
);
1941 output_filenames( res_files
);
1943 output( "\t%s -o $@ -b %s", tools_path( "winegcc" ), crosstarget
);
1944 output_filename( strmake( "-B%s", tools_dir_path( "winebuild" )));
1945 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir
));
1946 output_filename( "--lib-suffix=.cross.a" );
1947 output_filenames( crossobj_files
);
1948 output_filenames( res_files
);
1949 output_filenames( all_libs
);
1950 output_filename( "$(LDFLAGS)" );
1952 strarray_add( &phony_targets
, "crosstest" );
1955 output( "testlist.c: %s%s %s\n",
1956 tools_dir_path( "make_ctests" ), tools_ext
, src_dir_path( "Makefile.in" ));
1957 output( "\t%s%s -o $@", tools_dir_path( "make_ctests" ), tools_ext
);
1958 output_filenames( test_files
);
1960 output_filenames( ok_files
);
1961 output( ": %s%s ../%s%s\n", testmodule
, dllext
, testdll
, dllext
);
1962 output( "check test:" );
1963 output_filenames( ok_files
);
1965 output( "testclean::\n" );
1966 output( "\t$(RM)" );
1967 output_filenames( ok_files
);
1969 strarray_addall( &clean_files
, ok_files
);
1970 strarray_add( &phony_targets
, "check" );
1971 strarray_add( &phony_targets
, "test" );
1972 strarray_add( &phony_targets
, "testclean" );
1975 if (all_targets
.count
)
1978 output_filenames( all_targets
);
1982 strarray_addall( &clean_files
, object_files
);
1983 strarray_addall( &clean_files
, crossobj_files
);
1984 strarray_addall( &clean_files
, res_files
);
1985 strarray_addall( &clean_files
, all_targets
);
1986 strarray_addall( &clean_files
, get_expanded_make_var_array( "EXTRA_TARGETS" ));
1988 if (clean_files
.count
)
1990 output( "clean::\n" );
1991 output( "\t$(RM)" );
1992 output_filenames( clean_files
);
1994 strarray_add( &phony_targets
, "clean" );
1999 output( "depend:\n" );
2000 output( "\t@cd %s && $(MAKE) %s/depend\n", top_obj_dir
, base_dir
);
2001 strarray_add( &phony_targets
, "depend" );
2004 if (phony_targets
.count
)
2006 output( ".PHONY:" );
2007 output_filenames( phony_targets
);
2015 /*******************************************************************
2018 static FILE *create_temp_file( const char *orig
)
2020 char *name
= xmalloc( strlen(orig
) + 13 );
2021 unsigned int i
, id
= getpid();
2025 for (i
= 0; i
< 100; i
++)
2027 sprintf( name
, "%s.tmp%08x", orig
, id
);
2028 if ((fd
= open( name
, O_RDWR
| O_CREAT
| O_EXCL
, 0666 )) != -1)
2030 ret
= fdopen( fd
, "w" );
2033 if (errno
!= EEXIST
) break;
2036 if (!ret
) fatal_error( "failed to create output file for '%s'\n", orig
);
2037 temp_file_name
= name
;
2042 /*******************************************************************
2045 static void rename_temp_file( const char *dest
)
2047 int ret
= rename( temp_file_name
, dest
);
2048 if (ret
== -1 && errno
== EEXIST
)
2050 /* rename doesn't overwrite on windows */
2052 ret
= rename( temp_file_name
, dest
);
2054 if (ret
== -1) fatal_error( "failed to rename output file to '%s'\n", dest
);
2055 temp_file_name
= NULL
;
2059 /*******************************************************************
2062 static void output_gitignore( const char *dest
, const struct strarray
*files
)
2066 output_file
= create_temp_file( dest
);
2068 output( "# Automatically generated by make depend; DO NOT EDIT!!\n" );
2069 output( "/.gitignore\n" );
2070 output( "/Makefile\n" );
2071 for (i
= 0; i
< files
->count
; i
++)
2073 if (!strchr( files
->str
[i
], '/' )) output( "/" );
2074 output( "%s\n", files
->str
[i
] );
2077 if (fclose( output_file
)) fatal_perror( "write" );
2079 rename_temp_file( dest
);
2083 /*******************************************************************
2084 * output_dependencies
2086 static void output_dependencies( const char *path
)
2088 struct strarray targets
= empty_strarray
;
2090 if (Separator
&& ((output_file
= fopen( path
, "r" ))))
2093 FILE *tmp_file
= create_temp_file( path
);
2096 while (fgets( buffer
, sizeof(buffer
), output_file
) && !found
)
2098 if (fwrite( buffer
, 1, strlen(buffer
), tmp_file
) != strlen(buffer
)) fatal_perror( "write" );
2099 found
= !strncmp( buffer
, Separator
, strlen(Separator
) );
2101 if (fclose( output_file
)) fatal_perror( "write" );
2102 output_file
= tmp_file
;
2103 if (!found
) output( "\n%s\n", Separator
);
2107 if (!(output_file
= fopen( path
, Separator
? "a" : "w" )))
2108 fatal_perror( "%s", path
);
2111 targets
= output_sources();
2113 fclose( output_file
);
2115 if (temp_file_name
) rename_temp_file( path
);
2117 if (!src_dir
) output_gitignore( strmake( "%s/.gitignore", base_dir
), &targets
);
2121 /*******************************************************************
2124 static void update_makefile( const char *path
)
2126 static const char *source_vars
[] =
2145 struct strarray value
;
2146 struct incl_file
*file
;
2149 output_file_name
= strmake( "%s/%s", base_dir
, makefile_name
);
2152 src_dir
= get_expanded_make_variable( "srcdir" );
2153 top_src_dir
= get_expanded_make_variable( "top_srcdir" );
2154 top_obj_dir
= get_expanded_make_variable( "top_builddir" );
2155 parent_dir
= get_expanded_make_variable( "PARENTSRC" );
2156 tools_dir
= get_expanded_make_variable( "TOOLSDIR" );
2157 tools_ext
= get_expanded_make_variable( "TOOLSEXT" );
2159 appmode
= get_expanded_make_var_array( "APPMODE" );
2160 dllflags
= get_expanded_make_var_array( "DLLFLAGS" );
2161 imports
= get_expanded_make_var_array( "IMPORTS" );
2163 for (i
= 0; i
< appmode
.count
&& !use_msvcrt
; i
++)
2164 use_msvcrt
= !strcmp( appmode
.str
[i
], "-mno-cygwin" );
2165 for (i
= 0; i
< imports
.count
&& !use_msvcrt
; i
++)
2166 use_msvcrt
= !strncmp( imports
.str
[i
], "msvcr", 5 );
2168 include_args
= empty_strarray
;
2169 define_args
= empty_strarray
;
2170 strarray_add( &define_args
, "-D__WINESRC__" );
2172 if (!tools_ext
) tools_ext
= "";
2174 value
= get_expanded_make_var_array( "EXTRAINCL" );
2175 for (i
= 0; i
< value
.count
; i
++)
2176 if (!strncmp( value
.str
[i
], "-I", 2 ))
2177 strarray_add_uniq( &include_args
, value
.str
[i
] );
2179 strarray_add_uniq( &define_args
, value
.str
[i
] );
2180 strarray_addall( &define_args
, get_expanded_make_var_array( "EXTRADEFS" ));
2186 strarray_add( &dllflags
, get_expanded_make_variable( "MSVCRTFLAGS" ));
2187 strarray_add( &include_args
, strmake( "-I%s", top_dir_path( "include/msvcrt" )));
2190 list_init( &sources
);
2191 list_init( &includes
);
2193 for (var
= source_vars
; *var
; var
++)
2195 value
= get_expanded_make_var_array( *var
);
2196 for (i
= 0; i
< value
.count
; i
++) add_src_file( value
.str
[i
] );
2199 add_generated_sources();
2201 value
= get_expanded_make_var_array( "EXTRA_OBJS" );
2202 for (i
= 0; i
< value
.count
; i
++)
2204 /* default to .c for unknown extra object files */
2205 if (strendswith( value
.str
[i
], ".o" ))
2206 add_generated_source( value
.str
[i
], replace_extension( value
.str
[i
], ".o", ".c" ) );
2208 add_generated_source( value
.str
[i
], NULL
);
2211 LIST_FOR_EACH_ENTRY( file
, &includes
, struct incl_file
, entry
) parse_file( file
, 0 );
2212 output_dependencies( output_file_name
);
2213 output_file_name
= NULL
;
2217 /*******************************************************************
2220 static void parse_makeflags( const char *flags
)
2222 const char *p
= flags
;
2223 char *var
, *buffer
= xmalloc( strlen(flags
) + 1 );
2227 while (isspace(*p
)) p
++;
2229 while (*p
&& !isspace(*p
))
2231 if (*p
== '\\' && p
[1]) p
++;
2235 if (var
> buffer
) set_make_variable( &cmdline_vars
, buffer
);
2240 /*******************************************************************
2243 static int parse_option( const char *opt
)
2247 if (strchr( opt
, '=' )) return set_make_variable( &cmdline_vars
, opt
);
2253 if (opt
[2]) strarray_add_uniq( &include_args
, opt
);
2259 top_src_dir
= opt
+ 2;
2262 top_obj_dir
= opt
+ 2;
2265 parent_dir
= opt
+ 2;
2268 if (opt
[2]) makefile_name
= opt
+ 2;
2271 parse_makefile_mode
= 1;
2274 relative_dir_mode
= 1;
2277 if (opt
[2]) Separator
= opt
+ 2;
2278 else Separator
= NULL
;
2281 break; /* ignored */
2283 fprintf( stderr
, "Unknown option '%s'\n%s", opt
, Usage
);
2290 /*******************************************************************
2293 int main( int argc
, char *argv
[] )
2295 const char *makeflags
= getenv( "MAKEFLAGS" );
2296 struct incl_file
*pFile
;
2299 if (makeflags
) parse_makeflags( makeflags
);
2304 if (parse_option( argv
[i
] ))
2306 for (j
= i
; j
< argc
; j
++) argv
[j
] = argv
[j
+1];
2312 if (relative_dir_mode
)
2318 fprintf( stderr
, "Option -r needs two directories\n%s", Usage
);
2321 relpath
= get_relative_path( argv
[1], argv
[2] );
2322 printf( "%s\n", relpath
? relpath
: "." );
2326 atexit( cleanup_files
);
2327 signal( SIGTERM
, exit_on_signal
);
2328 signal( SIGINT
, exit_on_signal
);
2330 signal( SIGHUP
, exit_on_signal
);
2333 if (parse_makefile_mode
)
2335 for (i
= 1; i
< argc
; i
++) update_makefile( argv
[i
] );
2340 for (i
= 1; i
< argc
; i
++) add_src_file( argv
[i
] );
2341 add_generated_sources();
2343 LIST_FOR_EACH_ENTRY( pFile
, &includes
, struct incl_file
, entry
) parse_file( pFile
, 0 );
2344 output_dependencies( makefile_name
);