makefiles: Generate individual .gitignore files corresponding to the build targets.

This commit is contained in:
Alexandre Julliard 2013-12-13 20:37:26 +01:00
parent a8b633b1a1
commit 3bcad54fc6
9 changed files with 91 additions and 405 deletions

285
.gitignore vendored
View File

@ -1,12 +1,8 @@
# Automatically generated by make_makefiles; DO NOT EDIT!! # Automatically generated by make_makefiles; DO NOT EDIT!!
*.[oa] *.a
*.exe *.exe
*.fake *.fake
*.man
*.ok
*.res
*.so *.so
*/*/tests/testlist.c
/Make.rules /Make.rules
/TAGS /TAGS
/autom4te.cache /autom4te.cache
@ -18,290 +14,27 @@
/wine /wine
/wine64 /wine64
Makefile Makefile
dlldata.c
dlls/*/*.def dlls/*/*.def
dlls/actxprxy/actxprxy_activscp.h
dlls/actxprxy/actxprxy_activscp_p.c
dlls/actxprxy/actxprxy_comcat.h
dlls/actxprxy/actxprxy_comcat_p.c
dlls/actxprxy/actxprxy_docobj.h
dlls/actxprxy/actxprxy_docobj_p.c
dlls/actxprxy/actxprxy_hlink.h
dlls/actxprxy/actxprxy_hlink_p.c
dlls/actxprxy/actxprxy_htiface.h
dlls/actxprxy/actxprxy_htiface_p.c
dlls/actxprxy/actxprxy_htiframe.h
dlls/actxprxy/actxprxy_htiframe_p.c
dlls/actxprxy/actxprxy_objsafe.h
dlls/actxprxy/actxprxy_objsafe_p.c
dlls/actxprxy/actxprxy_ocmm.h
dlls/actxprxy/actxprxy_ocmm_p.c
dlls/actxprxy/actxprxy_servprov.h
dlls/actxprxy/actxprxy_servprov_p.c
dlls/actxprxy/actxprxy_shldisp.h
dlls/actxprxy/actxprxy_shldisp_p.c
dlls/actxprxy/actxprxy_shobjidl.h
dlls/actxprxy/actxprxy_shobjidl_p.c
dlls/actxprxy/actxprxy_urlhist.h
dlls/actxprxy/actxprxy_urlhist_p.c
dlls/advapi32/svcctl.h
dlls/advapi32/svcctl_c.c
dlls/d3dcompiler_43/asmshader.tab.c
dlls/d3dcompiler_43/asmshader.tab.h
dlls/d3dcompiler_43/asmshader.yy.c
dlls/d3dcompiler_43/hlsl.tab.c
dlls/d3dcompiler_43/hlsl.tab.h
dlls/d3dcompiler_43/hlsl.yy.c
dlls/dispex/disp_ex.h
dlls/dispex/disp_ex_p.c
dlls/dxdiagn/fil_data.h
dlls/infosoft/infosoft.h
dlls/jscript/jscript_classes.h
dlls/jscript/parser.tab.c
dlls/jscript/parser.tab.h
dlls/libd3dcompiler.def dlls/libd3dcompiler.def
dlls/libd3dx9.def dlls/libd3dx9.def
dlls/libhtmlhelp.def dlls/libhtmlhelp.def
dlls/libkernel.def dlls/libkernel.def
dlls/libwinspool.def dlls/libwinspool.def
dlls/libxinput.def dlls/libxinput.def
dlls/msdaps/msdaps.h fonts/*.fon
dlls/msdaps/msdaps_p.c
dlls/msdaps/row_server.h
dlls/msdaps/row_server_p.c
dlls/mshtml/nsiface.h
dlls/mshtml/tests/test_tlb.h
dlls/mshtml/tests/test_tlb.tlb
dlls/msi/cond.tab.c
dlls/msi/cond.tab.h
dlls/msi/msiserver.h
dlls/msi/msiserver_i.c
dlls/msi/sql.tab.c
dlls/msi/sql.tab.h
dlls/mstask/mstask_local.h
dlls/mstask/mstask_local_i.c
dlls/msxml3/tests/xmlparser.h
dlls/msxml3/xmlparser.h
dlls/msxml3/xslpattern.tab.c
dlls/msxml3/xslpattern.tab.h
dlls/msxml3/xslpattern.yy.c
dlls/ole32/dcom.h
dlls/ole32/dcom_p.c
dlls/ole32/irot.h
dlls/ole32/irot_c.c
dlls/ole32/ole32_objidl.h
dlls/ole32/ole32_objidl_p.c
dlls/ole32/ole32_oleidl.h
dlls/ole32/ole32_oleidl_p.c
dlls/ole32/ole32_unknwn.h
dlls/ole32/ole32_unknwn_p.c
dlls/oleaut32/oleaut32_oaidl.h
dlls/oleaut32/oleaut32_oaidl_p.c
dlls/oleaut32/oleaut32_ocidl.h
dlls/oleaut32/oleaut32_ocidl_p.c
dlls/oleaut32/tests/test_reg.h
dlls/oleaut32/tests/test_reg.tlb
dlls/oleaut32/tests/test_reg_i.c
dlls/oleaut32/tests/test_tlb.tlb
dlls/oleaut32/tests/tmarshal.h
dlls/oleaut32/tests/tmarshal.tlb
dlls/oleaut32/tests/tmarshal_i.c
dlls/oledb32/convert.h
dlls/oledb32/convert_i.c
dlls/oledb32/tests/convert.h
dlls/oledb32/tests/convert_i.c
dlls/qmgr/qmgr_local.h
dlls/qmgr/qmgr_local_i.c
dlls/qmgrprxy/qmgrprxy.h
dlls/qmgrprxy/qmgrprxy_i.c
dlls/qmgrprxy/qmgrprxy_p.c
dlls/quartz/fil_data.h
dlls/quartz/quartz_strmif.h
dlls/quartz/quartz_strmif_p.c
dlls/quartz/tests/fil_data.h
dlls/rpcrt4/epm.h
dlls/rpcrt4/epm_c.c
dlls/rpcrt4/tests/server.h
dlls/rpcrt4/tests/server_c.c
dlls/rpcrt4/tests/server_s.c
dlls/scrrun/scrrun.h
dlls/scrrun/tests/scrrun.h
dlls/sti/sti_wia.h
dlls/sti/sti_wia_p.c
dlls/urlmon/urlmon_urlmon.h
dlls/urlmon/urlmon_urlmon_p.c
dlls/vbscript/parser.tab.c
dlls/vbscript/parser.tab.h
dlls/vbscript/tests/vbsregexp55.h
dlls/vbscript/vbscript_classes.h
dlls/vbscript/vbsglobal.h
dlls/vbscript/vbsregexp55.h
dlls/wbemdisp/wbemdisp_classes.h
dlls/wbemprox/wql.tab.c
dlls/wbemprox/wql.tab.h
dlls/windowscodecs/windowscodecs_wincodec.h
dlls/windowscodecs/windowscodecs_wincodec_p.c
dlls/wshom.ocx/tests/wshom.h
dlls/wshom.ocx/wshom.h
include/activaut.h
include/activdbg.h
include/activscp.h
include/amstream.h
include/amvideo.h
include/asptlb.h
include/atliface.h
include/audioclient.h
include/audiopolicy.h
include/austream.h
include/bdaiface.h
include/bits.h
include/bits1_5.h
include/bits3_0.h
include/comcat.h
include/commoncontrols.h
include/config.h include/config.h
include/control.h
include/cor.h
include/cordebug.h
include/ctfutb.h
include/ctxtcall.h
include/d3d10.h
include/d3d10_1.h
include/d3d11.h
include/d3d11sdklayers.h
include/d3dcommon.h
include/ddstream.h
include/devicetopology.h
include/dimm.h
include/dispex.h
include/docobj.h
include/docobjectservice.h
include/downloadmgr.h
include/dwrite.h
include/dwrite_1.h
include/dxgi.h
include/endpointvolume.h
include/exdisp.h
include/fusion.h
include/gameux.h
include/hlink.h
include/htiface.h
include/htiframe.h
include/httprequest.h
include/iads.h
include/icftypes.h
include/iextag.h
include/imnact.h
include/imnxport.h
include/indexsrv.h
include/inputscope.h
include/mediaobj.h
include/metahost.h
include/mimeinfo.h
include/mimeole.h
include/mlang.h
include/mmc.h
include/mmdeviceapi.h
include/mmstream.h
include/mscoree.h
include/msctf.h
include/msdadc.h
include/msdasc.h
include/mshtmhst.h
include/mshtml.h
include/msident.h
include/msinkaut.h
include/mstask.h
include/msxml.h
include/msxml2.h
include/msxml6.h
include/netcon.h
include/netfw.h
include/oaidl.h
include/objectarray.h
include/objidl.h
include/objsafe.h
include/ocidl.h
include/ocmm.h
include/oleacc.h
include/oledb.h
include/oleidl.h
include/optary.h
include/perhist.h
include/propidl.h
include/propsys.h
include/pstore.h
include/qedit.h
include/richole.h
include/rmxftmpl.h
include/sensevts.h
include/servprov.h
include/shdeprecated.h
include/shldisp.h
include/shobjidl.h
include/shtypes.h
include/stamp-h include/stamp-h
include/stdole2.tlb libs/wine/libwine*.dylib
include/strmif.h libs/wine/libwine.so.*
include/structuredquerycondition.h libs/wine/version.c
include/taskschd.h
include/textstor.h
include/tlogstg.h
include/tom.h
include/transact.h
include/txcoord.h
include/txdtc.h
include/uiautomationclient.h
include/uiautomationcore.h
include/unknwn.h
include/urlhist.h
include/urlmon.h
include/vmr9.h
include/wbemcli.h
include/wbemdisp.h
include/wbemprov.h
include/wia_lh.h
include/wia_xp.h
include/wincodec.h
include/wincodecsdk.h
include/wine/itss.h
include/wine/svcctl.h
include/wine/winedxgi.h
include/winsxs.h
include/wmiutils.h
include/wmsbuffer.h
include/wmsdkidl.h
include/wpcapi.h
include/wtypes.h
include/wuapi.h
include/xmllite.h
libs/wpp/ppl.yy.c
libs/wpp/ppy.tab.c
libs/wpp/ppy.tab.h
loader/wine loader/wine
loader/wine-installed loader/wine-installed
loader/wine-preloader loader/wine-preloader
loader/wine.inf
loader/wine64 loader/wine64
loader/wine64-preloader loader/wine64-preloader
loader/wine_info.plist
msg.pot
po/*.mo po/*.mo
programs/rpcss/epm.h
programs/rpcss/epm_s.c
programs/rpcss/irot.h
programs/rpcss/irot_s.c
programs/services/svcctl.h
programs/services/svcctl_s.c
programs/winedbg/dbg.tab.c
programs/winedbg/dbg.tab.h
programs/winedbg/debug.yy.c
programs/winetest/build.nfo programs/winetest/build.nfo
programs/winetest/build.rc programs/winetest/build.rc
programs/winhlp32/macro.lex.yy.c
programs/wscript/ihost.h
programs/wscript/ihost.tlb
rsrc.pot
server/wineserver server/wineserver
server/wineserver-installed server/wineserver-installed
tools/fnt2fon tools/fnt2fon
@ -309,9 +42,6 @@ tools/make_ctests
tools/make_xftmpl tools/make_xftmpl
tools/makedep tools/makedep
tools/sfnt2fnt tools/sfnt2fnt
tools/widl/parser.tab.c
tools/widl/parser.tab.h
tools/widl/parser.yy.c
tools/widl/widl tools/widl/widl
tools/wineapploader tools/wineapploader
tools/winebuild/winebuild tools/winebuild/winebuild
@ -319,10 +49,5 @@ tools/winedump/winedump
tools/winegcc/winecpp tools/winegcc/winecpp
tools/winegcc/wineg++ tools/winegcc/wineg++
tools/winegcc/winegcc tools/winegcc/winegcc
tools/wmc/mcy.tab.c
tools/wmc/mcy.tab.h
tools/wmc/wmc tools/wmc/wmc
tools/wrc/parser.tab.c
tools/wrc/parser.tab.h
tools/wrc/parser.yy.c
tools/wrc/wrc tools/wrc/wrc

10
aclocal.m4 vendored
View File

@ -304,6 +304,8 @@ install-dev:: $ac_dir/install-dev"
wine_fn_clean_rules () wine_fn_clean_rules ()
{ {
ac_clean=$[@] ac_clean=$[@]
ac_extraclean="$ac_dir/Makefile"
test "$srcdir" = . && ac_extraclean="$ac_extraclean $ac_dir/.gitignore"
if wine_fn_has_flag clean if wine_fn_has_flag clean
then then
@ -312,25 +314,27 @@ wine_fn_clean_rules ()
.PHONY: $ac_dir/clean .PHONY: $ac_dir/clean
$ac_dir/clean: $ac_dir/Makefile $ac_dir/clean: $ac_dir/Makefile
@cd $ac_dir && \$(MAKE) clean @cd $ac_dir && \$(MAKE) clean
\$(RM) $ac_dir/Makefile" \$(RM) $ac_extraclean"
else else
wine_fn_append_rule \ wine_fn_append_rule \
"__clean__: $ac_dir/clean "__clean__: $ac_dir/clean
.PHONY: $ac_dir/clean .PHONY: $ac_dir/clean
$ac_dir/clean: dummy $ac_dir/clean: dummy
\$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_dir/Makefile" \$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_extraclean"
fi fi
} }
wine_fn_disabled_rules () wine_fn_disabled_rules ()
{ {
ac_clean=$[@] ac_clean=$[@]
ac_extraclean="$ac_dir/Makefile"
test "$srcdir" = . && ac_extraclean="$ac_extraclean $ac_dir/.gitignore"
wine_fn_append_rule \ wine_fn_append_rule \
"__clean__: $ac_dir/clean "__clean__: $ac_dir/clean
.PHONY: $ac_dir/clean .PHONY: $ac_dir/clean
$ac_dir/clean: dummy $ac_dir/clean: dummy
\$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_dir/Makefile" \$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_extraclean"
} }
wine_fn_config_makefile () wine_fn_config_makefile ()

10
configure vendored
View File

@ -16298,6 +16298,8 @@ install-dev:: $ac_dir/install-dev"
wine_fn_clean_rules () wine_fn_clean_rules ()
{ {
ac_clean=$@ ac_clean=$@
ac_extraclean="$ac_dir/Makefile"
test "$srcdir" = . && ac_extraclean="$ac_extraclean $ac_dir/.gitignore"
if wine_fn_has_flag clean if wine_fn_has_flag clean
then then
@ -16306,25 +16308,27 @@ wine_fn_clean_rules ()
.PHONY: $ac_dir/clean .PHONY: $ac_dir/clean
$ac_dir/clean: $ac_dir/Makefile $ac_dir/clean: $ac_dir/Makefile
@cd $ac_dir && \$(MAKE) clean @cd $ac_dir && \$(MAKE) clean
\$(RM) $ac_dir/Makefile" \$(RM) $ac_extraclean"
else else
wine_fn_append_rule \ wine_fn_append_rule \
"__clean__: $ac_dir/clean "__clean__: $ac_dir/clean
.PHONY: $ac_dir/clean .PHONY: $ac_dir/clean
$ac_dir/clean: dummy $ac_dir/clean: dummy
\$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_dir/Makefile" \$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_extraclean"
fi fi
} }
wine_fn_disabled_rules () wine_fn_disabled_rules ()
{ {
ac_clean=$@ ac_clean=$@
ac_extraclean="$ac_dir/Makefile"
test "$srcdir" = . && ac_extraclean="$ac_extraclean $ac_dir/.gitignore"
wine_fn_append_rule \ wine_fn_append_rule \
"__clean__: $ac_dir/clean "__clean__: $ac_dir/clean
.PHONY: $ac_dir/clean .PHONY: $ac_dir/clean
$ac_dir/clean: dummy $ac_dir/clean: dummy
\$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_dir/Makefile" \$(RM) \$(CLEAN_FILES:%=$ac_dir/%) $ac_clean $ac_extraclean"
} }
wine_fn_config_makefile () wine_fn_config_makefile ()

View File

@ -1 +0,0 @@
/html

50
fonts/.gitignore vendored
View File

@ -1,50 +0,0 @@
/coue1255.fon
/coue1256.fon
/coue1257.fon
/coure.fon
/couree.fon
/coureg.fon
/courer.fon
/couret.fon
/cvgasys.fon
/hvgasys.fon
/jsmalle.fon
/jvgafix.fon
/jvgasys.fon
/smae1255.fon
/smae1256.fon
/smae1257.fon
/smalle.fon
/smallee.fon
/smalleg.fon
/smaller.fon
/smallet.fon
/ssee1255.fon
/ssee1256.fon
/ssee1257.fon
/ssee874.fon
/ssef1255.fon
/ssef1256.fon
/ssef1257.fon
/ssef874.fon
/sserife.fon
/sserifee.fon
/sserifeg.fon
/sserifer.fon
/sserifet.fon
/sseriff.fon
/sseriffe.fon
/sseriffg.fon
/sseriffr.fon
/sserifft.fon
/svgasys.fon
/vgafix.fon
/vgas1255.fon
/vgas1256.fon
/vgas1257.fon
/vgas874.fon
/vgasys.fon
/vgasyse.fon
/vgasysg.fon
/vgasysr.fon
/vgasyst.fon

3
libs/.gitignore vendored
View File

@ -1,3 +0,0 @@
*.dylib
*.so.*
wine/version.c

View File

@ -9,8 +9,6 @@ PROGRAMS = \
wine \ wine \
wine-installed \ wine-installed \
wine-preloader \ wine-preloader \
wine.inf \
wine_info.plist \
wine64 \ wine64 \
wine64-preloader wine64-preloader

View File

@ -68,12 +68,9 @@ my %modules16 =
# Default patterns for top-level .gitignore # Default patterns for top-level .gitignore
my @ignores = ( my @ignores = (
"*.[oa]", "*.a",
"*.exe", "*.exe",
"*.fake", "*.fake",
"*.man",
"*.ok",
"*.res",
"*.so", "*.so",
"/autom4te.cache", "/autom4te.cache",
"/config.cache", "/config.cache",
@ -85,39 +82,19 @@ my @ignores = (
"/wine", "/wine",
"/wine64", "/wine64",
"Makefile", "Makefile",
"dlldata.c",
"dlls/*/*.def", "dlls/*/*.def",
"*/*/tests/testlist.c", "fonts/*.fon",
"include/config.h", "include/config.h",
"include/stamp-h", "include/stamp-h",
"msg.pot", "libs/wine/libwine*.dylib",
"libs/wine/libwine.so.*",
"libs/wine/version.c",
"po/*.mo", "po/*.mo",
"programs/winetest/build.nfo", "programs/winetest/build.nfo",
"programs/winetest/build.rc", "programs/winetest/build.rc",
"rsrc.pot",
"tools/makedep", "tools/makedep",
); );
# Source files and their resulting target to ignore
my @ignore_srcs = (
[ 'BISON_SRCS', '\.y', '.tab.c' ],
[ 'BISON_SRCS', '\.y', '.tab.h' ],
[ 'LEX_SRCS', '\.l', '.yy.c' ],
[ 'IDL_TLB_SRCS', '\.idl', '.tlb' ],
[ 'IDL_H_SRCS', '\.idl', '.h' ],
[ 'IDL_C_SRCS', '\.idl', '.h' ],
[ 'IDL_I_SRCS', '\.idl', '.h' ],
[ 'IDL_P_SRCS', '\.idl', '.h' ],
[ 'IDL_S_SRCS', '\.idl', '.h' ],
[ 'IDL_C_SRCS', '\.idl', '_c.c' ],
[ 'IDL_I_SRCS', '\.idl', '_i.c' ],
[ 'IDL_P_SRCS', '\.idl', '_p.c' ],
[ 'IDL_S_SRCS', '\.idl', '_s.c' ],
[ 'PUBLIC_IDL_H_SRCS', '\.idl', '.h' ],
[ 'PRIVATE_IDL_H_SRCS', '\.idl', '.h' ],
[ 'XTEMPLATE_SRCS', '\.x', '.h' ],
);
my %exported_wine_headers = ( my %exported_wine_headers = (
"wine/debug.h" => 1, "wine/debug.h" => 1,
"wine/exception.h" => 1, "wine/exception.h" => 1,
@ -649,19 +626,6 @@ sub update_ignores(@)
foreach my $file (sort @_) foreach my $file (sort @_)
{ {
my %makefile = %{$makefiles{$file}}; my %makefile = %{$makefiles{$file}};
my @list;
foreach my $src (@ignore_srcs)
{
my @pattern = @{$src};
next unless defined $makefile{$pattern[0]};
next if $pattern[0] eq "IDL_TLB_SRCS" && $makefile{"=rules"} eq "MAKE_DLL_RULES";
push @list, map { (my $ret = $_) =~ s/$pattern[1]$/$pattern[2]/; $ret; } @{$makefile{$pattern[0]}};
}
foreach my $f (@list)
{
push @ignores, $makefile{"=dir"} . $f unless $f =~ /\$\(.*\)/; # skip make variables
}
if (defined $makefile{"IMPORTLIB"}) if (defined $makefile{"IMPORTLIB"})
{ {

View File

@ -1166,7 +1166,7 @@ static void output_include( struct incl_file *pFile, struct incl_file *owner, in
/******************************************************************* /*******************************************************************
* output_sources * output_sources
*/ */
static void output_sources(void) static struct strarray output_sources(void)
{ {
struct incl_file *source; struct incl_file *source;
struct strarray clean_files, subdirs; struct strarray clean_files, subdirs;
@ -1321,6 +1321,7 @@ static void output_sources(void)
} }
else if (!strcmp( ext, "tlb" ) || !strcmp( ext, "res" ) || !strcmp( ext, "pot" )) else if (!strcmp( ext, "tlb" ) || !strcmp( ext, "res" ) || !strcmp( ext, "pot" ))
{ {
strarray_add( &clean_files, source->name );
continue; /* nothing to do for typelib files */ continue; /* nothing to do for typelib files */
} }
else else
@ -1409,11 +1410,15 @@ static void output_sources(void)
if (strendswith( source->name, ".c" ) && !is_generated_idl( source )) if (strendswith( source->name, ".c" ) && !is_generated_idl( source ))
output_filename( replace_extension( source->name, 2, ".ok" ), &column ); output_filename( replace_extension( source->name, 2, ".ok" ), &column );
output( "\n" ); output( "\n" );
output( "clean testclean::\n" ); output( "testclean::\n" );
column = output( "\t$(RM)" ); column = output( "\t$(RM)" );
LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry ) LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry )
if (strendswith( source->name, ".c" ) && !is_generated_idl( source )) if (strendswith( source->name, ".c" ) && !is_generated_idl( source ))
output_filename( replace_extension( source->name, 2, ".ok" ), &column ); {
char *ok_file = replace_extension( source->name, 2, ".ok" );
output_filename( ok_file, &column );
strarray_add( &clean_files, ok_file );
}
output( "\n" ); output( "\n" );
strarray_add( &clean_files, "testlist.c" ); strarray_add( &clean_files, "testlist.c" );
} }
@ -1432,22 +1437,23 @@ static void output_sources(void)
output( ":\n" ); output( ":\n" );
output( "\t$(MKDIR_P) -m 755 $@\n" ); output( "\t$(MKDIR_P) -m 755 $@\n" );
} }
return clean_files;
} }
/******************************************************************* /*******************************************************************
* create_temp_file * create_temp_file
*/ */
static FILE *create_temp_file( char **tmp_name ) static FILE *create_temp_file( const char *orig, char **tmp_name )
{ {
char *name = xmalloc( strlen(OutputFileName) + 13 ); char *name = xmalloc( strlen(orig) + 13 );
unsigned int i, id = getpid(); unsigned int i, id = getpid();
int fd; int fd;
FILE *ret = NULL; FILE *ret = NULL;
for (i = 0; i < 100; i++) for (i = 0; i < 100; i++)
{ {
sprintf( name, "%s.tmp%08x", OutputFileName, id ); sprintf( name, "%s.tmp%08x", orig, id );
if ((fd = open( name, O_RDWR | O_CREAT | O_EXCL, 0666 )) != -1) if ((fd = open( name, O_RDWR | O_CREAT | O_EXCL, 0666 )) != -1)
{ {
ret = fdopen( fd, "w" ); ret = fdopen( fd, "w" );
@ -1456,23 +1462,72 @@ static FILE *create_temp_file( char **tmp_name )
if (errno != EEXIST) break; if (errno != EEXIST) break;
id += 7777; id += 7777;
} }
if (!ret) fatal_error( "failed to create output file for '%s'\n", OutputFileName ); if (!ret) fatal_error( "failed to create output file for '%s'\n", orig );
*tmp_name = name; *tmp_name = name;
return ret; return ret;
} }
/*******************************************************************
* rename_temp_file
*/
static void rename_temp_file( const char *tmp_name, const char *dest )
{
int ret = rename( tmp_name, dest );
if (ret == -1 && errno == EEXIST)
{
/* rename doesn't overwrite on windows */
unlink( dest );
ret = rename( tmp_name, dest );
}
if (ret == -1)
{
unlink( tmp_name );
fatal_error( "failed to rename output file to '%s'\n", dest );
}
}
/*******************************************************************
* output_gitignore
*/
static void output_gitignore( const char *dest, const struct strarray *files )
{
char *tmp_name;
int i;
output_file = create_temp_file( dest, &tmp_name );
output( "# Automatically generated by make depend; DO NOT EDIT!!\n" );
output( "/.gitignore\n" );
output( "/Makefile\n" );
for (i = 0; i < files->count; i++)
{
if (!strchr( files->str[i], '/' )) output( "/" );
output( "%s\n", files->str[i] );
}
fclose( output_file );
output_file = NULL;
rename_temp_file( tmp_name, dest );
free( tmp_name );
}
/******************************************************************* /*******************************************************************
* output_dependencies * output_dependencies
*/ */
static void output_dependencies(void) static void output_dependencies(void)
{ {
char *tmp_name = NULL; char *tmp_name = NULL;
struct strarray targets;
strarray_init( &targets );
if (Separator && ((output_file = fopen( OutputFileName, "r" )))) if (Separator && ((output_file = fopen( OutputFileName, "r" ))))
{ {
char buffer[1024]; char buffer[1024];
FILE *tmp_file = create_temp_file( &tmp_name ); FILE *tmp_file = create_temp_file( OutputFileName, &tmp_name );
int found = 0; int found = 0;
while (fgets( buffer, sizeof(buffer), output_file ) && !found) while (fgets( buffer, sizeof(buffer), output_file ) && !found)
@ -1491,27 +1546,17 @@ static void output_dependencies(void)
fatal_perror( "%s", OutputFileName ); fatal_perror( "%s", OutputFileName );
} }
if (!list_empty( &sources )) output_sources(); if (!list_empty( &sources )) targets = output_sources();
fclose( output_file ); fclose( output_file );
output_file = NULL; output_file = NULL;
if (tmp_name) if (tmp_name)
{ {
int ret = rename( tmp_name, OutputFileName ); rename_temp_file( tmp_name, OutputFileName );
if (ret == -1 && errno == EEXIST)
{
/* rename doesn't overwrite on windows */
unlink( OutputFileName );
ret = rename( tmp_name, OutputFileName );
}
if (ret == -1)
{
unlink( tmp_name );
fatal_error( "failed to rename output file to '%s'\n", OutputFileName );
}
free( tmp_name ); free( tmp_name );
} }
if (!src_dir) output_gitignore( ".gitignore", &targets );
} }