makefiles: Generate the uninstall rule using the subdirs file lists.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-02-21 12:29:06 +01:00
parent 832a40109e
commit 1a52ba0bc8
4 changed files with 132 additions and 143 deletions

View File

@ -118,13 +118,6 @@ include/stamp-h: $(srcdir)/include/config.h.in config.status
distclean:: clean distclean:: clean
$(RM) -r autom4te.cache documentation/html documentation/api-guide documentation/api-guide-xml documentation/man$(api_manext) $(RM) -r autom4te.cache documentation/html documentation/api-guide documentation/api-guide-xml documentation/man$(api_manext)
# Rules for uninstalling
.PHONY: install install-lib install-dev uninstall __uninstall__
uninstall:: __uninstall__
-rmdir $(DESTDIR)$(fontdir) $(DESTDIR)$(datadir)/wine $(DESTDIR)$(fakedlldir) $(DESTDIR)$(dlldir) $(DESTDIR)$(includedir)/windows/ddk \
$(DESTDIR)$(includedir)/windows $(DESTDIR)$(includedir)/msvcrt/sys $(DESTDIR)$(includedir)/msvcrt $(DESTDIR)$(includedir)
# Rules for API documentation # Rules for API documentation
install-manpages:: manpages install-manpages:: manpages
@ -137,7 +130,7 @@ install-manpages:: manpages
# dependencies needed to build any dll or program # dependencies needed to build any dll or program
__tooldeps__: libs/port libs/wpp __tooldeps__: libs/port libs/wpp
__builddeps__: __tooldeps__ libs/wine include po __builddeps__: __tooldeps__ libs/wine include po
.PHONY: depend dummy check test testclean crosstest __tooldeps__ __builddeps__ .PHONY: depend dummy check test crosstest __tooldeps__ __builddeps__ install install-lib install-dev
dummy: dummy:
loader: libs/port libs/wine tools loader: libs/port libs/wine tools

60
aclocal.m4 vendored
View File

