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"
40 INCL_NORMAL
, /* #include "foo.h" */
41 INCL_SYSTEM
, /* #include <foo.h> */
42 INCL_IMPORT
, /* idl import "foo.idl" */
43 INCL_IMPORTLIB
, /* idl importlib "foo.tlb" */
44 INCL_CPP_QUOTE
, /* idl cpp_quote("#include \"foo.h\"") */
45 INCL_CPP_QUOTE_SYSTEM
/* idl cpp_quote("#include <foo.h>") */
50 int line
; /* source line where this header is included */
51 enum incl_type type
; /* type of include */
52 char *name
; /* header name */
58 char *name
; /* full file name relative to cwd */
59 void *args
; /* custom arguments for makefile rule */
60 unsigned int flags
; /* flags (see below) */
61 unsigned int deps_count
; /* files in use */
62 unsigned int deps_size
; /* total allocated size */
63 struct dependency
*deps
; /* all header dependencies */
72 char *sourcename
; /* source file name for generated headers */
73 struct incl_file
*included_by
; /* file that included this one */
74 int included_line
; /* line where this file was included */
75 enum incl_type type
; /* type of include */
76 struct incl_file
*owner
;
77 unsigned int files_count
; /* files in use */
78 unsigned int files_size
; /* total allocated size */
79 struct incl_file
**files
;
82 #define FLAG_GENERATED 0x000001 /* generated file */
83 #define FLAG_INSTALL 0x000002 /* file to install */
84 #define FLAG_IDL_PROXY 0x000100 /* generates a proxy (_p.c) file */
85 #define FLAG_IDL_CLIENT 0x000200 /* generates a client (_c.c) file */
86 #define FLAG_IDL_SERVER 0x000400 /* generates a server (_s.c) file */
87 #define FLAG_IDL_IDENT 0x000800 /* generates an ident (_i.c) file */
88 #define FLAG_IDL_REGISTER 0x001000 /* generates a registration (_r.res) file */
89 #define FLAG_IDL_TYPELIB 0x002000 /* generates a typelib (.tlb) file */
90 #define FLAG_IDL_REGTYPELIB 0x004000 /* generates a registered typelib (_t.res) file */
91 #define FLAG_IDL_HEADER 0x008000 /* generates a header (.h) file */
92 #define FLAG_RC_PO 0x010000 /* rc file contains translations */
93 #define FLAG_C_IMPLIB 0x020000 /* file is part of an import library */
94 #define FLAG_SFD_FONTS 0x040000 /* sfd file generated bitmap fonts */
102 { FLAG_IDL_TYPELIB
, ".tlb" },
103 { FLAG_IDL_REGTYPELIB
, "_t.res" },
104 { FLAG_IDL_CLIENT
, "_c.c" },
105 { FLAG_IDL_IDENT
, "_i.c" },
106 { FLAG_IDL_PROXY
, "_p.c" },
107 { FLAG_IDL_SERVER
, "_s.c" },
108 { FLAG_IDL_REGISTER
, "_r.res" },
109 { FLAG_IDL_HEADER
, ".h" }
112 #define HASH_SIZE 137
114 static struct list files
[HASH_SIZE
];
118 unsigned int count
; /* strings in use */
119 unsigned int size
; /* total allocated size */
123 static const struct strarray empty_strarray
;
125 enum install_rules
{ INSTALL_LIB
, INSTALL_DEV
, NB_INSTALL_RULES
};
127 /* variables common to all makefiles */
128 static struct strarray linguas
;
129 static struct strarray dll_flags
;
130 static struct strarray target_flags
;
131 static struct strarray msvcrt_flags
;
132 static struct strarray extra_cflags
;
133 static struct strarray cpp_flags
;
134 static struct strarray unwind_flags
;
135 static struct strarray libs
;
136 static struct strarray cmdline_vars
;
137 static const char *root_src_dir
;
138 static const char *tools_dir
;
139 static const char *tools_ext
;
140 static const char *exe_ext
;
141 static const char *dll_ext
;
142 static const char *man_ext
;
143 static const char *crosstarget
;
144 static const char *fontforge
;
145 static const char *convert
;
146 static const char *rsvg
;
147 static const char *icotool
;
148 static const char *dlltool
;
149 static const char *msgfmt
;
150 static const char *ln_s
;
154 struct strarray vars
;
155 struct strarray include_paths
;
156 struct strarray define_args
;
157 struct strarray programs
;
158 struct strarray scripts
;
159 struct strarray appmode
;
160 struct strarray imports
;
161 struct strarray subdirs
;
162 struct strarray delayimports
;
163 struct strarray extradllflags
;
164 struct strarray install_lib
;
165 struct strarray install_dev
;
167 struct list includes
;
168 const char *base_dir
;
171 const char *top_src_dir
;
172 const char *top_obj_dir
;
173 const char *parent_dir
;
176 const char *sharedlib
;
177 const char *staticlib
;
178 const char *staticimplib
;
179 const char *importlib
;
182 struct makefile
**submakes
;
185 static struct makefile
*top_makefile
;
187 static const char separator
[] = "### Dependencies";
188 static const char *output_makefile_name
= "Makefile";
189 static const char *input_file_name
;
190 static const char *output_file_name
;
191 static const char *temp_file_name
;
192 static int relative_dir_mode
;
193 static int input_line
;
194 static int output_column
;
195 static FILE *output_file
;
197 static const char Usage
[] =
198 "Usage: makedep [options] [directories]\n"
200 " -R from to Compute the relative path between two directories\n"
201 " -fxxx Store output in file 'xxx' (default: Makefile)\n";
205 #define __attribute__(x)
208 static void fatal_error( const char *msg
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
209 static void fatal_perror( const char *msg
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
210 static void output( const char *format
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
211 static char *strmake( const char* fmt
, ... ) __attribute__ ((__format__ (__printf__
, 1, 2)));
213 /*******************************************************************
216 static void fatal_error( const char *msg
, ... )
219 va_start( valist
, msg
);
222 fprintf( stderr
, "%s:", input_file_name
);
223 if (input_line
) fprintf( stderr
, "%d:", input_line
);
224 fprintf( stderr
, " error: " );
226 else fprintf( stderr
, "makedep: error: " );
227 vfprintf( stderr
, msg
, valist
);
233 /*******************************************************************
236 static void fatal_perror( const char *msg
, ... )
239 va_start( valist
, msg
);
242 fprintf( stderr
, "%s:", input_file_name
);
243 if (input_line
) fprintf( stderr
, "%d:", input_line
);
244 fprintf( stderr
, " error: " );
246 else fprintf( stderr
, "makedep: error: " );
247 vfprintf( stderr
, msg
, valist
);
254 /*******************************************************************
257 static void cleanup_files(void)
259 if (temp_file_name
) unlink( temp_file_name
);
260 if (output_file_name
) unlink( output_file_name
);
264 /*******************************************************************
267 static void exit_on_signal( int sig
)
269 exit( 1 ); /* this will call the atexit functions */
273 /*******************************************************************
276 static void *xmalloc( size_t size
)
279 if (!(res
= malloc (size
? size
: 1)))
280 fatal_error( "Virtual memory exhausted.\n" );
285 /*******************************************************************
288 static void *xrealloc (void *ptr
, size_t size
)
292 if (!(res
= realloc( ptr
, size
)))
293 fatal_error( "Virtual memory exhausted.\n" );
297 /*******************************************************************
300 static char *xstrdup( const char *str
)
302 char *res
= strdup( str
);
303 if (!res
) fatal_error( "Virtual memory exhausted.\n" );
308 /*******************************************************************
311 static char *strmake( const char* fmt
, ... )
319 char *p
= xmalloc (size
);
321 n
= vsnprintf (p
, size
, fmt
, ap
);
323 if (n
== -1) size
*= 2;
324 else if ((size_t)n
>= size
) size
= n
+ 1;
325 else return xrealloc( p
, n
+ 1 );
331 /*******************************************************************
334 static int strendswith( const char* str
, const char* end
)
336 size_t l
= strlen( str
);
337 size_t m
= strlen( end
);
339 return l
>= m
&& strcmp(str
+ l
- m
, end
) == 0;
343 /*******************************************************************
346 static void output( const char *format
, ... )
351 va_start( valist
, format
);
352 ret
= vfprintf( output_file
, format
, valist
);
354 if (ret
< 0) fatal_perror( "output" );
355 if (format
[0] && format
[strlen(format
) - 1] == '\n') output_column
= 0;
356 else output_column
+= ret
;
360 /*******************************************************************
363 static void strarray_add( struct strarray
*array
, const char *str
)
365 if (array
->count
== array
->size
)
367 if (array
->size
) array
->size
*= 2;
368 else array
->size
= 16;
369 array
->str
= xrealloc( array
->str
, sizeof(array
->str
[0]) * array
->size
);
371 array
->str
[array
->count
++] = str
;
375 /*******************************************************************
378 static void strarray_addall( struct strarray
*array
, struct strarray added
)
382 for (i
= 0; i
< added
.count
; i
++) strarray_add( array
, added
.str
[i
] );
386 /*******************************************************************
389 static int strarray_exists( const struct strarray
*array
, const char *str
)
393 for (i
= 0; i
< array
->count
; i
++) if (!strcmp( array
->str
[i
], str
)) return 1;
398 /*******************************************************************
401 static void strarray_add_uniq( struct strarray
*array
, const char *str
)
403 if (!strarray_exists( array
, str
)) strarray_add( array
, str
);
407 /*******************************************************************
410 * Find a value in a name/value pair string array.
412 static const char *strarray_get_value( const struct strarray
*array
, const char *name
)
416 for (i
= 0; i
< array
->count
; i
+= 2)
417 if (!strcmp( array
->str
[i
], name
)) return array
->str
[i
+ 1];
422 /*******************************************************************
425 * Define a value in a name/value pair string array.
427 static void strarray_set_value( struct strarray
*array
, const char *name
, const char *value
)
431 /* redefining a variable replaces the previous value */
432 for (i
= 0; i
< array
->count
; i
+= 2)
434 if (strcmp( array
->str
[i
], name
)) continue;
435 array
->str
[i
+ 1] = value
;
438 strarray_add( array
, name
);
439 strarray_add( array
, value
);
443 /*******************************************************************
446 static void output_filename( const char *name
)
448 if (output_column
+ strlen(name
) + 1 > 100)
453 else if (output_column
) output( " " );
454 output( "%s", name
);
458 /*******************************************************************
461 static void output_filenames( struct strarray array
)
465 for (i
= 0; i
< array
.count
; i
++) output_filename( array
.str
[i
] );
469 /*******************************************************************
472 static char *get_extension( char *filename
)
474 char *ext
= strrchr( filename
, '.' );
475 if (ext
&& strchr( ext
, '/' )) ext
= NULL
;
480 /*******************************************************************
483 static char *replace_extension( const char *name
, const char *old_ext
, const char *new_ext
)
486 size_t name_len
= strlen( name
);
487 size_t ext_len
= strlen( old_ext
);
489 if (name_len
>= ext_len
&& !strcmp( name
+ name_len
- ext_len
, old_ext
)) name_len
-= ext_len
;
490 ret
= xmalloc( name_len
+ strlen( new_ext
) + 1 );
491 memcpy( ret
, name
, name_len
);
492 strcpy( ret
+ name_len
, new_ext
);
497 /*******************************************************************
500 static char *replace_filename( const char *path
, const char *name
)
506 if (!path
) return xstrdup( name
);
507 if (!(p
= strrchr( path
, '/' ))) return xstrdup( name
);
509 ret
= xmalloc( len
+ strlen( name
) + 1 );
510 memcpy( ret
, path
, len
);
511 strcpy( ret
+ len
, name
);
516 /*******************************************************************
517 * strarray_replace_extension
519 static struct strarray
strarray_replace_extension( const struct strarray
*array
,
520 const char *old_ext
, const char *new_ext
)
525 ret
.count
= ret
.size
= array
->count
;
526 ret
.str
= xmalloc( sizeof(ret
.str
[0]) * ret
.size
);
527 for (i
= 0; i
< array
->count
; i
++) ret
.str
[i
] = replace_extension( array
->str
[i
], old_ext
, new_ext
);
532 /*******************************************************************
535 static char *replace_substr( const char *str
, const char *start
, size_t len
, const char *replace
)
537 size_t pos
= start
- str
;
538 char *ret
= xmalloc( pos
+ strlen(replace
) + strlen(start
+ len
) + 1 );
539 memcpy( ret
, str
, pos
);
540 strcpy( ret
+ pos
, replace
);
541 strcat( ret
+ pos
, start
+ len
);
546 /*******************************************************************
549 * Determine where the destination path is located relative to the 'from' path.
551 static char *get_relative_path( const char *from
, const char *dest
)
555 unsigned int dotdots
= 0;
557 /* a path of "." is equivalent to an empty path */
558 if (!strcmp( from
, "." )) from
= "";
562 while (*from
== '/') from
++;
563 while (*dest
== '/') dest
++;
564 start
= dest
; /* save start of next path element */
567 while (*from
&& *from
!= '/' && *from
== *dest
) { from
++; dest
++; }
568 if ((!*from
|| *from
== '/') && (!*dest
|| *dest
== '/')) continue;
570 /* count remaining elements in 'from' */
574 while (*from
&& *from
!= '/') from
++;
575 while (*from
== '/') from
++;
581 if (!start
[0] && !dotdots
) return NULL
; /* empty path */
583 ret
= xmalloc( 3 * dotdots
+ strlen( start
) + 1 );
584 for (p
= ret
; dotdots
; dotdots
--, p
+= 3) memcpy( p
, "../", 3 );
586 if (start
[0]) strcpy( p
, start
);
587 else p
[-1] = 0; /* remove trailing slash */
592 /*******************************************************************
595 static char *concat_paths( const char *base
, const char *path
)
597 if (!base
|| !base
[0]) return xstrdup( path
&& path
[0] ? path
: "." );
598 if (!path
|| !path
[0]) return xstrdup( base
);
599 if (path
[0] == '/') return xstrdup( path
);
600 return strmake( "%s/%s", base
, path
);
604 /*******************************************************************
607 static char *base_dir_path( const struct makefile
*make
, const char *path
)
609 return concat_paths( make
->base_dir
, path
);
613 /*******************************************************************
616 static char *obj_dir_path( const struct makefile
*make
, const char *path
)
618 return concat_paths( make
->obj_dir
, path
);
622 /*******************************************************************
625 static char *src_dir_path( const struct makefile
*make
, const char *path
)
627 if (make
->src_dir
) return concat_paths( make
->src_dir
, path
);
628 return obj_dir_path( make
, path
);
632 /*******************************************************************
635 static char *top_obj_dir_path( const struct makefile
*make
, const char *path
)
637 return concat_paths( make
->top_obj_dir
, path
);
641 /*******************************************************************
644 static char *top_dir_path( const struct makefile
*make
, const char *path
)
646 if (make
->top_src_dir
) return concat_paths( make
->top_src_dir
, path
);
647 return top_obj_dir_path( make
, path
);
651 /*******************************************************************
654 static char *root_dir_path( const char *path
)
656 return concat_paths( root_src_dir
, path
);
660 /*******************************************************************
663 static char *tools_dir_path( const struct makefile
*make
, const char *path
)
665 if (tools_dir
) return top_obj_dir_path( make
, strmake( "%s/tools/%s", tools_dir
, path
));
666 return top_obj_dir_path( make
, strmake( "tools/%s", path
));
670 /*******************************************************************
673 static char *tools_path( const struct makefile
*make
, const char *name
)
675 return strmake( "%s/%s%s", tools_dir_path( make
, name
), name
, tools_ext
);
679 /*******************************************************************
682 static char *get_line( FILE *file
)
690 buffer
= xmalloc( size
);
692 if (!fgets( buffer
, size
, file
)) return NULL
;
697 char *p
= buffer
+ strlen(buffer
);
698 /* if line is larger than buffer, resize buffer */
699 while (p
== buffer
+ size
- 1 && p
[-1] != '\n')
701 buffer
= xrealloc( buffer
, size
* 2 );
702 if (!fgets( buffer
+ size
- 1, size
+ 1, file
)) break;
703 p
= buffer
+ strlen(buffer
);
706 if (p
> buffer
&& p
[-1] == '\n')
709 if (p
> buffer
&& p
[-1] == '\r') *(--p
) = 0;
710 if (p
> buffer
&& p
[-1] == '\\')
713 /* line ends in backslash, read continuation line */
714 if (!fgets( p
, size
- (p
- buffer
), file
)) return buffer
;
724 /*******************************************************************
727 static unsigned int hash_filename( const char *name
)
729 unsigned int ret
= 0;
730 while (*name
) ret
= (ret
<< 7) + (ret
<< 3) + *name
++;
731 return ret
% HASH_SIZE
;
735 /*******************************************************************
738 static struct file
*add_file( const char *name
)
740 struct file
*file
= xmalloc( sizeof(*file
) );
741 memset( file
, 0, sizeof(*file
) );
742 file
->name
= xstrdup( name
);
743 list_add_tail( &files
[hash_filename( name
)], &file
->entry
);
748 /*******************************************************************
751 static void add_dependency( struct file
*file
, const char *name
, enum incl_type type
)
753 /* enforce some rules for the Wine tree */
755 if (!memcmp( name
, "../", 3 ))
756 fatal_error( "#include directive with relative path not allowed\n" );
758 if (!strcmp( name
, "config.h" ))
760 if (strendswith( file
->name
, ".h" ))
761 fatal_error( "config.h must not be included by a header file\n" );
762 if (file
->deps_count
)
763 fatal_error( "config.h must be included before anything else\n" );
765 else if (!strcmp( name
, "wine/port.h" ))
767 if (strendswith( file
->name
, ".h" ))
768 fatal_error( "wine/port.h must not be included by a header file\n" );
769 if (!file
->deps_count
) fatal_error( "config.h must be included before wine/port.h\n" );
770 if (file
->deps_count
> 1)
771 fatal_error( "wine/port.h must be included before everything except config.h\n" );
772 if (strcmp( file
->deps
[0].name
, "config.h" ))
773 fatal_error( "config.h must be included before wine/port.h\n" );
776 if (file
->deps_count
>= file
->deps_size
)
778 file
->deps_size
*= 2;
779 if (file
->deps_size
< 16) file
->deps_size
= 16;
780 file
->deps
= xrealloc( file
->deps
, file
->deps_size
* sizeof(*file
->deps
) );
782 file
->deps
[file
->deps_count
].line
= input_line
;
783 file
->deps
[file
->deps_count
].type
= type
;
784 file
->deps
[file
->deps_count
].name
= xstrdup( name
);
789 /*******************************************************************
792 static struct incl_file
*find_src_file( const struct makefile
*make
, const char *name
)
794 struct incl_file
*file
;
796 LIST_FOR_EACH_ENTRY( file
, &make
->sources
, struct incl_file
, entry
)
797 if (!strcmp( name
, file
->name
)) return file
;
801 /*******************************************************************
804 static struct incl_file
*find_include_file( const struct makefile
*make
, const char *name
)
806 struct incl_file
*file
;
808 LIST_FOR_EACH_ENTRY( file
, &make
->includes
, struct incl_file
, entry
)
809 if (!strcmp( name
, file
->name
)) return file
;
813 /*******************************************************************
816 * Add an include file if it doesn't already exists.
818 static struct incl_file
*add_include( struct makefile
*make
, struct incl_file
*parent
,
819 const char *name
, int line
, enum incl_type type
)
821 struct incl_file
*include
;
823 if (parent
->files_count
>= parent
->files_size
)
825 parent
->files_size
*= 2;
826 if (parent
->files_size
< 16) parent
->files_size
= 16;
827 parent
->files
= xrealloc( parent
->files
, parent
->files_size
* sizeof(*parent
->files
) );
830 LIST_FOR_EACH_ENTRY( include
, &make
->includes
, struct incl_file
, entry
)
831 if (!strcmp( name
, include
->name
)) goto found
;
833 include
= xmalloc( sizeof(*include
) );
834 memset( include
, 0, sizeof(*include
) );
835 include
->name
= xstrdup(name
);
836 include
->included_by
= parent
;
837 include
->included_line
= line
;
838 include
->type
= type
;
839 list_add_tail( &make
->includes
, &include
->entry
);
841 parent
->files
[parent
->files_count
++] = include
;
846 /*******************************************************************
847 * add_generated_source
849 * Add a generated source file to the list.
851 static struct incl_file
*add_generated_source( struct makefile
*make
,
852 const char *name
, const char *filename
)
854 struct incl_file
*file
;
856 if ((file
= find_src_file( make
, name
))) return file
; /* we already have it */
857 file
= xmalloc( sizeof(*file
) );
858 memset( file
, 0, sizeof(*file
) );
859 file
->file
= add_file( name
);
860 file
->name
= xstrdup( name
);
861 file
->filename
= obj_dir_path( make
, filename
? filename
: name
);
862 file
->file
->flags
= FLAG_GENERATED
;
863 list_add_tail( &make
->sources
, &file
->entry
);
868 /*******************************************************************
869 * parse_include_directive
871 static void parse_include_directive( struct file
*source
, char *str
)
873 char quote
, *include
, *p
= str
;
875 while (*p
&& isspace(*p
)) p
++;
876 if (*p
!= '\"' && *p
!= '<' ) return;
878 if (quote
== '<') quote
= '>';
880 while (*p
&& (*p
!= quote
)) p
++;
881 if (!*p
) fatal_error( "malformed include directive '%s'\n", str
);
883 add_dependency( source
, include
, (quote
== '>') ? INCL_SYSTEM
: INCL_NORMAL
);
887 /*******************************************************************
888 * parse_pragma_directive
890 static void parse_pragma_directive( struct file
*source
, char *str
)
892 char *flag
, *p
= str
;
894 if (!isspace( *p
)) return;
895 while (*p
&& isspace(*p
)) p
++;
896 p
= strtok( p
, " \t" );
897 if (strcmp( p
, "makedep" )) return;
899 while ((flag
= strtok( NULL
, " \t" )))
901 if (!strcmp( flag
, "depend" ))
903 while ((p
= strtok( NULL
, " \t" ))) add_dependency( source
, p
, INCL_NORMAL
);
906 else if (!strcmp( flag
, "install" )) source
->flags
|= FLAG_INSTALL
;
908 if (strendswith( source
->name
, ".idl" ))
910 if (!strcmp( flag
, "header" )) source
->flags
|= FLAG_IDL_HEADER
;
911 else if (!strcmp( flag
, "proxy" )) source
->flags
|= FLAG_IDL_PROXY
;
912 else if (!strcmp( flag
, "client" )) source
->flags
|= FLAG_IDL_CLIENT
;
913 else if (!strcmp( flag
, "server" )) source
->flags
|= FLAG_IDL_SERVER
;
914 else if (!strcmp( flag
, "ident" )) source
->flags
|= FLAG_IDL_IDENT
;
915 else if (!strcmp( flag
, "typelib" )) source
->flags
|= FLAG_IDL_TYPELIB
;
916 else if (!strcmp( flag
, "register" )) source
->flags
|= FLAG_IDL_REGISTER
;
917 else if (!strcmp( flag
, "regtypelib" )) source
->flags
|= FLAG_IDL_REGTYPELIB
;
919 else if (strendswith( source
->name
, ".rc" ))
921 if (!strcmp( flag
, "po" )) source
->flags
|= FLAG_RC_PO
;
923 else if (strendswith( source
->name
, ".sfd" ))
925 if (!strcmp( flag
, "font" ))
927 struct strarray
*array
= source
->args
;
931 source
->args
= array
= xmalloc( sizeof(*array
) );
932 *array
= empty_strarray
;
933 source
->flags
|= FLAG_SFD_FONTS
;
935 strarray_add( array
, xstrdup( strtok( NULL
, "" )));
939 else if (!strcmp( flag
, "implib" )) source
->flags
|= FLAG_C_IMPLIB
;
944 /*******************************************************************
945 * parse_cpp_directive
947 static void parse_cpp_directive( struct file
*source
, char *str
)
949 while (*str
&& isspace(*str
)) str
++;
950 if (*str
++ != '#') return;
951 while (*str
&& isspace(*str
)) str
++;
953 if (!strncmp( str
, "include", 7 ))
954 parse_include_directive( source
, str
+ 7 );
955 else if (!strncmp( str
, "import", 6 ) && strendswith( source
->name
, ".m" ))
956 parse_include_directive( source
, str
+ 6 );
957 else if (!strncmp( str
, "pragma", 6 ))
958 parse_pragma_directive( source
, str
+ 6 );
962 /*******************************************************************
965 static void parse_idl_file( struct file
*source
, FILE *file
)
967 char *buffer
, *include
;
971 while ((buffer
= get_line( file
)))
975 while (*p
&& isspace(*p
)) p
++;
977 if (!strncmp( p
, "importlib", 9 ))
980 while (*p
&& isspace(*p
)) p
++;
981 if (*p
++ != '(') continue;
982 while (*p
&& isspace(*p
)) p
++;
983 if (*p
++ != '"') continue;
985 while (*p
&& (*p
!= '"')) p
++;
986 if (!*p
) fatal_error( "malformed importlib directive\n" );
988 add_dependency( source
, include
, INCL_IMPORTLIB
);
992 if (!strncmp( p
, "import", 6 ))
995 while (*p
&& isspace(*p
)) p
++;
996 if (*p
!= '"') continue;
998 while (*p
&& (*p
!= '"')) p
++;
999 if (!*p
) fatal_error( "malformed import directive\n" );
1001 add_dependency( source
, include
, INCL_IMPORT
);
1005 /* check for #include inside cpp_quote */
1006 if (!strncmp( p
, "cpp_quote", 9 ))
1009 while (*p
&& isspace(*p
)) p
++;
1010 if (*p
++ != '(') continue;
1011 while (*p
&& isspace(*p
)) p
++;
1012 if (*p
++ != '"') continue;
1013 if (*p
++ != '#') continue;
1014 while (*p
&& isspace(*p
)) p
++;
1015 if (strncmp( p
, "include", 7 )) continue;
1017 while (*p
&& isspace(*p
)) p
++;
1018 if (*p
== '\\' && p
[1] == '"')
1025 if (*p
++ != '<' ) continue;
1029 while (*p
&& (*p
!= quote
)) p
++;
1030 if (!*p
|| (quote
== '"' && p
[-1] != '\\'))
1031 fatal_error( "malformed #include directive inside cpp_quote\n" );
1032 if (quote
== '"') p
--; /* remove backslash */
1034 add_dependency( source
, include
, (quote
== '>') ? INCL_CPP_QUOTE_SYSTEM
: INCL_CPP_QUOTE
);
1038 parse_cpp_directive( source
, p
);
1042 /*******************************************************************
1045 static void parse_c_file( struct file
*source
, FILE *file
)
1050 while ((buffer
= get_line( file
)))
1052 parse_cpp_directive( source
, buffer
);
1057 /*******************************************************************
1060 static void parse_rc_file( struct file
*source
, FILE *file
)
1062 char *buffer
, *include
;
1065 while ((buffer
= get_line( file
)))
1069 while (*p
&& isspace(*p
)) p
++;
1071 if (p
[0] == '/' && p
[1] == '*') /* check for magic makedep comment */
1074 while (*p
&& isspace(*p
)) p
++;
1075 if (strncmp( p
, "@makedep:", 9 )) continue;
1077 while (*p
&& isspace(*p
)) p
++;
1082 while (*p
&& *p
!= quote
) p
++;
1087 while (*p
&& !isspace(*p
) && *p
!= '*') p
++;
1090 fatal_error( "malformed makedep comment\n" );
1092 add_dependency( source
, include
, (quote
== '>') ? INCL_SYSTEM
: INCL_NORMAL
);
1096 parse_cpp_directive( source
, buffer
);
1101 /*******************************************************************
1104 static void parse_in_file( struct file
*source
, FILE *file
)
1108 /* make sure it gets rebuilt when the version changes */
1109 add_dependency( source
, "config.h", INCL_SYSTEM
);
1111 if (!strendswith( source
->name
, ".man.in" )) return; /* not a man page */
1114 while ((buffer
= get_line( file
)))
1116 if (strncmp( buffer
, ".TH", 3 )) continue;
1117 if (!(p
= strtok( buffer
, " \t" ))) continue; /* .TH */
1118 if (!(p
= strtok( NULL
, " \t" ))) continue; /* program name */
1119 if (!(p
= strtok( NULL
, " \t" ))) continue; /* man section */
1120 source
->args
= xstrdup( p
);
1126 /*******************************************************************
1129 static void parse_sfd_file( struct file
*source
, FILE *file
)
1131 char *p
, *eol
, *buffer
;
1134 while ((buffer
= get_line( file
)))
1136 if (strncmp( buffer
, "UComments:", 10 )) continue;
1138 while (*p
== ' ') p
++;
1139 if (p
[0] == '"' && p
[1] && buffer
[strlen(buffer
) - 1] == '"')
1142 buffer
[strlen(buffer
) - 1] = 0;
1144 while ((eol
= strstr( p
, "+AAoA" )))
1147 while (*p
&& isspace(*p
)) p
++;
1150 while (*p
&& isspace(*p
)) p
++;
1151 if (!strncmp( p
, "pragma", 6 )) parse_pragma_directive( source
, p
+ 6 );
1155 while (*p
&& isspace(*p
)) p
++;
1156 if (*p
++ != '#') return;
1157 while (*p
&& isspace(*p
)) p
++;
1158 if (!strncmp( p
, "pragma", 6 )) parse_pragma_directive( source
, p
+ 6 );
1167 void (*parse
)( struct file
*file
, FILE *f
);
1168 } parse_functions
[] =
1170 { ".c", parse_c_file
},
1171 { ".h", parse_c_file
},
1172 { ".inl", parse_c_file
},
1173 { ".l", parse_c_file
},
1174 { ".m", parse_c_file
},
1175 { ".rh", parse_c_file
},
1176 { ".x", parse_c_file
},
1177 { ".y", parse_c_file
},
1178 { ".idl", parse_idl_file
},
1179 { ".rc", parse_rc_file
},
1180 { ".in", parse_in_file
},
1181 { ".sfd", parse_sfd_file
}
1184 /*******************************************************************
1187 static struct file
*load_file( const char *name
)
1191 unsigned int i
, hash
= hash_filename( name
);
1193 LIST_FOR_EACH_ENTRY( file
, &files
[hash
], struct file
, entry
)
1194 if (!strcmp( name
, file
->name
)) return file
;
1196 if (!(f
= fopen( name
, "r" ))) return NULL
;
1198 file
= add_file( name
);
1199 input_file_name
= file
->name
;
1202 for (i
= 0; i
< sizeof(parse_functions
) / sizeof(parse_functions
[0]); i
++)
1204 if (!strendswith( name
, parse_functions
[i
].ext
)) continue;
1205 parse_functions
[i
].parse( file
, f
);
1210 input_file_name
= NULL
;
1216 /*******************************************************************
1217 * open_include_path_file
1219 * Open a file from a directory on the include path.
1221 static struct file
*open_include_path_file( const struct makefile
*make
, const char *dir
,
1222 const char *name
, char **filename
)
1224 char *src_path
= base_dir_path( make
, concat_paths( dir
, name
));
1225 struct file
*ret
= load_file( src_path
);
1227 if (ret
) *filename
= src_dir_path( make
, concat_paths( dir
, name
));
1232 /*******************************************************************
1233 * open_file_same_dir
1235 * Open a file in the same directory as the parent.
1237 static struct file
*open_file_same_dir( const struct incl_file
*parent
, const char *name
, char **filename
)
1239 char *src_path
= replace_filename( parent
->file
->name
, name
);
1240 struct file
*ret
= load_file( src_path
);
1242 if (ret
) *filename
= replace_filename( parent
->filename
, name
);
1248 /*******************************************************************
1251 * Open a file in the source directory of the makefile.
1253 static struct file
*open_local_file( const struct makefile
*make
, const char *path
, char **filename
)
1255 char *src_path
= root_dir_path( base_dir_path( make
, path
));
1256 struct file
*ret
= load_file( src_path
);
1258 /* if not found, try parent dir */
1259 if (!ret
&& make
->parent_dir
)
1262 path
= strmake( "%s/%s", make
->parent_dir
, path
);
1263 src_path
= root_dir_path( base_dir_path( make
, path
));
1264 ret
= load_file( src_path
);
1267 if (ret
) *filename
= src_dir_path( make
, path
);
1273 /*******************************************************************
1276 * Open a file in the top-level source directory.
1278 static struct file
*open_global_file( const struct makefile
*make
, const char *path
, char **filename
)
1280 char *src_path
= root_dir_path( path
);
1281 struct file
*ret
= load_file( src_path
);
1283 if (ret
) *filename
= top_dir_path( make
, path
);
1289 /*******************************************************************
1290 * open_global_header
1292 * Open a file in the global include source directory.
1294 static struct file
*open_global_header( const struct makefile
*make
, const char *path
, char **filename
)
1296 return open_global_file( make
, strmake( "include/%s", path
), filename
);
1300 /*******************************************************************
1303 static struct file
*open_src_file( const struct makefile
*make
, struct incl_file
*pFile
)
1305 struct file
*file
= open_local_file( make
, pFile
->name
, &pFile
->filename
);
1307 if (!file
) fatal_perror( "open %s", pFile
->name
);
1312 /*******************************************************************
1315 static struct file
*open_include_file( const struct makefile
*make
, struct incl_file
*pFile
)
1317 struct file
*file
= NULL
;
1319 unsigned int i
, len
;
1323 /* check for generated bison header */
1325 if (strendswith( pFile
->name
, ".tab.h" ) &&
1326 (file
= open_local_file( make
, replace_extension( pFile
->name
, ".tab.h", ".y" ), &filename
)))
1328 pFile
->sourcename
= filename
;
1329 pFile
->filename
= obj_dir_path( make
, pFile
->name
);
1333 /* check for corresponding idl file in source dir */
1335 if (strendswith( pFile
->name
, ".h" ) &&
1336 (file
= open_local_file( make
, replace_extension( pFile
->name
, ".h", ".idl" ), &filename
)))
1338 pFile
->sourcename
= filename
;
1339 pFile
->filename
= obj_dir_path( make
, pFile
->name
);
1343 /* check for corresponding tlb file in source dir */
1345 if (strendswith( pFile
->name
, ".tlb" ) &&
1346 (file
= open_local_file( make
, replace_extension( pFile
->name
, ".tlb", ".idl" ), &filename
)))
1348 pFile
->sourcename
= filename
;
1349 pFile
->filename
= obj_dir_path( make
, pFile
->name
);
1353 /* now try in source dir */
1354 if ((file
= open_local_file( make
, pFile
->name
, &pFile
->filename
))) return file
;
1356 /* check for corresponding idl file in global includes */
1358 if (strendswith( pFile
->name
, ".h" ) &&
1359 (file
= open_global_header( make
, replace_extension( pFile
->name
, ".h", ".idl" ), &filename
)))
1361 pFile
->sourcename
= filename
;
1362 pFile
->filename
= top_obj_dir_path( make
, strmake( "include/%s", pFile
->name
));
1366 /* check for corresponding .in file in global includes (for config.h.in) */
1368 if (strendswith( pFile
->name
, ".h" ) &&
1369 (file
= open_global_header( make
, replace_extension( pFile
->name
, ".h", ".h.in" ), &filename
)))
1371 pFile
->sourcename
= filename
;
1372 pFile
->filename
= top_obj_dir_path( make
, strmake( "include/%s", pFile
->name
));
1376 /* check for corresponding .x file in global includes */
1378 if (strendswith( pFile
->name
, "tmpl.h" ) &&
1379 (file
= open_global_header( make
, replace_extension( pFile
->name
, ".h", ".x" ), &filename
)))
1381 pFile
->sourcename
= filename
;
1382 pFile
->filename
= top_obj_dir_path( make
, strmake( "include/%s", pFile
->name
));
1386 /* check for corresponding .tlb file in global includes */
1388 if (strendswith( pFile
->name
, ".tlb" ) &&
1389 (file
= open_global_header( make
, replace_extension( pFile
->name
, ".tlb", ".idl" ), &filename
)))
1391 pFile
->sourcename
= filename
;
1392 pFile
->filename
= top_obj_dir_path( make
, strmake( "include/%s", pFile
->name
));
1396 /* check in global includes source dir */
1398 if ((file
= open_global_header( make
, pFile
->name
, &pFile
->filename
))) return file
;
1400 /* check in global msvcrt includes */
1401 if (make
->use_msvcrt
&&
1402 (file
= open_global_header( make
, strmake( "msvcrt/%s", pFile
->name
), &pFile
->filename
)))
1405 /* now search in include paths */
1406 for (i
= 0; i
< make
->include_paths
.count
; i
++)
1408 const char *dir
= make
->include_paths
.str
[i
];
1409 const char *prefix
= make
->top_src_dir
? make
->top_src_dir
: make
->top_obj_dir
;
1413 len
= strlen( prefix
);
1414 if (!strncmp( dir
, prefix
, len
) && (!dir
[len
] || dir
[len
] == '/'))
1416 while (dir
[len
] == '/') len
++;
1417 file
= open_global_file( make
, concat_paths( dir
+ len
, pFile
->name
), &pFile
->filename
);
1418 if (file
) return file
;
1420 if (make
->top_src_dir
) continue; /* ignore paths that don't point to the top source dir */
1424 if ((file
= open_include_path_file( make
, dir
, pFile
->name
, &pFile
->filename
)))
1428 if (pFile
->type
== INCL_SYSTEM
) return NULL
; /* ignore system files we cannot find */
1430 /* try in src file directory */
1431 if ((file
= open_file_same_dir( pFile
->included_by
, pFile
->name
, &pFile
->filename
))) return file
;
1433 fprintf( stderr
, "%s:%d: error: ", pFile
->included_by
->file
->name
, pFile
->included_line
);
1434 perror( pFile
->name
);
1435 pFile
= pFile
->included_by
;
1436 while (pFile
&& pFile
->included_by
)
1438 const char *parent
= pFile
->included_by
->sourcename
;
1439 if (!parent
) parent
= pFile
->included_by
->file
->name
;
1440 fprintf( stderr
, "%s:%d: note: %s was first included here\n",
1441 parent
, pFile
->included_line
, pFile
->name
);
1442 pFile
= pFile
->included_by
;
1448 /*******************************************************************
1451 static void add_all_includes( struct makefile
*make
, struct incl_file
*parent
, struct file
*file
)
1455 parent
->files_count
= 0;
1456 parent
->files_size
= file
->deps_count
;
1457 parent
->files
= xmalloc( parent
->files_size
* sizeof(*parent
->files
) );
1458 for (i
= 0; i
< file
->deps_count
; i
++)
1460 switch (file
->deps
[i
].type
)
1464 add_include( make
, parent
, file
->deps
[i
].name
, file
->deps
[i
].line
, INCL_NORMAL
);
1466 case INCL_IMPORTLIB
:
1467 add_include( make
, parent
, file
->deps
[i
].name
, file
->deps
[i
].line
, INCL_IMPORTLIB
);
1470 add_include( make
, parent
, file
->deps
[i
].name
, file
->deps
[i
].line
, INCL_SYSTEM
);
1472 case INCL_CPP_QUOTE
:
1473 case INCL_CPP_QUOTE_SYSTEM
:
1480 /*******************************************************************
1483 static void parse_file( struct makefile
*make
, struct incl_file
*source
, int src
)
1485 struct file
*file
= src
? open_src_file( make
, source
) : open_include_file( make
, source
);
1489 source
->file
= file
;
1490 source
->files_count
= 0;
1491 source
->files_size
= file
->deps_count
;
1492 source
->files
= xmalloc( source
->files_size
* sizeof(*source
->files
) );
1494 if (source
->sourcename
)
1496 if (strendswith( source
->sourcename
, ".idl" ))
1500 if (strendswith( source
->name
, ".tlb" )) return; /* typelibs don't include anything */
1502 /* generated .h file always includes these */
1503 add_include( make
, source
, "rpc.h", 0, INCL_NORMAL
);
1504 add_include( make
, source
, "rpcndr.h", 0, INCL_NORMAL
);
1505 for (i
= 0; i
< file
->deps_count
; i
++)
1507 switch (file
->deps
[i
].type
)
1510 if (strendswith( file
->deps
[i
].name
, ".idl" ))
1511 add_include( make
, source
, replace_extension( file
->deps
[i
].name
, ".idl", ".h" ),
1512 file
->deps
[i
].line
, INCL_NORMAL
);
1514 add_include( make
, source
, file
->deps
[i
].name
, file
->deps
[i
].line
, INCL_NORMAL
);
1516 case INCL_CPP_QUOTE
:
1517 add_include( make
, source
, file
->deps
[i
].name
, file
->deps
[i
].line
, INCL_NORMAL
);
1519 case INCL_CPP_QUOTE_SYSTEM
:
1520 add_include( make
, source
, file
->deps
[i
].name
, file
->deps
[i
].line
, INCL_SYSTEM
);
1524 case INCL_IMPORTLIB
:
1530 if (strendswith( source
->sourcename
, ".y" ))
1531 return; /* generated .tab.h doesn't include anything */
1534 add_all_includes( make
, source
, file
);
1538 /*******************************************************************
1541 * Add a source file to the list.
1543 static struct incl_file
*add_src_file( struct makefile
*make
, const char *name
)
1545 struct incl_file
*file
;
1547 if ((file
= find_src_file( make
, name
))) return file
; /* we already have it */
1548 file
= xmalloc( sizeof(*file
) );
1549 memset( file
, 0, sizeof(*file
) );
1550 file
->name
= xstrdup(name
);
1551 list_add_tail( &make
->sources
, &file
->entry
);
1552 parse_file( make
, file
, 1 );
1557 /*******************************************************************
1558 * open_input_makefile
1560 static FILE *open_input_makefile( const struct makefile
*make
)
1565 input_file_name
= root_dir_path( base_dir_path( make
, strmake( "%s.in", output_makefile_name
)));
1567 input_file_name
= output_makefile_name
; /* always use output name for main Makefile */
1570 if (!(ret
= fopen( input_file_name
, "r" ))) fatal_perror( "open" );
1575 /*******************************************************************
1578 static const char *get_make_variable( const struct makefile
*make
, const char *name
)
1582 if ((ret
= strarray_get_value( &cmdline_vars
, name
))) return ret
;
1583 if ((ret
= strarray_get_value( &make
->vars
, name
))) return ret
;
1584 if (top_makefile
&& (ret
= strarray_get_value( &top_makefile
->vars
, name
))) return ret
;
1589 /*******************************************************************
1590 * get_expanded_make_variable
1592 static char *get_expanded_make_variable( const struct makefile
*make
, const char *name
)
1595 char *p
, *end
, *expand
, *tmp
;
1597 var
= get_make_variable( make
, name
);
1598 if (!var
) return NULL
;
1600 p
= expand
= xstrdup( var
);
1601 while ((p
= strchr( p
, '$' )))
1605 if (!(end
= strchr( p
+ 2, ')' ))) fatal_error( "syntax error in '%s'\n", expand
);
1607 if (strchr( p
+ 2, ':' )) fatal_error( "pattern replacement not supported for '%s'\n", p
+ 2 );
1608 var
= get_make_variable( make
, p
+ 2 );
1609 tmp
= replace_substr( expand
, p
, end
- p
, var
? var
: "" );
1610 /* switch to the new string */
1611 p
= tmp
+ (p
- expand
);
1615 else if (p
[1] == '{') /* don't expand ${} variables */
1617 if (!(end
= strchr( p
+ 2, '}' ))) fatal_error( "syntax error in '%s'\n", expand
);
1620 else if (p
[1] == '$')
1624 else fatal_error( "syntax error in '%s'\n", expand
);
1627 /* consider empty variables undefined */
1629 while (*p
&& isspace(*p
)) p
++;
1630 if (*p
) return expand
;
1636 /*******************************************************************
1637 * get_expanded_make_var_array
1639 static struct strarray
get_expanded_make_var_array( const struct makefile
*make
, const char *name
)
1641 struct strarray ret
= empty_strarray
;
1642 char *value
, *token
;
1644 if ((value
= get_expanded_make_variable( make
, name
)))
1645 for (token
= strtok( value
, " \t" ); token
; token
= strtok( NULL
, " \t" ))
1646 strarray_add( &ret
, token
);
1651 /*******************************************************************
1652 * get_expanded_file_local_var
1654 static struct strarray
get_expanded_file_local_var( const struct makefile
*make
, const char *file
,
1657 char *p
, *var
= strmake( "%s_%s", file
, name
);
1659 for (p
= var
; *p
; p
++) if (!isalnum( *p
)) *p
= '_';
1660 return get_expanded_make_var_array( make
, var
);
1664 /*******************************************************************
1667 static int set_make_variable( struct strarray
*array
, const char *assignment
)
1671 p
= name
= xstrdup( assignment
);
1672 while (isalnum(*p
) || *p
== '_') p
++;
1673 if (name
== p
) return 0; /* not a variable */
1677 while (isspace(*p
)) p
++;
1679 if (*p
!= '=') return 0; /* not an assignment */
1681 while (isspace(*p
)) p
++;
1683 strarray_set_value( array
, name
, p
);
1688 /*******************************************************************
1691 static struct makefile
*parse_makefile( const char *path
)
1695 struct makefile
*make
= xmalloc( sizeof(*make
) );
1697 memset( make
, 0, sizeof(*make
) );
1700 make
->top_obj_dir
= get_relative_path( path
, "" );
1701 make
->base_dir
= path
;
1702 if (!strcmp( make
->base_dir
, "." )) make
->base_dir
= NULL
;
1705 file
= open_input_makefile( make
);
1706 while ((buffer
= get_line( file
)))
1708 if (!strncmp( buffer
, separator
, strlen(separator
) )) break;
1709 if (*buffer
== '\t') continue; /* command */
1710 while (isspace( *buffer
)) buffer
++;
1711 if (*buffer
== '#') continue; /* comment */
1712 set_make_variable( &make
->vars
, buffer
);
1715 input_file_name
= NULL
;
1720 /*******************************************************************
1721 * add_generated_sources
1723 static void add_generated_sources( struct makefile
*make
)
1725 struct incl_file
*source
, *next
, *file
;
1727 LIST_FOR_EACH_ENTRY_SAFE( source
, next
, &make
->sources
, struct incl_file
, entry
)
1729 if (source
->file
->flags
& FLAG_IDL_CLIENT
)
1731 file
= add_generated_source( make
, replace_extension( source
->name
, ".idl", "_c.c" ), NULL
);
1732 add_dependency( file
->file
, replace_extension( source
->name
, ".idl", ".h" ), INCL_NORMAL
);
1733 add_all_includes( make
, file
, file
->file
);
1735 if (source
->file
->flags
& FLAG_IDL_SERVER
)
1737 file
= add_generated_source( make
, replace_extension( source
->name
, ".idl", "_s.c" ), NULL
);
1738 add_dependency( file
->file
, "wine/exception.h", INCL_NORMAL
);
1739 add_dependency( file
->file
, replace_extension( source
->name
, ".idl", ".h" ), INCL_NORMAL
);
1740 add_all_includes( make
, file
, file
->file
);
1742 if (source
->file
->flags
& FLAG_IDL_IDENT
)
1744 file
= add_generated_source( make
, replace_extension( source
->name
, ".idl", "_i.c" ), NULL
);
1745 add_dependency( file
->file
, "rpc.h", INCL_NORMAL
);
1746 add_dependency( file
->file
, "rpcndr.h", INCL_NORMAL
);
1747 add_dependency( file
->file
, "guiddef.h", INCL_NORMAL
);
1748 add_all_includes( make
, file
, file
->file
);
1750 if (source
->file
->flags
& FLAG_IDL_PROXY
)
1752 file
= add_generated_source( make
, "dlldata.o", "dlldata.c" );
1753 add_dependency( file
->file
, "objbase.h", INCL_NORMAL
);
1754 add_dependency( file
->file
, "rpcproxy.h", INCL_NORMAL
);
1755 add_all_includes( make
, file
, file
->file
);
1756 file
= add_generated_source( make
, replace_extension( source
->name
, ".idl", "_p.c" ), NULL
);
1757 add_dependency( file
->file
, "objbase.h", INCL_NORMAL
);
1758 add_dependency( file
->file
, "rpcproxy.h", INCL_NORMAL
);
1759 add_dependency( file
->file
, "wine/exception.h", INCL_NORMAL
);
1760 add_dependency( file
->file
, replace_extension( source
->name
, ".idl", ".h" ), INCL_NORMAL
);
1761 add_all_includes( make
, file
, file
->file
);
1763 if (source
->file
->flags
& FLAG_IDL_TYPELIB
)
1765 add_generated_source( make
, replace_extension( source
->name
, ".idl", ".tlb" ), NULL
);
1767 if (source
->file
->flags
& FLAG_IDL_REGTYPELIB
)
1769 add_generated_source( make
, replace_extension( source
->name
, ".idl", "_t.res" ), NULL
);
1771 if (source
->file
->flags
& FLAG_IDL_REGISTER
)
1773 add_generated_source( make
, replace_extension( source
->name
, ".idl", "_r.res" ), NULL
);
1775 if (source
->file
->flags
& FLAG_IDL_HEADER
)
1777 add_generated_source( make
, replace_extension( source
->name
, ".idl", ".h" ), NULL
);
1779 if (!source
->file
->flags
&& strendswith( source
->name
, ".idl" ))
1781 add_generated_source( make
, replace_extension( source
->name
, ".idl", ".h" ), NULL
);
1783 if (strendswith( source
->name
, ".x" ))
1785 add_generated_source( make
, replace_extension( source
->name
, ".x", ".h" ), NULL
);
1787 if (strendswith( source
->name
, ".y" ))
1789 file
= add_generated_source( make
, replace_extension( source
->name
, ".y", ".tab.c" ), NULL
);
1790 /* steal the includes list from the source file */
1791 file
->files_count
= source
->files_count
;
1792 file
->files_size
= source
->files_size
;
1793 file
->files
= source
->files
;
1794 source
->files_count
= source
->files_size
= 0;
1795 source
->files
= NULL
;
1797 if (strendswith( source
->name
, ".l" ))
1799 file
= add_generated_source( make
, replace_extension( source
->name
, ".l", ".yy.c" ), NULL
);
1800 /* steal the includes list from the source file */
1801 file
->files_count
= source
->files_count
;
1802 file
->files_size
= source
->files_size
;
1803 file
->files
= source
->files
;
1804 source
->files_count
= source
->files_size
= 0;
1805 source
->files
= NULL
;
1807 if (source
->file
->flags
& FLAG_C_IMPLIB
)
1809 if (!make
->staticimplib
&& make
->importlib
&& *dll_ext
)
1810 make
->staticimplib
= strmake( "lib%s.def.a", make
->importlib
);
1815 file
= add_generated_source( make
, "testlist.o", "testlist.c" );
1816 add_dependency( file
->file
, "wine/test.h", INCL_NORMAL
);
1817 add_all_includes( make
, file
, file
->file
);
1822 /*******************************************************************
1825 static void create_dir( const char *dir
)
1829 p
= path
= xstrdup( dir
);
1830 while ((p
= strchr( p
, '/' )))
1833 if (mkdir( path
, 0755 ) == -1 && errno
!= EEXIST
) fatal_perror( "mkdir %s", path
);
1835 while (*p
== '/') p
++;
1837 if (mkdir( path
, 0755 ) == -1 && errno
!= EEXIST
) fatal_perror( "mkdir %s", path
);
1842 /*******************************************************************
1843 * create_file_directories
1845 * Create the base directories of all the files.
1847 static void create_file_directories( const struct makefile
*make
, struct strarray files
)
1849 struct strarray subdirs
= empty_strarray
;
1853 for (i
= 0; i
< files
.count
; i
++)
1855 if (!strchr( files
.str
[i
], '/' )) continue;
1856 dir
= base_dir_path( make
, files
.str
[i
] );
1857 *strrchr( dir
, '/' ) = 0;
1858 strarray_add_uniq( &subdirs
, dir
);
1861 for (i
= 0; i
< subdirs
.count
; i
++) create_dir( subdirs
.str
[i
] );
1865 /*******************************************************************
1866 * output_filenames_obj_dir
1868 static void output_filenames_obj_dir( const struct makefile
*make
, struct strarray array
)
1872 for (i
= 0; i
< array
.count
; i
++) output_filename( obj_dir_path( make
, array
.str
[i
] ));
1876 /*******************************************************************
1879 static void get_dependencies( struct strarray
*deps
, struct incl_file
*file
, struct incl_file
*source
)
1883 if (!file
->filename
) return;
1887 if (file
->owner
== source
) return; /* already processed */
1888 if (file
->type
== INCL_IMPORTLIB
&&
1889 !(source
->file
->flags
& (FLAG_IDL_TYPELIB
| FLAG_IDL_REGTYPELIB
)))
1890 return; /* library is imported only when building a typelib */
1891 file
->owner
= source
;
1892 strarray_add( deps
, file
->filename
);
1894 for (i
= 0; i
< file
->files_count
; i
++) get_dependencies( deps
, file
->files
[i
], source
);
1898 /*******************************************************************
1899 * get_local_dependencies
1901 * Get the local dependencies of a given target.
1903 static struct strarray
get_local_dependencies( const struct makefile
*make
, const char *name
,
1904 struct strarray targets
)
1907 struct strarray deps
= get_expanded_file_local_var( make
, name
, "DEPS" );
1909 for (i
= 0; i
< deps
.count
; i
++)
1911 if (strarray_exists( &targets
, deps
.str
[i
] ))
1912 deps
.str
[i
] = obj_dir_path( make
, deps
.str
[i
] );
1914 deps
.str
[i
] = src_dir_path( make
, deps
.str
[i
] );
1920 /*******************************************************************
1923 * Check if makefile builds the named static library.
1925 static int has_static_lib( const struct makefile
*make
, const char *name
)
1927 if (!make
->staticlib
) return 0;
1928 if (strncmp( make
->staticlib
, "lib", 3 )) return 0;
1929 if (strncmp( make
->staticlib
+ 3, name
, strlen(name
) )) return 0;
1930 return !strcmp( make
->staticlib
+ 3 + strlen(name
), ".a" );
1934 /*******************************************************************
1935 * add_default_libraries
1937 static struct strarray
add_default_libraries( const struct makefile
*make
, struct strarray
*deps
)
1939 struct strarray ret
= empty_strarray
;
1940 struct strarray all_libs
= empty_strarray
;
1943 strarray_add( &all_libs
, "-lwine_port" );
1944 strarray_addall( &all_libs
, get_expanded_make_var_array( make
, "EXTRALIBS" ));
1945 strarray_addall( &all_libs
, libs
);
1947 for (i
= 0; i
< all_libs
.count
; i
++)
1950 if (!strncmp( all_libs
.str
[i
], "-l", 2 ))
1952 const char *name
= all_libs
.str
[i
] + 2;
1954 for (j
= 0; j
< top_makefile
->subdirs
.count
; j
++)
1956 const struct makefile
*submake
= top_makefile
->submakes
[j
];
1958 if ((found
= has_static_lib( submake
, name
)))
1960 const char *lib
= strmake( "%s/lib%s.a",
1961 top_obj_dir_path( make
, submake
->base_dir
), name
);
1962 strarray_add( deps
, lib
);
1963 strarray_add( &ret
, lib
);
1968 if (!found
) strarray_add( &ret
, all_libs
.str
[i
] );
1974 /*******************************************************************
1977 static struct strarray
add_import_libs( const struct makefile
*make
, struct strarray
*deps
,
1978 struct strarray imports
, int cross
)
1980 struct strarray ret
= empty_strarray
;
1983 for (i
= 0; i
< imports
.count
; i
++)
1985 const char *name
= imports
.str
[i
];
1987 for (j
= 0; j
< top_makefile
->subdirs
.count
; j
++)
1989 const struct makefile
*submake
= top_makefile
->submakes
[j
];
1991 if (submake
->importlib
&& !strcmp( submake
->importlib
, name
))
1993 const char *dir
= top_obj_dir_path( make
, submake
->base_dir
);
1994 const char *ext
= cross
? "cross.a" : *dll_ext
? "def" : "a";
1996 strarray_add( deps
, strmake( "%s/lib%s.%s", dir
, name
, ext
));
1997 if (!cross
&& submake
->staticimplib
)
1998 strarray_add( deps
, strmake( "%s/%s", dir
, submake
->staticimplib
));
2002 if (has_static_lib( submake
, name
))
2004 const char *dir
= top_obj_dir_path( make
, submake
->base_dir
);
2006 strarray_add( deps
, strmake( "%s/lib%s.a", dir
, name
));
2010 strarray_add( &ret
, strmake( "-l%s", name
));
2016 /*******************************************************************
2017 * get_default_imports
2019 static struct strarray
get_default_imports( const struct makefile
*make
)
2021 struct strarray ret
= empty_strarray
;
2023 if (strarray_exists( &make
->extradllflags
, "-nodefaultlibs" )) return ret
;
2024 if (strarray_exists( &make
->appmode
, "-mno-cygwin" )) strarray_add( &ret
, "msvcrt" );
2025 if (make
->is_win16
) strarray_add( &ret
, "kernel" );
2026 strarray_add( &ret
, "kernel32" );
2027 strarray_add( &ret
, "ntdll" );
2028 strarray_add( &ret
, "winecrt0" );
2033 /*******************************************************************
2036 static void add_install_rule( const struct makefile
*make
, struct strarray
*install_rules
,
2037 const char *target
, const char *file
, const char *dest
)
2039 if (strarray_exists( &make
->install_lib
, target
))
2041 strarray_add( &install_rules
[INSTALL_LIB
], file
);
2042 strarray_add( &install_rules
[INSTALL_LIB
], dest
);
2044 else if (strarray_exists( &make
->install_dev
, target
))
2046 strarray_add( &install_rules
[INSTALL_DEV
], file
);
2047 strarray_add( &install_rules
[INSTALL_DEV
], dest
);
2052 /*******************************************************************
2053 * get_include_install_path
2055 * Determine the installation path for a given include file.
2057 static const char *get_include_install_path( const char *name
)
2059 if (!strncmp( name
, "wine/", 5 )) return name
+ 5;
2060 if (!strncmp( name
, "msvcrt/", 7 )) return name
;
2061 return strmake( "windows/%s", name
);
2065 /*******************************************************************
2066 * get_shared_library_name
2068 * Determine possible names for a shared library with a version number.
2070 static struct strarray
get_shared_lib_names( const char *libname
)
2072 struct strarray ret
= empty_strarray
;
2073 const char *ext
, *p
;
2074 char *name
, *first
, *second
;
2077 strarray_add( &ret
, libname
);
2079 for (p
= libname
; (p
= strchr( p
, '.' )); p
++)
2080 if ((len
= strspn( p
+ 1, "0123456789." ))) break;
2082 if (!len
) return ret
;
2084 if (*ext
&& ext
[-1] == '.') ext
--;
2086 /* keep only the first group of digits */
2087 name
= xstrdup( libname
);
2088 first
= name
+ (p
- libname
);
2089 if ((second
= strchr( first
+ 1, '.' )))
2091 strcpy( second
, ext
);
2092 strarray_add( &ret
, xstrdup( name
));
2094 /* now remove all digits */
2095 strcpy( first
, ext
);
2096 strarray_add( &ret
, name
);
2101 /*******************************************************************
2102 * output_install_rules
2104 * Rules are stored as a (file,dest) pair of values.
2105 * The first char of dest indicates the type of install.
2107 static struct strarray
output_install_rules( const struct makefile
*make
, struct strarray files
,
2108 const char *target
, struct strarray
*phony_targets
)
2112 struct strarray uninstall
= empty_strarray
;
2113 struct strarray targets
= empty_strarray
;
2115 if (!files
.count
) return uninstall
;
2117 for (i
= 0; i
< files
.count
; i
+= 2)
2118 if (strchr( "dps", files
.str
[i
+ 1][0] )) /* only for files copied from object dir */
2119 strarray_add_uniq( &targets
, files
.str
[i
] );
2121 output( "install %s::", target
);
2122 output_filenames_obj_dir( make
, targets
);
2125 install_sh
= top_dir_path( make
, "tools/install-sh" );
2126 for (i
= 0; i
< files
.count
; i
+= 2)
2128 const char *file
= files
.str
[i
];
2129 const char *dest
= files
.str
[i
+ 1];
2133 case 'd': /* data file */
2134 output( "\t%s -m 644 $(INSTALL_DATA_FLAGS) %s $(DESTDIR)%s\n",
2135 install_sh
, obj_dir_path( make
, file
), dest
+ 1 );
2137 case 'D': /* data file in source dir */
2138 output( "\t%s -m 644 $(INSTALL_DATA_FLAGS) %s $(DESTDIR)%s\n",
2139 install_sh
, src_dir_path( make
, file
), dest
+ 1 );
2141 case 'p': /* program file */
2142 output( "\tSTRIPPROG=\"$(STRIP)\" %s $(INSTALL_PROGRAM_FLAGS) %s $(DESTDIR)%s\n",
2143 install_sh
, obj_dir_path( make
, file
), dest
+ 1 );
2145 case 's': /* script */
2146 output( "\t%s $(INSTALL_SCRIPT_FLAGS) %s $(DESTDIR)%s\n",
2147 install_sh
, obj_dir_path( make
, file
), dest
+ 1 );
2149 case 'S': /* script in source dir */
2150 output( "\t%s $(INSTALL_SCRIPT_FLAGS) %s $(DESTDIR)%s\n",
2151 install_sh
, src_dir_path( make
, file
), dest
+ 1 );
2153 case 'y': /* symlink */
2154 output( "\trm -f $(DESTDIR)%s && %s %s $(DESTDIR)%s\n", dest
+ 1, ln_s
, file
, dest
+ 1 );
2161 for (i
= 0; i
< files
.count
; i
+= 2)
2162 strarray_add( &uninstall
, strmake( "$(DESTDIR)%s", files
.str
[i
+ 1] + 1 ));
2164 strarray_add_uniq( phony_targets
, "install" );
2165 strarray_add_uniq( phony_targets
, target
);
2170 /*******************************************************************
2171 * output_importlib_symlinks
2173 static struct strarray
output_importlib_symlinks( const struct makefile
*parent
,
2174 const struct makefile
*make
)
2176 struct strarray ret
= empty_strarray
;
2177 const char *dir
, *lib
;
2179 if (!make
->module
) return ret
;
2180 if (!make
->importlib
) return ret
;
2181 if (strncmp( make
->base_dir
, "dlls/", 5 )) return ret
;
2182 if (!strcmp( make
->module
, make
->importlib
)) return ret
;
2183 if (!strchr( make
->importlib
, '.' ) &&
2184 !strncmp( make
->module
, make
->importlib
, strlen( make
->importlib
)) &&
2185 !strcmp( make
->module
+ strlen( make
->importlib
), ".dll" ))
2188 dir
= obj_dir_path( parent
, "dlls" );
2189 lib
= strmake( "lib%s.%s", make
->importlib
, *dll_ext
? "def" : "a" );
2190 output( "%s/%s: %s\n", dir
, lib
, base_dir_path( make
, lib
));
2191 output( "\trm -f $@ && %s %s/%s $@\n", ln_s
, make
->base_dir
+ strlen("dlls/"), lib
);
2192 strarray_add( &ret
, strmake( "%s/%s", dir
, lib
));
2194 if (crosstarget
&& !make
->is_win16
)
2196 lib
= strmake( "lib%s.cross.a", make
->importlib
);
2197 output( "%s/%s: %s\n", dir
, lib
, base_dir_path( make
, lib
));
2198 output( "\trm -f $@ && %s %s/%s $@\n", ln_s
, make
->base_dir
+ strlen("dlls/"), lib
);
2199 strarray_add( &ret
, strmake( "%s/%s", dir
, lib
));
2205 /*******************************************************************
2208 static void output_po_files( const struct makefile
*make
)
2210 const char *po_dir
= src_dir_path( make
, "po" );
2211 struct strarray pot_files
= empty_strarray
;
2212 struct incl_file
*source
;
2215 for (i
= 0; i
< make
->subdirs
.count
; i
++)
2217 struct makefile
*submake
= make
->submakes
[i
];
2219 LIST_FOR_EACH_ENTRY( source
, &submake
->sources
, struct incl_file
, entry
)
2221 if (strendswith( source
->name
, ".rc" ) && (source
->file
->flags
& FLAG_RC_PO
))
2223 char *pot_file
= replace_extension( source
->name
, ".rc", ".pot" );
2224 char *pot_path
= base_dir_path( submake
, pot_file
);
2225 output( "%s: tools/wrc include dummy\n", pot_path
);
2226 output( "\t@cd %s && $(MAKE) %s\n", base_dir_path( submake
, "" ), pot_file
);
2227 strarray_add( &pot_files
, pot_path
);
2229 else if (strendswith( source
->name
, ".mc" ))
2231 char *pot_file
= replace_extension( source
->name
, ".mc", ".pot" );
2232 char *pot_path
= base_dir_path( submake
, pot_file
);
2233 output( "%s: tools/wmc include dummy\n", pot_path
);
2234 output( "\t@cd %s && $(MAKE) %s\n", base_dir_path( submake
, "" ), pot_file
);
2235 strarray_add( &pot_files
, pot_path
);
2241 for (i
= 0; i
< linguas
.count
; i
++)
2242 output_filename( strmake( "%s/%s.po", po_dir
, linguas
.str
[i
] ));
2243 output( ": %s/wine.pot\n", po_dir
);
2244 output( "\tmsgmerge --previous -q $@ %s/wine.pot | msgattrib --no-obsolete -o $@.new && mv $@.new $@\n",
2247 output( "%s/wine.pot:", po_dir
);
2248 output_filenames( pot_files
);
2250 output( "\tmsgcat -o $@" );
2251 output_filenames( pot_files
);
2256 /*******************************************************************
2259 static struct strarray
output_sources( const struct makefile
*make
)
2261 struct incl_file
*source
;
2263 struct strarray object_files
= empty_strarray
;
2264 struct strarray crossobj_files
= empty_strarray
;
2265 struct strarray res_files
= empty_strarray
;
2266 struct strarray clean_files
= empty_strarray
;
2267 struct strarray uninstall_files
= empty_strarray
;
2268 struct strarray mo_files
= empty_strarray
;
2269 struct strarray ok_files
= empty_strarray
;
2270 struct strarray in_files
= empty_strarray
;
2271 struct strarray dlldata_files
= empty_strarray
;
2272 struct strarray c2man_files
= empty_strarray
;
2273 struct strarray implib_objs
= empty_strarray
;
2274 struct strarray includes
= empty_strarray
;
2275 struct strarray phony_targets
= empty_strarray
;
2276 struct strarray all_targets
= empty_strarray
;
2277 struct strarray install_rules
[NB_INSTALL_RULES
];
2278 char *ldrpath_local
= get_expanded_make_variable( make
, "LDRPATH_LOCAL" );
2279 char *ldrpath_install
= get_expanded_make_variable( make
, "LDRPATH_INSTALL" );
2281 for (i
= 0; i
< NB_INSTALL_RULES
; i
++) install_rules
[i
] = empty_strarray
;
2283 for (i
= 0; i
< linguas
.count
; i
++)
2284 strarray_add( &mo_files
, strmake( "%s/%s.mo", top_obj_dir_path( make
, "po" ), linguas
.str
[i
] ));
2286 strarray_add( &phony_targets
, "all" );
2287 strarray_add( &includes
, strmake( "-I%s", obj_dir_path( make
, "" )));
2288 if (make
->src_dir
) strarray_add( &includes
, strmake( "-I%s", make
->src_dir
));
2289 if (make
->parent_dir
) strarray_add( &includes
, strmake( "-I%s", src_dir_path( make
, make
->parent_dir
)));
2290 strarray_add( &includes
, strmake( "-I%s", top_obj_dir_path( make
, "include" )));
2291 if (make
->top_src_dir
) strarray_add( &includes
, strmake( "-I%s", top_dir_path( make
, "include" )));
2292 if (make
->use_msvcrt
) strarray_add( &includes
, strmake( "-I%s", top_dir_path( make
, "include/msvcrt" )));
2293 for (i
= 0; i
< make
->include_paths
.count
; i
++)
2294 strarray_add( &includes
, strmake( "-I%s", obj_dir_path( make
, make
->include_paths
.str
[i
] )));
2296 LIST_FOR_EACH_ENTRY( source
, &make
->sources
, struct incl_file
, entry
)
2298 struct strarray dependencies
= empty_strarray
;
2299 struct strarray extradefs
;
2300 char *obj
= xstrdup( source
->name
);
2301 char *ext
= get_extension( obj
);
2303 if (!ext
) fatal_error( "unsupported file type %s\n", source
->name
);
2306 extradefs
= get_expanded_file_local_var( make
, obj
, "EXTRADEFS" );
2307 get_dependencies( &dependencies
, source
, source
);
2309 if (!strcmp( ext
, "y" )) /* yacc file */
2311 /* add source file dependency for parallel makes */
2312 char *header
= strmake( "%s.tab.h", obj
);
2314 if (find_include_file( make
, header
))
2316 output( "%s: %s\n", obj_dir_path( make
, header
), source
->filename
);
2317 output( "\t$(BISON) -p %s_ -o %s.tab.c -d %s\n",
2318 obj
, obj_dir_path( make
, obj
), source
->filename
);
2319 output( "%s.tab.c: %s %s\n", obj_dir_path( make
, obj
),
2320 source
->filename
, obj_dir_path( make
, header
));
2321 strarray_add( &clean_files
, header
);
2323 else output( "%s.tab.c: %s\n", obj
, source
->filename
);
2325 output( "\t$(BISON) -p %s_ -o $@ %s\n", obj
, source
->filename
);
2327 else if (!strcmp( ext
, "x" )) /* template file */
2329 output( "%s.h: %s%s %s\n", obj_dir_path( make
, obj
),
2330 tools_dir_path( make
, "make_xftmpl" ), tools_ext
, source
->filename
);
2331 output( "\t%s%s -H -o $@ %s\n",
2332 tools_dir_path( make
, "make_xftmpl" ), tools_ext
, source
->filename
);
2333 if (source
->file
->flags
& FLAG_INSTALL
)
2335 strarray_add( &install_rules
[INSTALL_DEV
], source
->name
);
2336 strarray_add( &install_rules
[INSTALL_DEV
],
2337 strmake( "D$(includedir)/%s", get_include_install_path( source
->name
) ));
2338 strarray_add( &install_rules
[INSTALL_DEV
], strmake( "%s.h", obj
));
2339 strarray_add( &install_rules
[INSTALL_DEV
],
2340 strmake( "d$(includedir)/%s.h", get_include_install_path( obj
) ));
2343 else if (!strcmp( ext
, "l" )) /* lex file */
2345 output( "%s.yy.c: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2346 output( "\t$(FLEX) -o$@ %s\n", source
->filename
);
2348 else if (!strcmp( ext
, "rc" )) /* resource file */
2350 strarray_add( &res_files
, strmake( "%s.res", obj
));
2351 output( "%s.res: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2352 output( "\t%s -o $@", tools_path( make
, "wrc" ) );
2353 if (make
->is_win16
) output_filename( "-m16" );
2354 else output_filenames( target_flags
);
2355 output_filename( "--nostdinc" );
2356 output_filenames( includes
);
2357 output_filenames( make
->define_args
);
2358 output_filenames( extradefs
);
2359 if (mo_files
.count
&& (source
->file
->flags
& FLAG_RC_PO
))
2361 output_filename( strmake( "--po-dir=%s", top_obj_dir_path( make
, "po" )));
2362 output_filename( source
->filename
);
2364 output( "%s.res:", obj_dir_path( make
, obj
));
2365 output_filenames( mo_files
);
2370 output_filename( source
->filename
);
2373 if (source
->file
->flags
& FLAG_RC_PO
)
2375 strarray_add( &clean_files
, strmake( "%s.pot", obj
));
2376 output( "%s.pot: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2377 output( "\t%s -O pot -o $@", tools_path( make
, "wrc" ) );
2378 if (make
->is_win16
) output_filename( "-m16" );
2379 else output_filenames( target_flags
);
2380 output_filename( "--nostdinc" );
2381 output_filenames( includes
);
2382 output_filenames( make
->define_args
);
2383 output_filenames( extradefs
);
2384 output_filename( source
->filename
);
2386 output( "%s.pot ", obj_dir_path( make
, obj
));
2388 output( "%s.res:", obj_dir_path( make
, obj
));
2389 output_filename( tools_path( make
, "wrc" ));
2390 output_filenames( dependencies
);
2393 else if (!strcmp( ext
, "mc" )) /* message file */
2395 strarray_add( &res_files
, strmake( "%s.res", obj
));
2396 strarray_add( &clean_files
, strmake( "%s.pot", obj
));
2397 output( "%s.res: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2398 output( "\t%s -U -O res -o $@ %s", tools_path( make
, "wmc" ), source
->filename
);
2401 output_filename( strmake( "--po-dir=%s", top_obj_dir_path( make
, "po" )));
2403 output( "%s.res:", obj_dir_path( make
, obj
));
2404 output_filenames( mo_files
);
2407 output( "%s.pot: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2408 output( "\t%s -O pot -o $@ %s", tools_path( make
, "wmc" ), source
->filename
);
2410 output( "%s.pot %s.res:", obj_dir_path( make
, obj
), obj_dir_path( make
, obj
));
2411 output_filename( tools_path( make
, "wmc" ));
2412 output_filenames( dependencies
);
2415 else if (!strcmp( ext
, "idl" )) /* IDL file */
2417 struct strarray targets
= empty_strarray
;
2420 if (!source
->file
->flags
) source
->file
->flags
|= FLAG_IDL_HEADER
| FLAG_INSTALL
;
2421 if (find_include_file( make
, strmake( "%s.h", obj
))) source
->file
->flags
|= FLAG_IDL_HEADER
;
2423 for (i
= 0; i
< sizeof(idl_outputs
) / sizeof(idl_outputs
[0]); i
++)
2425 if (!(source
->file
->flags
& idl_outputs
[i
].flag
)) continue;
2426 dest
= strmake( "%s%s", obj
, idl_outputs
[i
].ext
);
2427 if (!find_src_file( make
, dest
)) strarray_add( &clean_files
, dest
);
2428 strarray_add( &targets
, dest
);
2430 if (source
->file
->flags
& FLAG_IDL_PROXY
) strarray_add( &dlldata_files
, source
->name
);
2431 if (source
->file
->flags
& FLAG_INSTALL
)
2433 strarray_add( &install_rules
[INSTALL_DEV
], xstrdup( source
->name
));
2434 strarray_add( &install_rules
[INSTALL_DEV
],
2435 strmake( "D$(includedir)/%s.idl", get_include_install_path( obj
) ));
2436 if (source
->file
->flags
& FLAG_IDL_HEADER
)
2438 strarray_add( &install_rules
[INSTALL_DEV
], strmake( "%s.h", obj
));
2439 strarray_add( &install_rules
[INSTALL_DEV
],
2440 strmake( "d$(includedir)/%s.h", get_include_install_path( obj
) ));
2443 if (!targets
.count
) continue;
2444 output_filenames_obj_dir( make
, targets
);
2445 output( ": %s\n", tools_path( make
, "widl" ));
2446 output( "\t%s -o $@", tools_path( make
, "widl" ) );
2447 output_filenames( target_flags
);
2448 output_filenames( includes
);
2449 output_filenames( make
->define_args
);
2450 output_filenames( extradefs
);
2451 output_filenames( get_expanded_make_var_array( make
, "EXTRAIDLFLAGS" ));
2452 output_filename( source
->filename
);
2454 output_filenames_obj_dir( make
, targets
);
2455 output( ": %s", source
->filename
);
2456 output_filenames( dependencies
);
2459 else if (!strcmp( ext
, "in" )) /* .in file or man page */
2461 if (strendswith( obj
, ".man" ) && source
->file
->args
)
2463 struct strarray symlinks
;
2464 char *dir
, *dest
= replace_extension( obj
, ".man", "" );
2465 char *lang
= strchr( dest
, '.' );
2466 char *section
= source
->file
->args
;
2470 dir
= strmake( "$(mandir)/%s/man%s", lang
, section
);
2472 else dir
= strmake( "$(mandir)/man%s", section
);
2473 add_install_rule( make
, install_rules
, dest
, xstrdup(obj
),
2474 strmake( "d%s/%s.%s", dir
, dest
, section
));
2475 symlinks
= get_expanded_file_local_var( make
, dest
, "SYMLINKS" );
2476 for (i
= 0; i
< symlinks
.count
; i
++)
2477 add_install_rule( make
, install_rules
, symlinks
.str
[i
],
2478 strmake( "%s.%s", dest
, section
),
2479 strmake( "y%s/%s.%s", dir
, symlinks
.str
[i
], section
));
2483 strarray_add( &in_files
, xstrdup(obj
) );
2484 strarray_add( &all_targets
, xstrdup(obj
) );
2485 output( "%s: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2486 output( "\t$(SED_CMD) %s >$@ || (rm -f $@ && false)\n", source
->filename
);
2487 output( "%s:", obj_dir_path( make
, obj
));
2488 output_filenames( dependencies
);
2490 add_install_rule( make
, install_rules
, obj
, xstrdup( obj
),
2491 strmake( "d$(datadir)/wine/%s", obj
));
2493 else if (!strcmp( ext
, "sfd" )) /* font file */
2495 char *ttf_file
= src_dir_path( make
, strmake( "%s.ttf", obj
));
2496 if (fontforge
&& !make
->src_dir
)
2498 output( "%s: %s\n", ttf_file
, source
->filename
);
2499 output( "\t%s -script %s %s $@\n",
2500 fontforge
, top_dir_path( make
, "fonts/genttf.ff" ), source
->filename
);
2501 if (!(source
->file
->flags
& FLAG_SFD_FONTS
)) output( "all: %s\n", ttf_file
);
2503 if (source
->file
->flags
& FLAG_INSTALL
)
2505 strarray_add( &install_rules
[INSTALL_LIB
], strmake( "%s.ttf", obj
));
2506 strarray_add( &install_rules
[INSTALL_LIB
], strmake( "D$(fontdir)/%s.ttf", obj
));
2508 if (source
->file
->flags
& FLAG_SFD_FONTS
)
2510 struct strarray
*array
= source
->file
->args
;
2512 for (i
= 0; i
< array
->count
; i
++)
2514 char *font
= strtok( xstrdup(array
->str
[i
]), " \t" );
2515 char *args
= strtok( NULL
, "" );
2517 strarray_add( &all_targets
, xstrdup( font
));
2518 output( "%s: %s %s\n", obj_dir_path( make
, font
),
2519 tools_path( make
, "sfnt2fon" ), ttf_file
);
2520 output( "\t%s -o $@ %s %s\n", tools_path( make
, "sfnt2fon" ), ttf_file
, args
);
2521 strarray_add( &install_rules
[INSTALL_LIB
], xstrdup(font
) );
2522 strarray_add( &install_rules
[INSTALL_LIB
], strmake( "d$(fontdir)/%s", font
));
2526 else if (!strcmp( ext
, "svg" )) /* svg file */
2528 if (convert
&& rsvg
&& icotool
&& !make
->src_dir
)
2530 output( "%s.ico %s.bmp: %s\n",
2531 src_dir_path( make
, obj
), src_dir_path( make
, obj
), source
->filename
);
2532 output( "\tCONVERT=\"%s\" ICOTOOL=\"%s\" RSVG=\"%s\" %s %s $@\n", convert
, icotool
, rsvg
,
2533 top_dir_path( make
, "tools/buildimage" ), source
->filename
);
2536 else if (!strcmp( ext
, "res" ))
2538 strarray_add( &res_files
, source
->name
);
2540 else if (!strcmp( ext
, "tlb" ))
2542 strarray_add( &all_targets
, source
->name
);
2544 else if (!strcmp( ext
, "h" ) || !strcmp( ext
, "rh" ) || !strcmp( ext
, "inl" )) /* header file */
2546 if (source
->file
->flags
& FLAG_GENERATED
)
2548 strarray_add( &all_targets
, source
->name
);
2552 strarray_add( &install_rules
[INSTALL_DEV
], source
->name
);
2553 strarray_add( &install_rules
[INSTALL_DEV
],
2554 strmake( "D$(includedir)/%s", get_include_install_path( source
->name
) ));
2559 int need_cross
= make
->testdll
||
2560 (source
->file
->flags
& FLAG_C_IMPLIB
) ||
2561 (make
->module
&& make
->staticlib
);
2563 if ((source
->file
->flags
& FLAG_GENERATED
) &&
2564 (!make
->testdll
|| !strendswith( source
->filename
, "testlist.c" )))
2565 strarray_add( &clean_files
, source
->filename
);
2566 if (source
->file
->flags
& FLAG_C_IMPLIB
) strarray_add( &implib_objs
, strmake( "%s.o", obj
));
2567 strarray_add( &object_files
, strmake( "%s.o", obj
));
2568 output( "%s.o: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2569 output( "\t$(CC) -c -o $@ %s", source
->filename
);
2570 output_filenames( includes
);
2571 output_filenames( make
->define_args
);
2572 output_filenames( extradefs
);
2573 if (make
->module
|| make
->staticlib
|| make
->sharedlib
|| make
->testdll
)
2575 output_filenames( dll_flags
);
2576 if (make
->use_msvcrt
) output_filenames( msvcrt_flags
);
2578 output_filenames( extra_cflags
);
2579 output_filenames( cpp_flags
);
2580 output_filename( "$(CFLAGS)" );
2582 if (crosstarget
&& need_cross
)
2584 strarray_add( &crossobj_files
, strmake( "%s.cross.o", obj
));
2585 output( "%s.cross.o: %s\n", obj_dir_path( make
, obj
), source
->filename
);
2586 output( "\t$(CROSSCC) -c -o $@ %s", source
->filename
);
2587 output_filenames( includes
);
2588 output_filenames( make
->define_args
);
2589 output_filenames( extradefs
);
2590 output_filename( "-DWINE_CROSSTEST" );
2591 output_filenames( cpp_flags
);
2592 output_filename( "$(CFLAGS)" );
2595 if (make
->testdll
&& !strcmp( ext
, "c" ) && !(source
->file
->flags
& FLAG_GENERATED
))
2597 strarray_add( &ok_files
, strmake( "%s.ok", obj
));
2598 output( "%s.ok:\n", obj_dir_path( make
, obj
));
2599 output( "\t%s $(RUNTESTFLAGS) -T %s -M %s -p %s%s %s && touch $@\n",
2600 top_dir_path( make
, "tools/runtest" ), top_obj_dir_path( make
, "" ), make
->testdll
,
2601 replace_extension( make
->testdll
, ".dll", "_test.exe" ), dll_ext
, obj
);
2603 if (!strcmp( ext
, "c" ) && !(source
->file
->flags
& FLAG_GENERATED
))
2604 strarray_add( &c2man_files
, source
->filename
);
2605 output( "%s.o", obj_dir_path( make
, obj
));
2606 if (crosstarget
&& need_cross
) output( " %s.cross.o", obj_dir_path( make
, obj
));
2608 output_filenames( dependencies
);
2614 /* rules for files that depend on multiple sources */
2616 if (dlldata_files
.count
)
2618 output( "%s: %s %s\n", obj_dir_path( make
, "dlldata.c" ),
2619 tools_path( make
, "widl" ), src_dir_path( make
, "Makefile.in" ));
2620 output( "\t%s --dlldata-only -o $@", tools_path( make
, "widl" ));
2621 output_filenames( dlldata_files
);
2625 if (make
->module
&& !make
->staticlib
)
2627 struct strarray all_libs
= empty_strarray
;
2628 struct strarray dep_libs
= empty_strarray
;
2629 char *module_path
= obj_dir_path( make
, make
->module
);
2630 char *spec_file
= NULL
;
2632 if (!make
->appmode
.count
)
2633 spec_file
= src_dir_path( make
, replace_extension( make
->module
, ".dll", ".spec" ));
2634 strarray_addall( &all_libs
, add_import_libs( make
, &dep_libs
, make
->delayimports
, 0 ));
2635 strarray_addall( &all_libs
, add_import_libs( make
, &dep_libs
, make
->imports
, 0 ));
2636 add_import_libs( make
, &dep_libs
, get_default_imports( make
), 0 ); /* dependencies only */
2637 strarray_addall( &all_libs
, add_default_libraries( make
, &dep_libs
));
2641 for (i
= 0; i
< make
->delayimports
.count
; i
++)
2642 strarray_add( &all_libs
, strmake( "-Wb,-d%s", make
->delayimports
.str
[i
] ));
2643 strarray_add( &all_targets
, strmake( "%s%s", make
->module
, dll_ext
));
2644 strarray_add( &all_targets
, strmake( "%s.fake", make
->module
));
2645 add_install_rule( make
, install_rules
, make
->module
, strmake( "%s%s", make
->module
, dll_ext
),
2646 strmake( "p$(dlldir)/%s%s", make
->module
, dll_ext
));
2647 add_install_rule( make
, install_rules
, make
->module
, strmake( "%s.fake", make
->module
),
2648 strmake( "d$(fakedlldir)/%s", make
->module
));
2649 output( "%s%s %s.fake:", module_path
, dll_ext
, module_path
);
2653 strarray_add( &all_libs
, "-lwine" );
2654 strarray_add( &all_targets
, make
->module
);
2655 add_install_rule( make
, install_rules
, make
->module
, make
->module
,
2656 strmake( "p$(%s)/%s", spec_file
? "dlldir" : "bindir", make
->module
));
2657 output( "%s:", module_path
);
2659 if (spec_file
) output_filename( spec_file
);
2660 output_filenames_obj_dir( make
, object_files
);
2661 output_filenames_obj_dir( make
, res_files
);
2662 output_filenames( dep_libs
);
2664 output( "\t%s -o $@", tools_path( make
, "winegcc" ));
2665 output_filename( strmake( "-B%s", tools_dir_path( make
, "winebuild" )));
2666 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make
, "" )));
2667 output_filenames( target_flags
);
2668 output_filenames( unwind_flags
);
2671 output( " -shared %s", spec_file
);
2672 output_filenames( make
->extradllflags
);
2674 else output_filenames( make
->appmode
);
2675 output_filenames_obj_dir( make
, object_files
);
2676 output_filenames_obj_dir( make
, res_files
);
2677 output_filenames( all_libs
);
2678 output_filename( "$(LDFLAGS)" );
2681 if (spec_file
&& make
->importlib
)
2683 char *importlib_path
= obj_dir_path( make
, strmake( "lib%s", make
->importlib
));
2686 strarray_add( &clean_files
, strmake( "lib%s.def", make
->importlib
));
2687 output( "%s.def: %s %s\n", importlib_path
, tools_path( make
, "winebuild" ), spec_file
);
2688 output( "\t%s -w --def -o $@ --export %s", tools_path( make
, "winebuild" ), spec_file
);
2689 output_filenames( target_flags
);
2690 if (make
->is_win16
) output_filename( "-m16" );
2692 add_install_rule( make
, install_rules
, make
->importlib
,
2693 strmake( "lib%s.def", make
->importlib
),
2694 strmake( "d$(dlldir)/lib%s.def", make
->importlib
));
2695 if (implib_objs
.count
)
2697 strarray_add( &clean_files
, strmake( "lib%s.def.a", make
->importlib
));
2698 output( "%s.def.a:", importlib_path
);
2699 output_filenames_obj_dir( make
, implib_objs
);
2701 output( "\trm -f $@\n" );
2702 output( "\t$(AR) $(ARFLAGS) $@" );
2703 output_filenames_obj_dir( make
, implib_objs
);
2705 output( "\t$(RANLIB) $@\n" );
2706 add_install_rule( make
, install_rules
, make
->importlib
,
2707 strmake( "lib%s.def.a", make
->importlib
),
2708 strmake( "d$(dlldir)/lib%s.def.a", make
->importlib
));
2713 strarray_add( &clean_files
, strmake( "lib%s.a", make
->importlib
));
2714 output( "%s.a: %s %s", importlib_path
, tools_path( make
, "winebuild" ), spec_file
);
2715 output_filenames_obj_dir( make
, implib_objs
);
2717 output( "\t%s -w --implib -o $@ --export %s", tools_path( make
, "winebuild" ), spec_file
);
2718 output_filenames( target_flags
);
2719 output_filenames_obj_dir( make
, implib_objs
);
2721 add_install_rule( make
, install_rules
, make
->importlib
,
2722 strmake( "lib%s.a", make
->importlib
),
2723 strmake( "d$(dlldir)/lib%s.a", make
->importlib
));
2725 if (crosstarget
&& !make
->is_win16
)
2727 struct strarray cross_files
= strarray_replace_extension( &implib_objs
, ".o", ".cross.o" );
2728 strarray_add( &clean_files
, strmake( "lib%s.cross.a", make
->importlib
));
2729 output( "%s.cross.a: %s %s", importlib_path
, tools_path( make
, "winebuild" ), spec_file
);
2730 output_filenames_obj_dir( make
, cross_files
);
2732 output( "\t%s -b %s -w --implib -o $@ --export %s",
2733 tools_path( make
, "winebuild" ), crosstarget
, spec_file
);
2734 output_filenames_obj_dir( make
, cross_files
);
2741 if (c2man_files
.count
)
2743 output( "manpages::\n" );
2744 output( "\t%s -w %s", top_dir_path( make
, "tools/c2man.pl" ), spec_file
);
2745 output_filename( strmake( "-R%s", top_dir_path( make
, "" )));
2746 output_filename( strmake( "-I%s", top_dir_path( make
, "include" )));
2747 output_filename( strmake( "-o %s/man%s",
2748 top_obj_dir_path( make
, "documentation" ), man_ext
));
2749 output_filenames( c2man_files
);
2751 output( "htmlpages::\n" );
2752 output( "\t%s -Th -w %s", top_dir_path( make
, "tools/c2man.pl" ), spec_file
);
2753 output_filename( strmake( "-R%s", top_dir_path( make
, "" )));
2754 output_filename( strmake( "-I%s", top_dir_path( make
, "include" )));
2755 output_filename( strmake( "-o %s",
2756 top_obj_dir_path( make
, "documentation/html" )));
2757 output_filenames( c2man_files
);
2759 output( "sgmlpages::\n" );
2760 output( "\t%s -Ts -w %s", top_dir_path( make
, "tools/c2man.pl" ), spec_file
);
2761 output_filename( strmake( "-R%s", top_dir_path( make
, "" )));
2762 output_filename( strmake( "-I%s", top_dir_path( make
, "include" )));
2763 output_filename( strmake( "-o %s",
2764 top_obj_dir_path( make
, "documentation/api-guide" )));
2765 output_filenames( c2man_files
);
2767 output( "xmlpages::\n" );
2768 output( "\t%s -Tx -w %s", top_dir_path( make
, "tools/c2man.pl" ), spec_file
);
2769 output_filename( strmake( "-R%s", top_dir_path( make
, "" )));
2770 output_filename( strmake( "-I%s", top_dir_path( make
, "include" )));
2771 output_filename( strmake( "-o %s",
2772 top_obj_dir_path( make
, "documentation/api-guide-xml" )));
2773 output_filenames( c2man_files
);
2775 strarray_add( &phony_targets
, "manpages" );
2776 strarray_add( &phony_targets
, "htmlpages" );
2777 strarray_add( &phony_targets
, "sgmlpages" );
2778 strarray_add( &phony_targets
, "xmlpages" );
2780 else output( "manpages htmlpages sgmlpages xmlpages::\n" );
2784 char *binary
= replace_extension( make
->module
, ".exe", "" );
2785 add_install_rule( make
, install_rules
, binary
, tools_dir_path( make
, "wineapploader" ),
2786 strmake( "s$(bindir)/%s", binary
));
2790 if (make
->staticlib
)
2792 strarray_add( &all_targets
, make
->staticlib
);
2793 output( "%s:", obj_dir_path( make
, make
->staticlib
));
2794 output_filenames_obj_dir( make
, object_files
);
2795 output( "\n\trm -f $@\n" );
2796 output( "\t$(AR) $(ARFLAGS) $@" );
2797 output_filenames_obj_dir( make
, object_files
);
2798 output( "\n\t$(RANLIB) $@\n" );
2799 if (crosstarget
&& make
->module
)
2801 char *name
= replace_extension( make
->staticlib
, ".a", ".cross.a" );
2803 strarray_add( &all_targets
, name
);
2804 output( "%s:", obj_dir_path( make
, name
));
2805 output_filenames_obj_dir( make
, crossobj_files
);
2806 output( "\n\trm -f $@\n" );
2807 output( "\t%s-ar $(ARFLAGS) $@", crosstarget
);
2808 output_filenames_obj_dir( make
, crossobj_files
);
2809 output( "\n\t%s-ranlib $@\n", crosstarget
);
2813 if (make
->sharedlib
)
2816 struct strarray names
= get_shared_lib_names( make
->sharedlib
);
2817 struct strarray all_libs
= empty_strarray
;
2818 struct strarray dep_libs
= empty_strarray
;
2820 basename
= xstrdup( make
->sharedlib
);
2821 if ((p
= strchr( basename
, '.' ))) *p
= 0;
2823 strarray_addall( &dep_libs
, get_local_dependencies( make
, basename
, in_files
));
2824 strarray_addall( &all_libs
, get_expanded_file_local_var( make
, basename
, "LDFLAGS" ));
2825 strarray_addall( &all_libs
, add_default_libraries( make
, &dep_libs
));
2827 output( "%s:", obj_dir_path( make
, make
->sharedlib
));
2828 output_filenames_obj_dir( make
, object_files
);
2829 output_filenames( dep_libs
);
2831 output( "\t$(CC) -o $@" );
2832 output_filenames_obj_dir( make
, object_files
);
2833 output_filenames( all_libs
);
2834 output_filename( "$(LDFLAGS)" );
2836 add_install_rule( make
, install_rules
, make
->sharedlib
, make
->sharedlib
,
2837 strmake( "p$(libdir)/%s", make
->sharedlib
));
2838 for (i
= 1; i
< names
.count
; i
++)
2840 output( "%s: %s\n", obj_dir_path( make
, names
.str
[i
] ), obj_dir_path( make
, names
.str
[i
-1] ));
2841 output( "\trm -f $@ && %s %s $@\n", ln_s
, names
.str
[i
-1] );
2842 add_install_rule( make
, install_rules
, names
.str
[i
], names
.str
[i
-1],
2843 strmake( "y$(libdir)/%s", names
.str
[i
] ));
2845 strarray_addall( &all_targets
, names
);
2848 if (make
->importlib
&& !make
->module
) /* stand-alone import lib (for libwine) */
2850 char *def_file
= replace_extension( make
->importlib
, ".a", ".def" );
2852 if (!strncmp( def_file
, "lib", 3 )) def_file
+= 3;
2853 output( "%s: %s\n", obj_dir_path( make
, make
->importlib
), src_dir_path( make
, def_file
));
2854 output( "\t%s -l $@ -d %s\n", dlltool
, src_dir_path( make
, def_file
));
2855 add_install_rule( make
, install_rules
, make
->importlib
, make
->importlib
,
2856 strmake( "d$(libdir)/%s", make
->importlib
));
2857 strarray_add( &all_targets
, make
->importlib
);
2862 char *testmodule
= replace_extension( make
->testdll
, ".dll", "_test.exe" );
2863 char *stripped
= replace_extension( make
->testdll
, ".dll", "_test-stripped.exe" );
2864 char *testres
= replace_extension( make
->testdll
, ".dll", "_test.res" );
2865 struct strarray dep_libs
= empty_strarray
;
2866 struct strarray all_libs
= add_import_libs( make
, &dep_libs
, make
->imports
, 0 );
2868 add_import_libs( make
, &dep_libs
, get_default_imports( make
), 0 ); /* dependencies only */
2869 strarray_addall( &all_libs
, libs
);
2870 strarray_add( &all_targets
, strmake( "%s%s", testmodule
, dll_ext
));
2871 strarray_add( &clean_files
, strmake( "%s%s", stripped
, dll_ext
));
2872 output( "%s%s:\n", obj_dir_path( make
, testmodule
), dll_ext
);
2873 output( "\t%s -o $@", tools_path( make
, "winegcc" ));
2874 output_filename( strmake( "-B%s", tools_dir_path( make
, "winebuild" )));
2875 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make
, "" )));
2876 output_filenames( target_flags
);
2877 output_filenames( unwind_flags
);
2878 output_filenames( make
->appmode
);
2879 output_filenames_obj_dir( make
, object_files
);
2880 output_filenames_obj_dir( make
, res_files
);
2881 output_filenames( all_libs
);
2882 output_filename( "$(LDFLAGS)" );
2884 output( "%s%s:\n", obj_dir_path( make
, stripped
), dll_ext
);
2885 output( "\t%s -o $@", tools_path( make
, "winegcc" ));
2886 output_filename( strmake( "-B%s", tools_dir_path( make
, "winebuild" )));
2887 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make
, "" )));
2888 output_filenames( target_flags
);
2889 output_filenames( unwind_flags
);
2890 output_filename( strmake( "-Wb,-F,%s", testmodule
));
2891 output_filenames( make
->appmode
);
2892 output_filenames_obj_dir( make
, object_files
);
2893 output_filenames_obj_dir( make
, res_files
);
2894 output_filenames( all_libs
);
2895 output_filename( "$(LDFLAGS)" );
2897 output( "%s%s %s%s:", obj_dir_path( make
, testmodule
), dll_ext
,
2898 obj_dir_path( make
, stripped
), dll_ext
);
2899 output_filenames_obj_dir( make
, object_files
);
2900 output_filenames_obj_dir( make
, res_files
);
2901 output_filenames( dep_libs
);
2904 output( "all: %s/%s\n", top_obj_dir_path( make
, "programs/winetest" ), testres
);
2905 output( "%s/%s: %s%s\n", top_obj_dir_path( make
, "programs/winetest" ), testres
,
2906 obj_dir_path( make
, stripped
), dll_ext
);
2907 output( "\techo \"%s TESTRES \\\"%s%s\\\"\" | %s -o $@\n",
2908 testmodule
, obj_dir_path( make
, stripped
), dll_ext
, tools_path( make
, "wrc" ));
2912 char *crosstest
= replace_extension( make
->testdll
, ".dll", "_crosstest.exe" );
2914 dep_libs
= empty_strarray
;
2915 all_libs
= add_import_libs( make
, &dep_libs
, make
->imports
, 1 );
2916 add_import_libs( make
, &dep_libs
, get_default_imports( make
), 1 ); /* dependencies only */
2917 strarray_addall( &all_libs
, libs
);
2918 strarray_add( &clean_files
, crosstest
);
2919 output( "%s: %s\n", obj_dir_path( make
, "crosstest" ), obj_dir_path( make
, crosstest
));
2920 output( "%s:", obj_dir_path( make
, crosstest
));
2921 output_filenames_obj_dir( make
, crossobj_files
);
2922 output_filenames_obj_dir( make
, res_files
);
2923 output_filenames( dep_libs
);
2925 output( "\t%s -o $@ -b %s", tools_path( make
, "winegcc" ), crosstarget
);
2926 output_filename( strmake( "-B%s", tools_dir_path( make
, "winebuild" )));
2927 if (tools_dir
) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make
, "" )));
2928 output_filename( "--lib-suffix=.cross.a" );
2929 output_filenames_obj_dir( make
, crossobj_files
);
2930 output_filenames_obj_dir( make
, res_files
);
2931 output_filenames( all_libs
);
2932 output_filename( "$(LDFLAGS)" );
2934 strarray_add( &phony_targets
, obj_dir_path( make
, "crosstest" ));
2935 if (make
->obj_dir
) output( "crosstest: %s\n", obj_dir_path( make
, "crosstest" ));
2938 output_filenames_obj_dir( make
, ok_files
);
2939 output( ": %s%s ../%s%s\n", testmodule
, dll_ext
, make
->testdll
, dll_ext
);
2940 output( "check test:" );
2941 output_filenames_obj_dir( make
, ok_files
);
2943 output( "testclean::\n" );
2944 output( "\trm -f" );
2945 output_filenames_obj_dir( make
, ok_files
);
2947 strarray_addall( &clean_files
, ok_files
);
2948 strarray_add( &phony_targets
, "check" );
2949 strarray_add( &phony_targets
, "test" );
2950 strarray_add( &phony_targets
, "testclean" );
2953 for (i
= 0; i
< make
->programs
.count
; i
++)
2955 char *program_installed
= NULL
;
2956 char *program
= strmake( "%s%s", make
->programs
.str
[i
], exe_ext
);
2957 struct strarray deps
= get_local_dependencies( make
, make
->programs
.str
[i
], in_files
);
2958 struct strarray all_libs
= get_expanded_file_local_var( make
, make
->programs
.str
[i
], "LDFLAGS" );
2959 struct strarray objs
= get_expanded_file_local_var( make
, make
->programs
.str
[i
], "OBJS" );
2960 struct strarray symlinks
= get_expanded_file_local_var( make
, make
->programs
.str
[i
], "SYMLINKS" );
2962 if (!objs
.count
) objs
= object_files
;
2963 strarray_addall( &all_libs
, add_default_libraries( make
, &deps
));
2965 output( "%s:", obj_dir_path( make
, program
) );
2966 output_filenames_obj_dir( make
, objs
);
2967 output_filenames( deps
);
2969 output( "\t$(CC) -o $@" );
2970 output_filenames_obj_dir( make
, objs
);
2972 if (strarray_exists( &all_libs
, "-lwine" ))
2974 strarray_add( &all_libs
, strmake( "-L%s", top_obj_dir_path( make
, "libs/wine" )));
2975 if (ldrpath_local
&& ldrpath_install
)
2977 program_installed
= strmake( "%s-installed%s", make
->programs
.str
[i
], exe_ext
);
2978 output_filename( ldrpath_local
);
2979 output_filenames( all_libs
);
2980 output_filename( "$(LDFLAGS)" );
2982 output( "%s:", obj_dir_path( make
, program_installed
) );
2983 output_filenames_obj_dir( make
, objs
);
2984 output_filenames( deps
);
2986 output( "\t$(CC) -o $@" );
2987 output_filenames_obj_dir( make
, objs
);
2988 output_filename( ldrpath_install
);
2989 strarray_add( &all_targets
, program_installed
);
2993 output_filenames( all_libs
);
2994 output_filename( "$(LDFLAGS)" );
2996 strarray_add( &all_targets
, program
);
3000 output_filenames_obj_dir( make
, symlinks
);
3001 output( ": %s\n", obj_dir_path( make
, program
));
3002 output( "\trm -f $@ && %s %s $@\n", ln_s
, obj_dir_path( make
, program
));
3003 strarray_addall( &all_targets
, symlinks
);
3006 add_install_rule( make
, install_rules
, program
, program_installed
? program_installed
: program
,
3007 strmake( "p$(bindir)/%s", program
));
3008 for (j
= 0; j
< symlinks
.count
; j
++)
3009 add_install_rule( make
, install_rules
, symlinks
.str
[j
], program
,
3010 strmake( "y$(bindir)/%s%s", symlinks
.str
[j
], exe_ext
));
3013 for (i
= 0; i
< make
->scripts
.count
; i
++)
3014 add_install_rule( make
, install_rules
, make
->scripts
.str
[i
], make
->scripts
.str
[i
],
3015 strmake( "S$(bindir)/%s", make
->scripts
.str
[i
] ));
3017 if (all_targets
.count
)
3020 output_filenames_obj_dir( make
, all_targets
);
3024 strarray_addall( &uninstall_files
, output_install_rules( make
, install_rules
[INSTALL_LIB
],
3025 "install-lib", &phony_targets
));
3026 strarray_addall( &uninstall_files
, output_install_rules( make
, install_rules
[INSTALL_DEV
],
3027 "install-dev", &phony_targets
));
3028 if (uninstall_files
.count
)
3030 output( "uninstall::\n" );
3031 output( "\trm -f" );
3032 output_filenames( uninstall_files
);
3034 strarray_add_uniq( &phony_targets
, "uninstall" );
3037 strarray_addall( &clean_files
, object_files
);
3038 strarray_addall( &clean_files
, crossobj_files
);
3039 strarray_addall( &clean_files
, res_files
);
3040 strarray_addall( &clean_files
, all_targets
);
3041 strarray_addall( &clean_files
, get_expanded_make_var_array( make
, "EXTRA_TARGETS" ));
3043 if (make
->subdirs
.count
)
3045 struct strarray build_deps
= empty_strarray
;
3046 struct strarray makefile_deps
= empty_strarray
;
3047 struct strarray distclean_files
= empty_strarray
;
3049 for (i
= 0; i
< make
->subdirs
.count
; i
++)
3051 const struct makefile
*submake
= make
->submakes
[i
];
3053 strarray_add( &makefile_deps
, top_dir_path( make
, base_dir_path( submake
,
3054 strmake ( "%s.in", output_makefile_name
))));
3055 strarray_add( &distclean_files
, base_dir_path( submake
, output_makefile_name
));
3056 if (!make
->src_dir
) strarray_add( &distclean_files
, base_dir_path( submake
, ".gitignore" ));
3057 if (submake
->testdll
) strarray_add( &distclean_files
, base_dir_path( submake
, "testlist.c" ));
3058 strarray_addall( &build_deps
, output_importlib_symlinks( make
, submake
));
3060 output( "Makefile:" );
3061 output_filenames( makefile_deps
);
3063 output( "distclean::\n");
3064 output( "\trm -f" );
3065 output_filenames( distclean_files
);
3067 strarray_add( &phony_targets
, "distclean" );
3069 if (msgfmt
&& strcmp( msgfmt
, "false" ))
3071 strarray_addall( &build_deps
, mo_files
);
3072 for (i
= 0; i
< linguas
.count
; i
++)
3074 output( "%s/%s.mo:", obj_dir_path( make
, "po" ), linguas
.str
[i
] );
3075 output( " %s/%s.po\n", src_dir_path( make
, "po" ), linguas
.str
[i
] );
3076 output( "\t%s -o $@ %s/%s.po\n", msgfmt
, src_dir_path( make
, "po" ), linguas
.str
[i
] );
3079 if (build_deps
.count
)
3081 output( "__builddeps__:" );
3082 output_filenames( build_deps
);
3084 strarray_addall( &clean_files
, build_deps
);
3086 if (get_expanded_make_variable( make
, "GETTEXTPO_LIBS" )) output_po_files( make
);
3089 if (clean_files
.count
)
3091 output( "%s::\n", obj_dir_path( make
, "clean" ));
3092 output( "\trm -f" );
3093 output_filenames_obj_dir( make
, clean_files
);
3095 if (make
->obj_dir
) output( "__clean__: %s\n", obj_dir_path( make
, "clean" ));
3096 strarray_add( &phony_targets
, obj_dir_path( make
, "clean" ));
3099 if (phony_targets
.count
)
3101 output( ".PHONY:" );
3102 output_filenames( phony_targets
);
3110 /*******************************************************************
3113 static FILE *create_temp_file( const char *orig
)
3115 char *name
= xmalloc( strlen(orig
) + 13 );
3116 unsigned int i
, id
= getpid();
3120 for (i
= 0; i
< 100; i
++)
3122 sprintf( name
, "%s.tmp%08x", orig
, id
);
3123 if ((fd
= open( name
, O_RDWR
| O_CREAT
| O_EXCL
, 0666 )) != -1)
3125 ret
= fdopen( fd
, "w" );
3128 if (errno
!= EEXIST
) break;
3131 if (!ret
) fatal_error( "failed to create output file for '%s'\n", orig
);
3132 temp_file_name
= name
;
3137 /*******************************************************************
3140 static void rename_temp_file( const char *dest
)
3142 int ret
= rename( temp_file_name
, dest
);
3143 if (ret
== -1 && errno
== EEXIST
)
3145 /* rename doesn't overwrite on windows */
3147 ret
= rename( temp_file_name
, dest
);
3149 if (ret
== -1) fatal_error( "failed to rename output file to '%s'\n", dest
);
3150 temp_file_name
= NULL
;
3154 /*******************************************************************
3155 * are_files_identical
3157 static int are_files_identical( FILE *file1
, FILE *file2
)
3161 char buffer1
[8192], buffer2
[8192];
3162 int size1
= fread( buffer1
, 1, sizeof(buffer1
), file1
);
3163 int size2
= fread( buffer2
, 1, sizeof(buffer2
), file2
);
3164 if (size1
!= size2
) return 0;
3165 if (!size1
) return feof( file1
) && feof( file2
);
3166 if (memcmp( buffer1
, buffer2
, size1
)) return 0;
3171 /*******************************************************************
3172 * rename_temp_file_if_changed
3174 static void rename_temp_file_if_changed( const char *dest
)
3176 FILE *file1
, *file2
;
3179 if ((file1
= fopen( dest
, "r" )))
3181 if ((file2
= fopen( temp_file_name
, "r" )))
3183 do_rename
= !are_files_identical( file1
, file2
);
3190 unlink( temp_file_name
);
3191 temp_file_name
= NULL
;
3193 else rename_temp_file( dest
);
3197 /*******************************************************************
3200 static void output_testlist( const struct makefile
*make
)
3202 const char *dest
= base_dir_path( make
, "testlist.c" );
3203 struct strarray files
= empty_strarray
;
3204 struct incl_file
*source
;
3207 LIST_FOR_EACH_ENTRY( source
, &make
->sources
, struct incl_file
, entry
)
3209 if (source
->file
->flags
& FLAG_GENERATED
) continue;
3210 if (!strendswith( source
->name
, ".c" )) continue;
3211 strarray_add( &files
, replace_extension( source
->name
, ".c", "" ));
3214 output_file
= create_temp_file( dest
);
3216 output( "/* Automatically generated by make depend; DO NOT EDIT!! */\n\n" );
3217 output( "#define WIN32_LEAN_AND_MEAN\n" );
3218 output( "#include <windows.h>\n\n" );
3219 output( "#define STANDALONE\n" );
3220 output( "#include \"wine/test.h\"\n\n" );
3222 for (i
= 0; i
< files
.count
; i
++) output( "extern void func_%s(void);\n", files
.str
[i
] );
3224 output( "const struct test winetest_testlist[] =\n" );
3226 for (i
= 0; i
< files
.count
; i
++) output( " { \"%s\", func_%s },\n", files
.str
[i
], files
.str
[i
] );
3227 output( " { 0, 0 }\n" );
3230 if (fclose( output_file
)) fatal_perror( "write" );
3232 rename_temp_file_if_changed( dest
);
3236 /*******************************************************************
3239 static void output_gitignore( const char *dest
, struct strarray files
)
3243 output_file
= create_temp_file( dest
);
3245 output( "# Automatically generated by make depend; DO NOT EDIT!!\n" );
3246 for (i
= 0; i
< files
.count
; i
++)
3248 if (!strchr( files
.str
[i
], '/' )) output( "/" );
3249 output( "%s\n", files
.str
[i
] );
3252 if (fclose( output_file
)) fatal_perror( "write" );
3254 rename_temp_file( dest
);
3258 /*******************************************************************
3259 * output_top_variables
3261 static void output_top_variables( const struct makefile
*make
)
3264 struct strarray
*vars
= &top_makefile
->vars
;
3266 if (!make
->base_dir
) return; /* don't output variables in the top makefile */
3268 output( "# Automatically generated by make depend; DO NOT EDIT!!\n\n" );
3269 output( "all:\n\n" );
3270 for (i
= 0; i
< vars
->count
; i
+= 2)
3272 if (!strcmp( vars
->str
[i
], "SUBDIRS" )) continue; /* not inherited */
3273 output( "%s = %s\n", vars
->str
[i
], get_make_variable( make
, vars
->str
[i
] ));
3279 /*******************************************************************
3280 * output_dependencies
3282 static void output_dependencies( const struct makefile
*make
)
3284 struct strarray targets
, ignore_files
= empty_strarray
;
3289 if (make
->base_dir
) create_dir( make
->base_dir
);
3291 output_file_name
= base_dir_path( make
, output_makefile_name
);
3292 output_file
= create_temp_file( output_file_name
);
3293 output_top_variables( make
);
3295 /* copy the contents of the source makefile */
3296 src_file
= open_input_makefile( make
);
3297 while (fgets( buffer
, sizeof(buffer
), src_file
) && !found
)
3299 if (fwrite( buffer
, 1, strlen(buffer
), output_file
) != strlen(buffer
)) fatal_perror( "write" );
3300 found
= !strncmp( buffer
, separator
, strlen(separator
) );
3302 if (fclose( src_file
)) fatal_perror( "close" );
3303 input_file_name
= NULL
;
3305 if (!found
) output( "\n%s (everything below this line is auto-generated; DO NOT EDIT!!)\n", separator
);
3306 targets
= output_sources( make
);
3308 fclose( output_file
);
3310 rename_temp_file( output_file_name
);
3312 strarray_add( &ignore_files
, ".gitignore" );
3313 strarray_add( &ignore_files
, "Makefile" );
3316 output_testlist( make
);
3317 strarray_add( &ignore_files
, "testlist.c" );
3319 strarray_addall( &ignore_files
, targets
);
3320 if (!make
->src_dir
&& make
->base_dir
)
3321 output_gitignore( base_dir_path( make
, ".gitignore" ), ignore_files
);
3323 create_file_directories( make
, targets
);
3325 output_file_name
= NULL
;
3329 /*******************************************************************
3332 static void load_sources( struct makefile
*make
)
3334 static const char *source_vars
[] =
3353 struct strarray value
;
3354 struct incl_file
*file
;
3358 make
->top_src_dir
= concat_paths( make
->top_obj_dir
, root_src_dir
);
3359 make
->src_dir
= concat_paths( make
->top_src_dir
, make
->base_dir
);
3361 strarray_set_value( &make
->vars
, "top_builddir", top_obj_dir_path( make
, "" ));
3362 strarray_set_value( &make
->vars
, "top_srcdir", top_dir_path( make
, "" ));
3363 strarray_set_value( &make
->vars
, "srcdir", src_dir_path( make
, "" ));
3365 make
->parent_dir
= get_expanded_make_variable( make
, "PARENTSRC" );
3366 make
->module
= get_expanded_make_variable( make
, "MODULE" );
3367 make
->testdll
= get_expanded_make_variable( make
, "TESTDLL" );
3368 make
->sharedlib
= get_expanded_make_variable( make
, "SHAREDLIB" );
3369 make
->staticlib
= get_expanded_make_variable( make
, "STATICLIB" );
3370 make
->importlib
= get_expanded_make_variable( make
, "IMPORTLIB" );
3372 make
->programs
= get_expanded_make_var_array( make
, "PROGRAMS" );
3373 make
->scripts
= get_expanded_make_var_array( make
, "SCRIPTS" );
3374 make
->appmode
= get_expanded_make_var_array( make
, "APPMODE" );
3375 make
->imports
= get_expanded_make_var_array( make
, "IMPORTS" );
3376 make
->delayimports
= get_expanded_make_var_array( make
, "DELAYIMPORTS" );
3377 make
->extradllflags
= get_expanded_make_var_array( make
, "EXTRADLLFLAGS" );
3378 make
->install_lib
= get_expanded_make_var_array( make
, "INSTALL_LIB" );
3379 make
->install_dev
= get_expanded_make_var_array( make
, "INSTALL_DEV" );
3381 if (make
->module
&& strendswith( make
->module
, ".a" )) make
->staticlib
= make
->module
;
3383 make
->is_win16
= strarray_exists( &make
->extradllflags
, "-m16" );
3384 make
->use_msvcrt
= strarray_exists( &make
->appmode
, "-mno-cygwin" );
3386 for (i
= 0; i
< make
->imports
.count
&& !make
->use_msvcrt
; i
++)
3387 make
->use_msvcrt
= !strncmp( make
->imports
.str
[i
], "msvcr", 5 ) ||
3388 !strcmp( make
->imports
.str
[i
], "ucrtbase" );
3390 if (make
->module
&& !make
->install_lib
.count
) strarray_add( &make
->install_lib
, make
->module
);
3392 make
->include_paths
= empty_strarray
;
3393 make
->define_args
= empty_strarray
;
3394 strarray_add( &make
->define_args
, "-D__WINESRC__" );
3396 value
= get_expanded_make_var_array( make
, "EXTRAINCL" );
3397 for (i
= 0; i
< value
.count
; i
++)
3398 if (!strncmp( value
.str
[i
], "-I", 2 ))
3399 strarray_add_uniq( &make
->include_paths
, value
.str
[i
] + 2 );
3401 strarray_add_uniq( &make
->define_args
, value
.str
[i
] );
3402 strarray_addall( &make
->define_args
, get_expanded_make_var_array( make
, "EXTRADEFS" ));
3404 list_init( &make
->sources
);
3405 list_init( &make
->includes
);
3407 for (var
= source_vars
; *var
; var
++)
3409 value
= get_expanded_make_var_array( make
, *var
);
3410 for (i
= 0; i
< value
.count
; i
++) add_src_file( make
, value
.str
[i
] );
3413 add_generated_sources( make
);
3415 value
= get_expanded_make_var_array( make
, "EXTRA_OBJS" );
3416 for (i
= 0; i
< value
.count
; i
++)
3418 /* default to .c for unknown extra object files */
3419 if (strendswith( value
.str
[i
], ".o" ))
3420 add_generated_source( make
, value
.str
[i
], replace_extension( value
.str
[i
], ".o", ".c" ) );
3422 add_generated_source( make
, value
.str
[i
], NULL
);
3425 LIST_FOR_EACH_ENTRY( file
, &make
->includes
, struct incl_file
, entry
) parse_file( make
, file
, 0 );
3429 /*******************************************************************
3432 static void parse_makeflags( const char *flags
)
3434 const char *p
= flags
;
3435 char *var
, *buffer
= xmalloc( strlen(flags
) + 1 );
3439 while (isspace(*p
)) p
++;
3441 while (*p
&& !isspace(*p
))
3443 if (*p
== '\\' && p
[1]) p
++;
3447 if (var
> buffer
) set_make_variable( &cmdline_vars
, buffer
);
3452 /*******************************************************************
3455 static int parse_option( const char *opt
)
3459 if (strchr( opt
, '=' )) return set_make_variable( &cmdline_vars
, opt
);
3465 if (opt
[2]) output_makefile_name
= opt
+ 2;
3468 relative_dir_mode
= 1;
3471 fprintf( stderr
, "Unknown option '%s'\n%s", opt
, Usage
);
3478 /*******************************************************************
3481 int main( int argc
, char *argv
[] )
3483 const char *makeflags
= getenv( "MAKEFLAGS" );
3486 if (makeflags
) parse_makeflags( makeflags
);
3491 if (parse_option( argv
[i
] ))
3493 for (j
= i
; j
< argc
; j
++) argv
[j
] = argv
[j
+1];
3499 if (relative_dir_mode
)
3505 fprintf( stderr
, "Option -R needs two directories\n%s", Usage
);
3508 relpath
= get_relative_path( argv
[1], argv
[2] );
3509 printf( "%s\n", relpath
? relpath
: "." );
3513 atexit( cleanup_files
);
3514 signal( SIGTERM
, exit_on_signal
);
3515 signal( SIGINT
, exit_on_signal
);
3517 signal( SIGHUP
, exit_on_signal
);
3520 for (i
= 0; i
< HASH_SIZE
; i
++) list_init( &files
[i
] );
3522 top_makefile
= parse_makefile( NULL
);
3524 linguas
= get_expanded_make_var_array( top_makefile
, "LINGUAS" );
3525 target_flags
= get_expanded_make_var_array( top_makefile
, "TARGETFLAGS" );
3526 msvcrt_flags
= get_expanded_make_var_array( top_makefile
, "MSVCRTFLAGS" );
3527 dll_flags
= get_expanded_make_var_array( top_makefile
, "DLLFLAGS" );
3528 extra_cflags
= get_expanded_make_var_array( top_makefile
, "EXTRACFLAGS" );
3529 cpp_flags
= get_expanded_make_var_array( top_makefile
, "CPPFLAGS" );
3530 unwind_flags
= get_expanded_make_var_array( top_makefile
, "UNWINDFLAGS" );
3531 libs
= get_expanded_make_var_array( top_makefile
, "LIBS" );
3533 root_src_dir
= get_expanded_make_variable( top_makefile
, "srcdir" );
3534 tools_dir
= get_expanded_make_variable( top_makefile
, "TOOLSDIR" );
3535 tools_ext
= get_expanded_make_variable( top_makefile
, "TOOLSEXT" );
3536 exe_ext
= get_expanded_make_variable( top_makefile
, "EXEEXT" );
3537 man_ext
= get_expanded_make_variable( top_makefile
, "api_manext" );
3538 dll_ext
= (exe_ext
&& !strcmp( exe_ext
, ".exe" )) ? "" : ".so";
3539 crosstarget
= get_expanded_make_variable( top_makefile
, "CROSSTARGET" );
3540 fontforge
= get_expanded_make_variable( top_makefile
, "FONTFORGE" );
3541 convert
= get_expanded_make_variable( top_makefile
, "CONVERT" );
3542 rsvg
= get_expanded_make_variable( top_makefile
, "RSVG" );
3543 icotool
= get_expanded_make_variable( top_makefile
, "ICOTOOL" );
3544 dlltool
= get_expanded_make_variable( top_makefile
, "DLLTOOL" );
3545 msgfmt
= get_expanded_make_variable( top_makefile
, "MSGFMT" );
3546 ln_s
= get_expanded_make_variable( top_makefile
, "LN_S" );
3548 if (root_src_dir
&& !strcmp( root_src_dir
, "." )) root_src_dir
= NULL
;
3549 if (tools_dir
&& !strcmp( tools_dir
, "." )) tools_dir
= NULL
;
3550 if (!exe_ext
) exe_ext
= "";
3551 if (!tools_ext
) tools_ext
= "";
3552 if (!man_ext
) man_ext
= "3w";
3556 top_makefile
->subdirs
= get_expanded_make_var_array( top_makefile
, "SUBDIRS" );
3557 top_makefile
->submakes
= xmalloc( top_makefile
->subdirs
.count
* sizeof(*top_makefile
->submakes
) );
3559 for (i
= 0; i
< top_makefile
->subdirs
.count
; i
++)
3560 top_makefile
->submakes
[i
] = parse_makefile( top_makefile
->subdirs
.str
[i
] );
3562 load_sources( top_makefile
);
3563 for (i
= 0; i
< top_makefile
->subdirs
.count
; i
++)
3564 load_sources( top_makefile
->submakes
[i
] );
3566 for (i
= 0; i
< top_makefile
->subdirs
.count
; i
++)
3567 output_dependencies( top_makefile
->submakes
[i
] );
3569 output_dependencies( top_makefile
);
3573 for (i
= 1; i
< argc
; i
++)
3575 struct makefile
*make
= parse_makefile( argv
[i
] );
3576 load_sources( make
);
3577 output_dependencies( make
);