From 237ed76e6d3bf60a7c4daf1eefc07c5cf59054c0 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Thu, 10 Oct 2013 11:22:08 +0200
Subject: [PATCH] makefiles: Generate the common rules for programs from
 configure.

---
 .gitignore                    |  1 -
 aclocal.m4                    |  2 +-
 configure                     | 18 ++++++++++--------
 configure.ac                  |  9 +++++++--
 programs/Makeprog.rules.in    | 16 ----------------
 programs/winetest/Makefile.in |  4 ++--
 tools/make_makefiles          |  5 ++---
 7 files changed, 22 insertions(+), 33 deletions(-)
 delete mode 100644 programs/Makeprog.rules.in

diff --git a/.gitignore b/.gitignore
index 1d35e05c08d..4cb2af7e18a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -286,7 +286,6 @@ loader/wine64-preloader
 loader/wine_info.plist
 msg.pot
 po/*.mo
-programs/Makeprog.rules
 programs/rpcss/epm.h
 programs/rpcss/epm_s.c
 programs/rpcss/irot.h
diff --git a/aclocal.m4 b/aclocal.m4
index fb013fb7f15..9ee387af358 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -524,7 +524,7 @@ wine_fn_config_program ()
 
     AS_VAR_IF([$ac_enable],[no],[wine_fn_disabled_rules $ac_clean; return])
 
-    wine_fn_all_rules programs/Makeprog.rules
+    wine_fn_all_rules Make.rules.in
     wine_fn_clean_rules $ac_clean
     wine_fn_append_rule "$ac_dir: __builddeps__"
     wine_fn_pot_rules
diff --git a/configure b/configure
index da3d922f81b..91af939a8e1 100755
--- a/configure
+++ b/configure
@@ -627,6 +627,7 @@ LIBOBJS
 PORCFLAGS
 LINGUAS
 ALL_TEST_RESOURCES
+MAKE_PROG_RULES
 MAKE_DLL_RULES
 MAKE_IMPLIB_RULES
 LDAPLIBS
@@ -801,8 +802,7 @@ PACKAGE_NAME
 PATH_SEPARATOR
 SHELL'
 ac_subst_files='MAKE_RULES
-MAKE_TEST_RULES
-MAKE_PROG_RULES'
+MAKE_TEST_RULES'
 ac_user_opts='
 enable_option_checking
 enable_win16
@@ -16082,6 +16082,13 @@ all: $deps
 "
 
 
+MAKE_PROG_RULES="
+DLLFLAGS    = $DLLFLAGS
+
+all: $deps
+"
+
+
 
 wine_rules_file=conf$$rules.make
 rm -f $wine_rules_file
@@ -16418,7 +16425,7 @@ wine_fn_config_program ()
   wine_fn_disabled_rules $ac_clean; return
 fi
 
-    wine_fn_all_rules programs/Makeprog.rules
+    wine_fn_all_rules Make.rules.in
     wine_fn_clean_rules $ac_clean
     wine_fn_append_rule "$ac_dir: __builddeps__"
     wine_fn_pot_rules
@@ -16623,10 +16630,6 @@ wine_fn_config_makerules Maketest.rules Make.rules
 MAKE_TEST_RULES=Maketest.rules
 ac_config_files="$ac_config_files Maketest.rules"
 
-wine_fn_config_makerules programs/Makeprog.rules Make.rules
-MAKE_PROG_RULES=programs/Makeprog.rules
-ac_config_files="$ac_config_files programs/Makeprog.rules"
-
 
 wine_fn_config_dll acledit enable_acledit
 wine_fn_config_dll aclui enable_aclui implib
@@ -18194,7 +18197,6 @@ do
     "include/wine") CONFIG_COMMANDS="$CONFIG_COMMANDS include/wine" ;;
     "Make.rules") CONFIG_FILES="$CONFIG_FILES Make.rules" ;;
     "Maketest.rules") CONFIG_FILES="$CONFIG_FILES Maketest.rules" ;;
-    "programs/Makeprog.rules") CONFIG_FILES="$CONFIG_FILES programs/Makeprog.rules" ;;
     "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
     "Make.tmp") CONFIG_FILES="$CONFIG_FILES Make.tmp:Make.vars.in:Makefile.in" ;;
 
diff --git a/configure.ac b/configure.ac
index 6bc985aa31b..b5358c01934 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2608,7 +2608,7 @@ all: \$(STATICLIB:.a=.cross.a)
 ")
 fi
 
-dnl Dll rules
+dnl Dll and program rules
 
 if test -n "$DLLEXT"
 then
@@ -2626,6 +2626,12 @@ MODULEFLAGS = -shared \$(srcdir)/\$(MAINSPEC) \$(EXTRADLLFLAGS)
 all: $deps
 ")
 
+AC_SUBST(MAKE_PROG_RULES,"
+DLLFLAGS    = $DLLFLAGS
+
+all: $deps
+")
+
 dnl Main makefile
 
 WINE_APPEND_RULE([
@@ -2654,7 +2660,6 @@ WINE_CONFIG_EXTRA_DIR(include/wine)
 
 WINE_CONFIG_MAKERULES([Make.rules],[MAKE_RULES])
 WINE_CONFIG_MAKERULES([Maketest.rules],[MAKE_TEST_RULES],[Make.rules])
-WINE_CONFIG_MAKERULES([programs/Makeprog.rules],[MAKE_PROG_RULES],[Make.rules])
 
 WINE_CONFIG_DLL(acledit)
 WINE_CONFIG_DLL(aclui,,[implib])
diff --git a/programs/Makeprog.rules.in b/programs/Makeprog.rules.in
deleted file mode 100644
index 1813173ae27..00000000000
--- a/programs/Makeprog.rules.in
+++ /dev/null
@@ -1,16 +0,0 @@
-# Global rules for building a Winelib program     -*-Makefile-*-
-#
-# Each individual makefile should define the following variables:
-# MODULE       : name of the main module being built
-# APPMODE      : program mode (-mwindows,-mconsole)
-# EXTRALIBS    : extra libraries to link in (optional)
-# EXTRADEFS    : extra symbol definitions, like -DWINELIB (optional)
-#
-# plus all variables required by the global Make.rules.in
-#
-
-DLLFLAGS    = @DLLFLAGS@
-
-all: $(MODULE)$(DLLEXT) $(MODULE)$(FAKEEXT)
-
-@MAKE_RULES@
diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index cddea98a71c..898e995482e 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -16,8 +16,6 @@ SVG_SRCS = winetest.svg
 
 EXTRA_OBJS = build.res @ALL_TEST_RESOURCES@
 
-@MAKE_PROG_RULES@
-
 clean::
 	$(RM) build.rc build.nfo
 
@@ -28,3 +26,5 @@ build.nfo:
 	-$(CC) -v 2>$@
 
 build.res: build.nfo
+
+@MAKE_PROG_RULES@
diff --git a/tools/make_makefiles b/tools/make_makefiles
index dc1f92a995a..d2659556fd0 100755
--- a/tools/make_makefiles
+++ b/tools/make_makefiles
@@ -26,7 +26,6 @@ my %makerules =
 (
  "MAKE_RULES" => "Make.rules",
  "MAKE_TEST_RULES" => "Maketest.rules",
- "MAKE_PROG_RULES" => "programs/Makeprog.rules",
 );
 
 # Programs that we want to install in the bin directory too
@@ -351,7 +350,7 @@ sub parse_makefile($)
 
     if (defined $make{"=flags"} && defined $make{"=rules"} &&
         ($make{"=rules"} eq "MAKE_DLL_RULES" ||
-         $make{"=rules"} eq $makerules{"MAKE_PROG_RULES"}))
+         $make{"=rules"} eq "MAKE_PROG_RULES"))
     {
         die "Custom install-lib rule not allowed in $file" if defined ${$make{"=flags"}}{"install-lib"};
         die "Custom install-dev rule not allowed in $file" if defined ${$make{"=flags"}}{"install-dev"};
@@ -472,7 +471,7 @@ sub update_makefiles(@)
             $args .= ",[$implib]" if $implib && $implib ne $name;
             push @lines, "WINE_CONFIG_DLL($name$args)\n";
         }
-        elsif ($rules eq $makerules{"MAKE_PROG_RULES"})
+        elsif ($rules eq "MAKE_PROG_RULES")
         {
             (my $name = $file) =~ s/^programs\/(.*)\/Makefile/$1/;
             if ($name =~ /\./)
-- 
GitLab