@ -250,13 +250,10 @@ wine_fn_install_rules ()
wine_fn_has_flag install-lib || wine_fn_has_flag install-dev || return wine_fn_has_flag install-lib || wine_fn_has_flag install-dev || return
wine_fn_append_rule \ wine_fn_append_rule \
".PHONY: $ac_dir/install $ac_dir/uninstall ".PHONY: $ac_dir/install
$ac_dir/install:: $ac_dir $ac_dir/install:: $ac_dir
@cd $ac_dir && \$(MAKE) install @cd $ac_dir && \$(MAKE) install
$ac_dir/uninstall:: install:: $ac_dir/install"
@cd $ac_dir && \$(MAKE) uninstall
install:: $ac_dir/install
__uninstall__: $ac_dir/uninstall"
if wine_fn_has_flag install-lib if wine_fn_has_flag install-lib
then then
@ -309,13 +306,10 @@ wine_fn_config_lib ()
wine_fn_all_rules wine_fn_all_rules
wine_fn_append_rule \ wine_fn_append_rule \
".PHONY: $ac_dir/install $ac_dir/uninstall ".PHONY: $ac_dir/install
$ac_dir/install:: $ac_dir $ac_dir/install:: $ac_dir
\$(INSTALL_DATA) $ac_dir/lib$ac_name.a \$(DESTDIR)\$(dlldir)/lib$ac_name.a \$(INSTALL_DATA) $ac_dir/lib$ac_name.a \$(DESTDIR)\$(dlldir)/lib$ac_name.a
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/lib$ac_name.a
install install-dev:: $ac_dir/install install install-dev:: $ac_dir/install
__uninstall__: $ac_dir/uninstall
__builddeps__: $ac_dir __builddeps__: $ac_dir
$ac_dir: $ac_deps" $ac_dir: $ac_deps"
} }
@ -355,23 +349,18 @@ wine_fn_config_dll ()
"$ac_dir: __builddeps__ "$ac_dir: __builddeps__
manpages htmlpages sgmlpages xmlpages:: manpages htmlpages sgmlpages xmlpages::
@cd $ac_dir && \$(MAKE) \$[@] @cd $ac_dir && \$(MAKE) \$[@]
.PHONY: $ac_dir/install-lib $ac_dir/uninstall .PHONY: $ac_dir/install-lib
install install-lib:: $ac_dir/install-lib install install-lib:: $ac_dir/install-lib"
__uninstall__: $ac_dir/uninstall"
if test -n "$DLLEXT" if test -n "$DLLEXT"
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install-lib:: $ac_dir "$ac_dir/install-lib:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_dll$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_dll$DLLEXT \$(INSTALL_PROGRAM) $ac_dir/$ac_dll$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_dll$DLLEXT
\$(INSTALL_DATA) $ac_dir/$ac_dll.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_dll \$(INSTALL_DATA) $ac_dir/$ac_dll.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_dll"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/$ac_dll$DLLEXT \$(DESTDIR)\$(dlldir)/fakedlls/$ac_dll"
else else
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install-lib:: $ac_dir "$ac_dir/install-lib:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_dll \$(DESTDIR)\$(dlldir)/$ac_dll \$(INSTALL_PROGRAM) $ac_dir/$ac_dll \$(DESTDIR)\$(dlldir)/$ac_dll"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/$ac_dll"
fi]) fi])
if wine_fn_has_flag staticimplib if wine_fn_has_flag staticimplib
@ -381,13 +370,10 @@ $ac_dir/uninstall::
$ac_file.a $ac_file.cross.a: $ac_deps $ac_file.a $ac_file.cross.a: $ac_deps
$ac_file.a: dummy $ac_file.a: dummy
@cd $ac_dir && \$(MAKE) lib$ac_implib.a @cd $ac_dir && \$(MAKE) lib$ac_implib.a
.PHONY: $ac_dir/install-dev $ac_dir/uninstall .PHONY: $ac_dir/install-dev
$ac_dir/install-dev:: $ac_file.a $ac_dir/install-dev:: $ac_file.a
\$(INSTALL_DATA) $ac_file.a \$(DESTDIR)\$(dlldir)/lib$ac_implib.a \$(INSTALL_DATA) $ac_file.a \$(DESTDIR)\$(dlldir)/lib$ac_implib.a
$ac_dir/uninstall:: install install-dev:: $ac_dir/install-dev"
\$(RM) \$(DESTDIR)\$(dlldir)/lib$ac_implib.a
install install-dev:: $ac_dir/install-dev
__uninstall__: $ac_dir/uninstall"
if test -n "$CROSSTARGET" -a -z "$ac_implibflags" if test -n "$CROSSTARGET" -a -z "$ac_implibflags"
then then
@ -405,13 +391,10 @@ $ac_file.def: $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD)
\$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --def -o \$[@] --export $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --def -o \$[@] --export $srcdir/$ac_dir/$ac_name.spec
$ac_file.a: $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD) $ac_file.a: $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD)
\$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --implib -o \$[@] --export $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --implib -o \$[@] --export $srcdir/$ac_dir/$ac_name.spec
.PHONY: $ac_dir/install-dev $ac_dir/uninstall .PHONY: $ac_dir/install-dev
$ac_dir/install-dev:: $ac_file.$IMPLIBEXT $ac_dir/install-dev:: $ac_file.$IMPLIBEXT
\$(INSTALL_DATA) $ac_file.$IMPLIBEXT \$(DESTDIR)\$(dlldir)/lib$ac_implib.$IMPLIBEXT \$(INSTALL_DATA) $ac_file.$IMPLIBEXT \$(DESTDIR)\$(dlldir)/lib$ac_implib.$IMPLIBEXT
$ac_dir/uninstall:: install install-dev:: $ac_dir/install-dev"
\$(RM) \$(DESTDIR)\$(dlldir)/lib$ac_implib.$IMPLIBEXT
install install-dev:: $ac_dir/install-dev
__uninstall__: $ac_dir/uninstall"
if test -n "$CROSSTARGET" -a -z "$ac_implibflags" if test -n "$CROSSTARGET" -a -z "$ac_implibflags"
then then
wine_fn_append_rule \ wine_fn_append_rule \
@ -442,42 +425,33 @@ wine_fn_config_program ()
wine_fn_has_flag install || return wine_fn_has_flag install || return
wine_fn_append_rule \ wine_fn_append_rule \
".PHONY: $ac_dir/install $ac_dir/uninstall ".PHONY: $ac_dir/install
install install-lib:: $ac_dir/install install install-lib:: $ac_dir/install"
__uninstall__: $ac_dir/uninstall"
if test -n "$DLLEXT" if test -n "$DLLEXT"
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: $ac_dir "$ac_dir/install:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_program$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_program$DLLEXT \$(INSTALL_PROGRAM) $ac_dir/$ac_program$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_program$DLLEXT
\$(INSTALL_DATA) $ac_dir/$ac_program.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_program \$(INSTALL_DATA) $ac_dir/$ac_program.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_program"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/$ac_program$DLLEXT \$(DESTDIR)\$(dlldir)/fakedlls/$ac_program"
if test -z "$with_wine64" && wine_fn_has_flag installbin if test -z "$with_wine64" && wine_fn_has_flag installbin
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: __tooldeps__ "$ac_dir/install:: __tooldeps__
\$(INSTALL_SCRIPT) \$(TOOLSDIR)/tools/wineapploader \$(DESTDIR)\$(bindir)/$ac_name \$(INSTALL_SCRIPT) \$(TOOLSDIR)/tools/wineapploader \$(DESTDIR)\$(bindir)/$ac_name"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$ac_name"
fi fi
else else
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: $ac_dir "$ac_dir/install:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_program \$(DESTDIR)\$(bindir)/$ac_program \$(INSTALL_PROGRAM) $ac_dir/$ac_program \$(DESTDIR)\$(bindir)/$ac_program"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$ac_program"
fi fi
if test -z "$with_wine64" && wine_fn_has_flag manpage if test -z "$with_wine64" && wine_fn_has_flag manpage
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: $ac_dir "$ac_dir/install:: $ac_dir
\$(INSTALL_DATA) $ac_dir/$ac_name.man \$(DESTDIR)\$(mandir)/man\$(prog_manext)/$ac_name.\$(prog_manext) \$(INSTALL_DATA) $ac_dir/$ac_name.man \$(DESTDIR)\$(mandir)/man\$(prog_manext)/$ac_name.\$(prog_manext)"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(mandir)/man\$(prog_manext)/$ac_name.\$(prog_manext)"
fi fi
} }

