Commit a4905910 authored by Arnel A. Borja's avatar Arnel A. Borja Committed by Sebastien Granjoux

project-wizard: bgo #688611 - Make templates Windows portable

- Check for Windows in configure.ac templates.
- Add win32-dll to LT_INIT options.
- Add -mwindows to LDFLAGS of GUI applications if compiling for native
  Windows.
- Add -no-undefined to LDFLAGS of libraries if compiling for Windows.
- Replace -Wl,--export-dynamic with -Wl,--export-all-symbols in LDFLAGS of
  applications if compiling for Windows.
- Add Windows support option to wizards.

Affected templates are cpp, gtk, gtkapplication, gtkmm, library, terminal
and vala-gtk.
parent 25254114
......@@ -27,6 +27,7 @@
<property type="boolean" name="HaveSharedlib" _label="Add shared library support:" _description="Adds support for building shared libraries in your project" default="1"/>
<property type="boolean" name="HaveI18n" _label="Add internationalization:" _description="Adds support for internationalization so that your project can have translations in different languages" default="1"/>
<property type="boolean" name="HavePackage" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
<property type="boolean" name="HaveWindowsSupport" _label="Add Windows support:" _description="Adds support for building on Windows platforms" default="0"/>
</page>
[+IF (=(get "HavePackage") "1")+]
......
......@@ -29,9 +29,37 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
AM_GLIB_GNU_GETTEXT
[+ENDIF+]
[+IF (=(get "HaveSharedlib") "1")+]
LT_INIT
[+ENDIF+]
[+IF (=(get "HaveWindowsSupport") "1")+]
dnl ***************************************************************************
dnl Check for Windows
dnl ***************************************************************************
AC_CANONICAL_HOST
case $host_os in
*mingw*)
platform_win32=yes
native_win32=yes
;;
pw32* | *cygwin*)
platform_win32=yes
native_win32=no
;;
*)
platform_win32=no
native_win32=no
;;
esac
AM_CONDITIONAL(PLATFORM_WIN32, test x"$platform_win32" = "xyes")
AM_CONDITIONAL(NATIVE_WIN32, test x"$native_win32" = "xyes")[+
ENDIF+]
[+IF (=(get "HaveSharedlib") "1")+][+
IF (=(get "HaveWindowsSupport") "1")+]
LT_INIT([win32-dll])[+
ELSE+]
LT_INIT[+
ENDIF+][+
ENDIF+]
[+IF (=(get "HavePackage") "1")+]
PKG_CHECK_MODULES([+NameCUpper+], [[+PackageModule1+] [+PackageModule2+]])
......
......@@ -22,3 +22,8 @@ bin_PROGRAMS = [+NameHLower+]
[+NameCLower+]_LDADD = [+IF (=(get "HavePackage") "1")+]$([+NameCUpper+]_LIBS)[+ENDIF+]
[+IF (=(get "HaveWindowsSupport") "1")+]
if NATIVE_WIN32
[+NameCLower+]_LDFLAGS += -mwindows
endif[+
ENDIF+]
......@@ -34,6 +34,7 @@
<property type="boolean" name="HaveGtkDoc" _label="Add gtk-doc system:" _description="gtk-doc is used to compile API documentations for GObject based classes" default="0"/>
<property type="boolean" name="HavePackageExtra" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
<property type="boolean" name="HaveBuilderUI" _label="Use GtkBuilder for user interface:" _description="Use GtkBuilder to create the user-interface in a graphical way and load it from xml files at runtime" default="1"/>
<property type="boolean" name="HaveWindowsSupport" _label="Add Windows support:" _description="Adds support for building on Windows platforms" default="0"/>
</page>
[+IF (=(get "HavePackageExtra") "1")+]
......
......@@ -23,11 +23,27 @@ bin_PROGRAMS = [+NameHLower+]
[+NameCLower+]_SOURCES = \
main.c
[+IF (=(get "HaveWindowsSupport") "1")+]
[+NameCLower+]_LDFLAGS =[+
ELSE+]
[+NameCLower+]_LDFLAGS = \
-Wl,--export-dynamic
-Wl,--export-dynamic[+
ENDIF+]
[+NameCLower+]_LDADD = $([+NameCUpper+]_LIBS)
[+IF (=(get "HaveWindowsSupport") "1")+]
if PLATFORM_WIN32
[+NameCLower+]_LDFLAGS += -Wl,--export-all-symbols
else
[+NameCLower+]_LDFLAGS += -Wl,--export-dynamic
endif
if NATIVE_WIN32
[+NameCLower+]_LDFLAGS += -mwindows
endif[+
ENDIF+]
[+IF (=(get "HaveBuilderUI") "1")+]
EXTRA_DIST = $(ui_DATA)
......
......@@ -26,9 +26,21 @@ static struct _Private
static struct Private* priv = NULL;
/* For testing propose use the local (not installed) ui file */
/* #define UI_FILE PACKAGE_DATA_DIR"/ui/[+NameHLower+].ui" */
/* For testing purpose, define TEST to use the local (not installed) ui file */
#define TEST
#ifdef TEST
#define UI_FILE "src/[+NameHLower+].ui"
#else
[+IF (=(get "HaveWindowsSupport") "1")\+]
#ifdef G_OS_WIN32
#define UI_FILE ui_file
#else
[+ENDIF\+]
#define UI_FILE PACKAGE_DATA_DIR"/ui/[+NameHLower+].ui"
[+IF (=(get "HaveWindowsSupport") "1")\+]
#endif
[+ENDIF\+]
#endif
#define TOP_WINDOW "window"
/* Signal handlers */
......@@ -46,6 +58,13 @@ destroy (GtkWidget *widget, gpointer data)
static GtkWidget*
create_window (void)
{
[+IF (=(get "HaveWindowsSupport") "1")\+]
#if !defined(TEST) && defined(G_OS_WIN32)
gchar *prefix = g_win32_get_package_installation_directory_of_module (NULL);
gchar *datadir = g_build_filename (prefix, "share", PACKAGE, NULL);
gchar *ui_file = g_build_filename (datadir, "ui", "[+NameHLower+].ui", NULL);
#endif
[+ENDIF\+]
GtkWidget *window;
GtkBuilder *builder;
GError* error = NULL;
......@@ -74,10 +93,18 @@ create_window (void)
/* ANJUTA: Widgets initialization for [+NameHLower+].ui - DO NOT REMOVE */
g_object_unref (builder);
[+IF (=(get "HaveWindowsSupport") "1")+]
#if !defined(TEST) && defined(G_OS_WIN32)
g_free (prefix);
g_free (datadir);
g_free (ui_file);
#endif
[+ENDIF\+]
return window;
}
[+ELSE+]
}[+
ELSE+]
static GtkWidget*
create_window (void)
{
......@@ -90,21 +117,36 @@ create_window (void)
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
return window;
}
[+ENDIF+]
}[+
ENDIF+]
int
main (int argc, char *argv[])
{
GtkWidget *window;
[+IF (=(get "HaveI18n") "1")+]
[+IF (=(get "HaveI18n") "1")+][+
IF (=(get "HaveWindowsSupport") "1")+]
#ifdef G_OS_WIN32
gchar *prefix = g_win32_get_package_installation_directory_of_module (NULL);
gchar *localedir = g_build_filename (prefix, "share", "locale", NULL);
#endif[+
ENDIF+]
#ifdef ENABLE_NLS
[+IF (=(get "HaveWindowsSupport") "1")+]
# ifndef G_OS_WIN32
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
# else
bindtextdomain (GETTEXT_PACKAGE, localedir);
# endif[+
ELSE+]
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);[+
ENDIF+]
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
[+ENDIF+]
#endif[+
ENDIF+]
gtk_init (&argc, &argv);
......@@ -112,9 +154,19 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
[+IF (=(get "HaveBuilderUI") "1")+]
g_free (priv);
[+ENDIF+]
g_free (priv);[+
ENDIF+]
[+IF (=(get "HaveI18n") "1")+][+
IF (=(get "HaveWindowsSupport") "1")+]
#ifdef G_OS_WIN32
g_free (prefix);
g_free (localedir);
#endif[+
ENDIF+][+
ENDIF+]
return 0;
}
[+INVOKE END-INDENT\+]
......@@ -35,6 +35,7 @@
<property type="boolean" name="HaveGtkDoc" _label="Add gtk-doc system:" _description="gtk-doc is used to compile API documentations for GObject based classes" default="0"/>
<property type="boolean" name="HavePackageExtra" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
<property type="boolean" name="HaveBuilderUI" _label="Use GtkBuilder for user interface:" _description="Use GtkBuilder to create the user-interface in a graphical way and load it from xml files at runtime" default="1"/>
<property type="boolean" name="HaveWindowsSupport" _label="Add Windows support:" _description="Adds support for building on Windows platforms" default="0"/>
</page>
[+IF (=(get "HavePackageExtra") "1")+]
......
......@@ -25,11 +25,27 @@ bin_PROGRAMS = [+NameHLower+]
[+NameLower+].h \
[+NameLower+].c
[+IF (=(get "HaveWindowsSupport") "1")+]
[+NameCLower+]_LDFLAGS =[+
ELSE+]
[+NameCLower+]_LDFLAGS = \
-Wl,--export-dynamic
-Wl,--export-dynamic[+
ENDIF+]
[+NameCLower+]_LDADD = $([+NameCUpper+]_LIBS)
[+IF (=(get "HaveWindowsSupport") "1")+]
if PLATFORM_WIN32
[+NameCLower+]_LDFLAGS += -Wl,--export-all-symbols
else
[+NameCLower+]_LDFLAGS += -Wl,--export-dynamic
endif
if NATIVE_WIN32
[+NameCLower+]_LDFLAGS += -mwindows
endif[+
ENDIF+]
[+IF (=(get "HaveBuilderUI") "1")+]
EXTRA_DIST = $(ui_DATA)
......
......@@ -33,6 +33,7 @@
<property type="hidden" name="HaveGtkDoc" _label="Add gtk-doc system:" _description="gtk-doc is used to compile API documentations for GObject based classes" default="0"/>
<property type="boolean" name="HavePackageExtra" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
<property type="boolean" name="HaveBuilderUI" _label="Use GtkBuilder for user interface:" _description="Use GtkBuilder to create the user-interface in a graphical way and load it from xml files at runtime" default="1"/>
<property type="boolean" name="HaveWindowsSupport" _label="Add Windows support:" _description="Adds support for building on Windows platforms" default="0"/>
</page>
[+IF (=(get "HavePackageExtra") "1")+]
......
......@@ -27,6 +27,12 @@ bin_PROGRAMS = [+NameHLower+]
[+NameCLower+]_LDADD = $([+NameCUpper+]_LIBS)
[+IF (=(get "HaveWindowsSupport") "1")+]
if NATIVE_WIN32
[+NameCLower+]_LDFLAGS += -mwindows
endif
[+ENDIF+]
[+IF (=(get "HaveBuilderUI") "1")+]
EXTRA_DIST = $(ui_DATA)
......
......@@ -33,6 +33,7 @@
<property type="boolean" name="HaveLangCPP" _label="Add C++ support:" _description="Adds C++ support to the project so that C++ source files can be built" default="0"/>
<property type="boolean" name="HaveI18n" _label="Add internationalization:" _description="Adds support for internationalization so that your project can have translations in different languages" default="1"/>
<property type="boolean" name="HavePackage" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
<property type="boolean" name="HaveWindowsSupport" _label="Add Windows support:" _description="Adds support for building on Windows platforms" default="0"/>
</page>
[+IF (=(get "HavePackage") "1")+]
......
......@@ -29,10 +29,39 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
AM_GLIB_GNU_GETTEXT
[+ENDIF+]
[+IF (=(get "HaveWindowsSupport") "1")+]
dnl ***************************************************************************
dnl Check for Windows
dnl ***************************************************************************
AC_CANONICAL_HOST
case $host_os in
*mingw*)
platform_win32=yes
native_win32=yes
;;
pw32* | *cygwin*)
platform_win32=yes
native_win32=no
;;
*)
platform_win32=no
native_win32=no
;;
esac
AM_CONDITIONAL(PLATFORM_WIN32, test x"$platform_win32" = "xyes")
AM_CONDITIONAL(NATIVE_WIN32, test x"$native_win32" = "xyes")[+
ENDIF+]
[+CASE (get "LibraryType") +]
[+ == "Static" +]AC_DISABLE_SHARED
[+ == "Shared" +]AC_DISABLE_STATIC
[+ESAC+]LT_INIT
[+ESAC+][+
IF (=(get "HaveWindowsSupport") "1")+]
LT_INIT([win32-dll])[+
ELSE+]
LT_INIT[+
ENDIF+]
[+IF (=(get "HavePackage") "1")+]
PKG_CHECK_MODULES([+NameCUpper+], [[+PackageModule1+] [+PackageModule2+]])
......
......@@ -37,6 +37,16 @@ lib_LTLIBRARIES = [+(prefix_if_missing "NameHLower" "lib")+].la
[+(prefix_if_missing "NameCLower" "lib")+]_la_LIBADD = [+IF (=(get "HavePackage") "1")+]$([+NameCUpper+]_LIBS)[+ENDIF+]
[+IF (=(get "HaveWindowsSupport") "1")+]
if PLATFORM_WIN32
[+(prefix_if_missing "NameCLower" "lib")+]_la_LDFLAGS += -no-undefined
endif
if NATIVE_WIN32
[+(prefix_if_missing "NameCLower" "lib")+]_la_LDFLAGS += -export-dynamic
endif[+
ENDIF+]
include_HEADERS = \
[+NameHLower+].h
......
......@@ -28,6 +28,7 @@
<property type="boolean" name="HaveSharedlib" _label="Add shared library support:" _description="Adds support for building shared libraries in your project" default="1"/>
<property type="boolean" name="HaveI18n" _label="Add internationalization:" _description="Adds support for internationalization so that your project can have translations in different languages" default="1"/>
<property type="boolean" name="HavePackage" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
<property type="boolean" name="HaveWindowsSupport" _label="Add Windows support:" _description="Adds support for building on Windows platforms" default="0"/>
</page>
[+IF (=(get "HavePackage") "1")+]
......
......@@ -30,9 +30,37 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
AM_GLIB_GNU_GETTEXT
[+ENDIF+]
[+IF (=(get "HaveSharedlib") "1")+]
LT_INIT
[+ENDIF+]
[+IF (=(get "HaveWindowsSupport") "1")+]
dnl ***************************************************************************
dnl Check for Windows
dnl ***************************************************************************
AC_CANONICAL_HOST
case $host_os in
*mingw*)
platform_win32=yes
native_win32=yes
;;
pw32* | *cygwin*)
platform_win32=yes
native_win32=no
;;
*)
platform_win32=no
native_win32=no
;;
esac
AM_CONDITIONAL(PLATFORM_WIN32, test x"$platform_win32" = "xyes")
AM_CONDITIONAL(NATIVE_WIN32, test x"$native_win32" = "xyes")[+
ENDIF+]
[+IF (=(get "HaveSharedlib") "1")+][+
IF (=(get "HaveWindowsSupport") "1")+]
LT_INIT([win32-dll])[+
ELSE+]
LT_INIT[+
ENDIF+][+
ENDIF+]
[+IF (=(get "HavePackage") "1")+]
PKG_CHECK_MODULES([+NameCUpper+], [[+PackageModule1+] [+PackageModule2+]])
......
......@@ -32,6 +32,7 @@
<property type="boolean" name="HaveSharedlib" _label="Add shared library support:" _description="Adds support for building shared libraries in your project" default="1"/>
<property type="boolean" name="HavePackageExtra" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
<property type="boolean" name="HaveBuilderUI" _label="Use GtkBuilder for user interface:" _description="Use GtkBuilder to create the user-interface in a graphical way and load it from xml files at runtime" default="1"/>
<property type="boolean" name="HaveWindowsSupport" _label="Add Windows support:" _description="Adds support for building on Windows platforms" default="0"/>
</page>
[+IF (=(get "HavePackageExtra") "1")+]
......
......@@ -12,9 +12,37 @@ AM_SILENT_RULES([yes])
AC_PROG_CC
[+IF (=(get "HaveSharedlib") "1")+]
LT_INIT
[+ENDIF+]
[+IF (=(get "HaveWindowsSupport") "1")+]
dnl ***************************************************************************
dnl Check for Windows
dnl ***************************************************************************
AC_CANONICAL_HOST
case $host_os in
*mingw*)
platform_win32=yes
native_win32=yes
;;
pw32* | *cygwin*)
platform_win32=yes
native_win32=no
;;
*)
platform_win32=no
native_win32=no
;;
esac
AM_CONDITIONAL(PLATFORM_WIN32, test x"$platform_win32" = "xyes")
AM_CONDITIONAL(NATIVE_WIN32, test x"$native_win32" = "xyes")[+
ENDIF+]
[+IF (=(get "HaveSharedlib") "1")+][+
IF (=(get "HaveWindowsSupport") "1")+]
LT_INIT([win32-dll])[+
ELSE+]
LT_INIT[+
ENDIF+][+
ENDIF+]
dnl Check for vala
AM_PROG_VALAC([0.10.0])
......
......@@ -26,11 +26,27 @@ bin_PROGRAMS = [+NameHLower+]
[+NameCLower+]_VALAFLAGS = [+IF (not (= (get "PackageModule2") ""))+] --pkg [+(string-substitute (get "PackageModule2") " " " --pkg ")+] [+ENDIF+] \
--pkg gtk+-3.0
[+IF (=(get "HaveWindowsSupport") "1")+]
[+NameCLower+]_LDFLAGS =[+
ELSE+]
[+NameCLower+]_LDFLAGS = \
-Wl,--export-dynamic
-Wl,--export-dynamic[+
ENDIF+]
[+NameCLower+]_LDADD = $([+NameCUpper+]_LIBS)
[+IF (=(get "HaveWindowsSupport") "1")+]
if PLATFORM_WIN32
[+NameCLower+]_LDFLAGS += -Wl,--export-all-symbols
else
[+NameCLower+]_LDFLAGS += -Wl,--export-dynamic
endif
if NATIVE_WIN32
[+NameCLower+]_LDFLAGS += -mwindows
endif[+
ENDIF+]
[+IF (=(get "HaveBuilderUI") "1")+]
EXTRA_DIST = $(ui_DATA)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment