On 2019-03-12 12:08+0100 Valerio Messina via Msys2-users wrote:

hi,
I want to use a single Makefile for three platforms (Linux64, MinGw64, MinGw32) to generate a simple binary (using SDL2).
The source is a single .c file, so use Automake, Autoconf is too heavy.

Hi Valerio:

This is my second try at this post because I had mailing-list
subscription issues with the first version (so you were the
only one that likely got that first version).  Note, for
this version I have added a bit more about CMake and how
to use it.

I am sure with enough effort you could get a pure GNU Make approach to
work.  However *for those familiar with CMake* the task you describe
(build an executable that links to an external library in a
cross-platform way) is straightforward and could be implemented in
just a few lines of CMake code which uses the CMake wrapper for
pkg-config to find SDL2, the add_executable CMake function to
configure the build of your executable, and the target_link_libraries
CMake function to configure linking that build with SDL2.  As a
result, your executable build will be truly cross-platform (e.g.,
including Linux, Mac OS X, and all Windows platforms including Cygwin,
MSYS2, and MSVC), and you will have your choice of CMake back-ends
(including GNU Make).

I assume you are not familiar with CMake because you haven't mentioned
it as a possibility.  So because of that unfamiliarity doing this task
with CMake would likely cost you just as much time as a pure GNU make
approach.  But you would learn a lot that I guarantee would be helpful
to you in other projects (at least that is my experience with CMake
over the last decade) so it would be time well spent.

Alan
__________________________
Alan W. Irwin

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to