60
configure vendored
View File

@ -7729,13 +7729,10 @@ wine_fn_install_rules ()
wine_fn_has_flag install-lib || wine_fn_has_flag install-dev || return wine_fn_has_flag install-lib || wine_fn_has_flag install-dev || return
wine_fn_append_rule \ wine_fn_append_rule \
".PHONY: $ac_dir/install $ac_dir/uninstall ".PHONY: $ac_dir/install
$ac_dir/install:: $ac_dir $ac_dir/install:: $ac_dir
@cd $ac_dir && \$(MAKE) install @cd $ac_dir && \$(MAKE) install
$ac_dir/uninstall:: install:: $ac_dir/install"
@cd $ac_dir && \$(MAKE) uninstall
install:: $ac_dir/install
__uninstall__: $ac_dir/uninstall"
if wine_fn_has_flag install-lib if wine_fn_has_flag install-lib
then then
@ -7793,13 +7790,10 @@ fi
wine_fn_all_rules wine_fn_all_rules
wine_fn_append_rule \ wine_fn_append_rule \
".PHONY: $ac_dir/install $ac_dir/uninstall ".PHONY: $ac_dir/install
$ac_dir/install:: $ac_dir $ac_dir/install:: $ac_dir
\$(INSTALL_DATA) $ac_dir/lib$ac_name.a \$(DESTDIR)\$(dlldir)/lib$ac_name.a \$(INSTALL_DATA) $ac_dir/lib$ac_name.a \$(DESTDIR)\$(dlldir)/lib$ac_name.a
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/lib$ac_name.a
install install-dev:: $ac_dir/install install install-dev:: $ac_dir/install
__uninstall__: $ac_dir/uninstall
__builddeps__: $ac_dir __builddeps__: $ac_dir
$ac_dir: $ac_deps" $ac_dir: $ac_deps"
} }
@ -7842,23 +7836,18 @@ else
"$ac_dir: __builddeps__ "$ac_dir: __builddeps__
manpages htmlpages sgmlpages xmlpages:: manpages htmlpages sgmlpages xmlpages::
@cd $ac_dir && \$(MAKE) \$@ @cd $ac_dir && \$(MAKE) \$@
.PHONY: $ac_dir/install-lib $ac_dir/uninstall .PHONY: $ac_dir/install-lib
install install-lib:: $ac_dir/install-lib install install-lib:: $ac_dir/install-lib"
__uninstall__: $ac_dir/uninstall"
if test -n "$DLLEXT" if test -n "$DLLEXT"
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install-lib:: $ac_dir "$ac_dir/install-lib:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_dll$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_dll$DLLEXT \$(INSTALL_PROGRAM) $ac_dir/$ac_dll$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_dll$DLLEXT
\$(INSTALL_DATA) $ac_dir/$ac_dll.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_dll \$(INSTALL_DATA) $ac_dir/$ac_dll.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_dll"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/$ac_dll$DLLEXT \$(DESTDIR)\$(dlldir)/fakedlls/$ac_dll"
else else
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install-lib:: $ac_dir "$ac_dir/install-lib:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_dll \$(DESTDIR)\$(dlldir)/$ac_dll \$(INSTALL_PROGRAM) $ac_dir/$ac_dll \$(DESTDIR)\$(dlldir)/$ac_dll"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/$ac_dll"
fi fi
fi fi
@ -7869,13 +7858,10 @@ fi
$ac_file.a $ac_file.cross.a: $ac_deps $ac_file.a $ac_file.cross.a: $ac_deps
$ac_file.a: dummy $ac_file.a: dummy
@cd $ac_dir && \$(MAKE) lib$ac_implib.a @cd $ac_dir && \$(MAKE) lib$ac_implib.a
.PHONY: $ac_dir/install-dev $ac_dir/uninstall .PHONY: $ac_dir/install-dev
$ac_dir/install-dev:: $ac_file.a $ac_dir/install-dev:: $ac_file.a
\$(INSTALL_DATA) $ac_file.a \$(DESTDIR)\$(dlldir)/lib$ac_implib.a \$(INSTALL_DATA) $ac_file.a \$(DESTDIR)\$(dlldir)/lib$ac_implib.a
$ac_dir/uninstall:: install install-dev:: $ac_dir/install-dev"
\$(RM) \$(DESTDIR)\$(dlldir)/lib$ac_implib.a
install install-dev:: $ac_dir/install-dev
__uninstall__: $ac_dir/uninstall"
if test -n "$CROSSTARGET" -a -z "$ac_implibflags" if test -n "$CROSSTARGET" -a -z "$ac_implibflags"
then then
@ -7893,13 +7879,10 @@ $ac_file.def: $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD)
\$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --def -o \$@ --export $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --def -o \$@ --export $srcdir/$ac_dir/$ac_name.spec
$ac_file.a: $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD) $ac_file.a: $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD)
\$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --implib -o \$@ --export $srcdir/$ac_dir/$ac_name.spec \$(WINEBUILD) \$(TARGETFLAGS)$ac_implibflags -w --implib -o \$@ --export $srcdir/$ac_dir/$ac_name.spec
.PHONY: $ac_dir/install-dev $ac_dir/uninstall .PHONY: $ac_dir/install-dev
$ac_dir/install-dev:: $ac_file.$IMPLIBEXT $ac_dir/install-dev:: $ac_file.$IMPLIBEXT
\$(INSTALL_DATA) $ac_file.$IMPLIBEXT \$(DESTDIR)\$(dlldir)/lib$ac_implib.$IMPLIBEXT \$(INSTALL_DATA) $ac_file.$IMPLIBEXT \$(DESTDIR)\$(dlldir)/lib$ac_implib.$IMPLIBEXT
$ac_dir/uninstall:: install install-dev:: $ac_dir/install-dev"
\$(RM) \$(DESTDIR)\$(dlldir)/lib$ac_implib.$IMPLIBEXT
install install-dev:: $ac_dir/install-dev
__uninstall__: $ac_dir/uninstall"
if test -n "$CROSSTARGET" -a -z "$ac_implibflags" if test -n "$CROSSTARGET" -a -z "$ac_implibflags"
then then
wine_fn_append_rule \ wine_fn_append_rule \
@ -7932,42 +7915,33 @@ fi
wine_fn_has_flag install || return wine_fn_has_flag install || return
wine_fn_append_rule \ wine_fn_append_rule \
".PHONY: $ac_dir/install $ac_dir/uninstall ".PHONY: $ac_dir/install
install install-lib:: $ac_dir/install install install-lib:: $ac_dir/install"
__uninstall__: $ac_dir/uninstall"
if test -n "$DLLEXT" if test -n "$DLLEXT"
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: $ac_dir "$ac_dir/install:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_program$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_program$DLLEXT \$(INSTALL_PROGRAM) $ac_dir/$ac_program$DLLEXT \$(DESTDIR)\$(dlldir)/$ac_program$DLLEXT
\$(INSTALL_DATA) $ac_dir/$ac_program.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_program \$(INSTALL_DATA) $ac_dir/$ac_program.fake \$(DESTDIR)\$(dlldir)/fakedlls/$ac_program"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(dlldir)/$ac_program$DLLEXT \$(DESTDIR)\$(dlldir)/fakedlls/$ac_program"
if test -z "$with_wine64" && wine_fn_has_flag installbin if test -z "$with_wine64" && wine_fn_has_flag installbin
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: __tooldeps__ "$ac_dir/install:: __tooldeps__
\$(INSTALL_SCRIPT) \$(TOOLSDIR)/tools/wineapploader \$(DESTDIR)\$(bindir)/$ac_name \$(INSTALL_SCRIPT) \$(TOOLSDIR)/tools/wineapploader \$(DESTDIR)\$(bindir)/$ac_name"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$ac_name"
fi fi
else else
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: $ac_dir "$ac_dir/install:: $ac_dir
\$(INSTALL_PROGRAM) $ac_dir/$ac_program \$(DESTDIR)\$(bindir)/$ac_program \$(INSTALL_PROGRAM) $ac_dir/$ac_program \$(DESTDIR)\$(bindir)/$ac_program"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$ac_program"
fi fi
if test -z "$with_wine64" && wine_fn_has_flag manpage if test -z "$with_wine64" && wine_fn_has_flag manpage
then then
wine_fn_append_rule \ wine_fn_append_rule \
"$ac_dir/install:: $ac_dir "$ac_dir/install:: $ac_dir
\$(INSTALL_DATA) $ac_dir/$ac_name.man \$(DESTDIR)\$(mandir)/man\$(prog_manext)/$ac_name.\$(prog_manext) \$(INSTALL_DATA) $ac_dir/$ac_name.man \$(DESTDIR)\$(mandir)/man\$(prog_manext)/$ac_name.\$(prog_manext)"
$ac_dir/uninstall::
\$(RM) \$(DESTDIR)\$(mandir)/man\$(prog_manext)/$ac_name.\$(prog_manext)"
fi fi
} }

View File

@ -190,6 +190,8 @@ struct makefile
struct strarray in_files; struct strarray in_files;
struct strarray ok_files; struct strarray ok_files;
struct strarray clean_files; struct strarray clean_files;
struct strarray distclean_files;
struct strarray uninstall_files;
struct strarray object_files; struct strarray object_files;
struct strarray crossobj_files; struct strarray crossobj_files;
struct strarray c2man_files; struct strarray c2man_files;
@ -471,6 +473,15 @@ static void strarray_set_value( struct strarray *array, const char *name, const
} }
/*******************************************************************
* strarray_set_qsort
*/
static void strarray_qsort( struct strarray *array, int (*func)(const char **, const char **) )
{
if (array->count) qsort( array->str, array->count, sizeof(*array->str), (void *)func );
}
/******************************************************************* /*******************************************************************
* output_filename * output_filename
*/ */
@ -2196,16 +2207,14 @@ static void output_symlink_rule( const char *src_name, const char *link_name )
* Rules are stored as a (file,dest) pair of values. * Rules are stored as a (file,dest) pair of values.
* The first char of dest indicates the type of install. * The first char of dest indicates the type of install.
*/ */
static struct strarray output_install_rules( struct makefile *make, enum install_rules rules, static void output_install_rules( struct makefile *make, enum install_rules rules, const char *target )
const char *target )
{ {
unsigned int i; unsigned int i;
char *install_sh; char *install_sh;
struct strarray files = make->install_rules[rules]; struct strarray files = make->install_rules[rules];
struct strarray uninstall = empty_strarray;
struct strarray targets = empty_strarray; struct strarray targets = empty_strarray;
if (!files.count) return uninstall; if (!files.count) return;
for (i = 0; i < files.count; i += 2) for (i = 0; i < files.count; i += 2)
{ {
@ -2265,12 +2274,67 @@ static struct strarray output_install_rules( struct makefile *make, enum install
default: default:
assert(0); assert(0);
} }
strarray_add( &uninstall, dest ); strarray_add( &make->uninstall_files, dest );
} }
strarray_add_uniq( &make->phony_targets, "install" ); strarray_add_uniq( &make->phony_targets, "install" );
strarray_add_uniq( &make->phony_targets, target ); strarray_add_uniq( &make->phony_targets, target );
return uninstall; }
static int cmp_string_length( const char **a, const char **b )
{
int paths_a = 0, paths_b = 0;
const char *p;
for (p = *a; *p; p++) if (*p == '/') paths_a++;
for (p = *b; *p; p++) if (*p == '/') paths_b++;
if (paths_b != paths_a) return paths_b - paths_a;
return strcmp( *a, *b );
}
/*******************************************************************
* output_uninstall_rules
*/
static void output_uninstall_rules( struct makefile *make )
{
static const char *dirs_order[] =
{ "$(includedir)", "$(mandir)", "$(fontdir)", "$(datadir)", "$(dlldir)" };
struct strarray subdirs = empty_strarray;
unsigned int i, j;
if (!make->uninstall_files.count) return;
output( "uninstall::\n" );
output_rm_filenames( make->uninstall_files );
strarray_add_uniq( &make->phony_targets, "uninstall" );
if (!make->subdirs.count) return;
for (i = 0; i < make->uninstall_files.count; i++)
{
char *dir = xstrdup( make->uninstall_files.str[i] );
while (strchr( dir, '/' ))
{
*strrchr( dir, '/' ) = 0;
strarray_add_uniq( &subdirs, xstrdup(dir) );
}
}
strarray_qsort( &subdirs, cmp_string_length );
output( "\t-rmdir" );
for (i = 0; i < sizeof(dirs_order)/sizeof(dirs_order[0]); i++)
{
for (j = 0; j < subdirs.count; j++)
{
if (!subdirs.str[j]) continue;
if (strncmp( subdirs.str[j] + strlen("$(DESTDIR)"), dirs_order[i], strlen(dirs_order[i]) ))
continue;
output_filename( subdirs.str[j] );
subdirs.str[j] = NULL;
}
}
for (j = 0; j < subdirs.count; j++)
if (subdirs.str[j]) output_filename( subdirs.str[j] );
output( "\n" );
} }
@ -3328,27 +3392,23 @@ static void output_subdirs( struct makefile *make )
struct strarray makefile_deps = empty_strarray; struct strarray makefile_deps = empty_strarray;
struct strarray clean_files = empty_strarray; struct strarray clean_files = empty_strarray;
struct strarray testclean_files = empty_strarray; struct strarray testclean_files = empty_strarray;
struct strarray distclean_files = get_expanded_make_var_array( make, "CONFIGURE_TARGETS" ); struct strarray distclean_files = empty_strarray;
unsigned int i, j; unsigned int i, j;
strarray_add( &distclean_files, obj_dir_path( make, output_makefile_name )); strarray_addall( &distclean_files, make->distclean_files );
if (!make->src_dir) strarray_add( &distclean_files, obj_dir_path( make, ".gitignore" ));
for (i = 0; i < make->subdirs.count; i++) for (i = 0; i < make->subdirs.count; i++)
{ {
const struct makefile *submake = make->submakes[i]; const struct makefile *submake = make->submakes[i];
strarray_add( &makefile_deps, top_src_dir_path( make, base_dir_path( submake, strarray_add( &makefile_deps, top_src_dir_path( make, base_dir_path( submake,
strmake ( "%s.in", output_makefile_name )))); strmake ( "%s.in", output_makefile_name ))));
strarray_add( &distclean_files, base_dir_path( submake, output_makefile_name ));
if (!make->src_dir) strarray_add( &distclean_files, base_dir_path( submake, ".gitignore" ));
for (j = 0; j < submake->clean_files.count; j++) for (j = 0; j < submake->clean_files.count; j++)
strarray_add( &clean_files, base_dir_path( submake, submake->clean_files.str[j] )); strarray_add( &clean_files, base_dir_path( submake, submake->clean_files.str[j] ));
if (submake->testdll) for (j = 0; j < submake->distclean_files.count; j++)
{ strarray_add( &distclean_files, base_dir_path( submake, submake->distclean_files.str[j] ));
for (j = 0; j < submake->ok_files.count; j++) for (j = 0; j < submake->ok_files.count; j++)
strarray_add( &testclean_files, base_dir_path( submake, submake->ok_files.str[j] )); strarray_add( &testclean_files, base_dir_path( submake, submake->ok_files.str[j] ));
strarray_add( &distclean_files, base_dir_path( submake, "testlist.c" )); strarray_addall( &make->uninstall_files, submake->uninstall_files );
}
strarray_addall( &build_deps, output_importlib_symlinks( make, submake )); strarray_addall( &build_deps, output_importlib_symlinks( make, submake ));
} }
output( "Makefile:" ); output( "Makefile:" );
@ -3379,11 +3439,10 @@ static void output_subdirs( struct makefile *make )
/******************************************************************* /*******************************************************************
* output_sources * output_sources
*/ */
static struct strarray output_sources( struct makefile *make ) static void output_sources( struct makefile *make )
{ {
struct incl_file *source; struct incl_file *source;
unsigned int i, j; unsigned int i, j;
struct strarray uninstall_files = empty_strarray;
strarray_add( &make->phony_targets, "all" ); strarray_add( &make->phony_targets, "all" );
@ -3423,6 +3482,15 @@ static struct strarray output_sources( struct makefile *make )
add_install_rule( make, make->scripts.str[i], make->scripts.str[i], add_install_rule( make, make->scripts.str[i], make->scripts.str[i],
strmake( "S$(bindir)/%s", make->scripts.str[i] )); strmake( "S$(bindir)/%s", make->scripts.str[i] ));
if (!make->src_dir) strarray_add( &make->distclean_files, ".gitignore" );
strarray_add( &make->distclean_files, "Makefile" );
if (make->testdll) strarray_add( &make->distclean_files, "testlist.c" );
if (!make->base_dir)
strarray_addall( &make->distclean_files, get_expanded_make_var_array( make, "CONFIGURE_TARGETS" ));
else if (!strcmp( make->base_dir, "po" ))
strarray_add( &make->distclean_files, "LINGUAS" );
if (make->subdirs.count) output_subdirs( make ); if (make->subdirs.count) output_subdirs( make );
if (!make->disabled) if (!make->disabled)
@ -3433,16 +3501,9 @@ static struct strarray output_sources( struct makefile *make )
output_filenames_obj_dir( make, make->all_targets ); output_filenames_obj_dir( make, make->all_targets );
output( "\n" ); output( "\n" );
} }
strarray_addall( &uninstall_files, output_install_rules( make, INSTALL_LIB, "install-lib" )); output_install_rules( make, INSTALL_LIB, "install-lib" );
strarray_addall( &uninstall_files, output_install_rules( make, INSTALL_DEV, "install-dev" )); output_install_rules( make, INSTALL_DEV, "install-dev" );
if (uninstall_files.count) output_uninstall_rules( make );
{
output( "uninstall::\n" );
output( "\trm -f" );
output_filenames( uninstall_files );
output( "\n" );
strarray_add_uniq( &make->phony_targets, "uninstall" );
}
} }
strarray_addall( &make->clean_files, make->object_files ); strarray_addall( &make->clean_files, make->object_files );
@ -3467,10 +3528,6 @@ static struct strarray output_sources( struct makefile *make )
output_filenames( make->phony_targets ); output_filenames( make->phony_targets );
output( "\n" ); output( "\n" );
} }
if (!make->base_dir)
strarray_addall( &make->clean_files, get_expanded_make_var_array( make, "CONFIGURE_TARGETS" ));
return make->clean_files;
} }
@ -3664,7 +3721,7 @@ static void output_top_variables( const struct makefile *make )
*/ */
static void output_dependencies( struct makefile *make ) static void output_dependencies( struct makefile *make )
{ {
struct strarray targets, ignore_files = empty_strarray; struct strarray ignore_files = empty_strarray;
char buffer[1024]; char buffer[1024];
FILE *src_file; FILE *src_file;
int found = 0; int found = 0;
@ -3686,28 +3743,19 @@ static void output_dependencies( struct makefile *make )
input_file_name = NULL; input_file_name = NULL;
if (!found) output( "\n%s (everything below this line is auto-generated; DO NOT EDIT!!)\n", separator ); if (!found) output( "\n%s (everything below this line is auto-generated; DO NOT EDIT!!)\n", separator );
targets = output_sources( make ); output_sources( make );
fclose( output_file ); fclose( output_file );
output_file = NULL; output_file = NULL;
rename_temp_file( output_file_name ); rename_temp_file( output_file_name );
strarray_add( &ignore_files, ".gitignore" ); strarray_addall( &ignore_files, make->distclean_files );
strarray_add( &ignore_files, "Makefile" ); strarray_addall( &ignore_files, make->clean_files );
if (make->testdll) if (make->testdll) output_testlist( make );
{ if (make->base_dir && !strcmp( make->base_dir, "po" )) output_linguas( make );
output_testlist( make );
strarray_add( &ignore_files, "testlist.c" );
}
if (make->base_dir && !strcmp( make->base_dir, "po" ))
{
output_linguas( make );
strarray_add( &ignore_files, "LINGUAS" );
}
strarray_addall( &ignore_files, targets );
if (!make->src_dir) output_gitignore( base_dir_path( make, ".gitignore" ), ignore_files ); if (!make->src_dir) output_gitignore( base_dir_path( make, ".gitignore" ), ignore_files );
create_file_directories( make, targets ); create_file_directories( make, ignore_files );
output_file_name = NULL; output_file_name = NULL;
} }