473,395 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Windows and Linux

Hello,

I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?

Has anybody an example?
Thanks

Mar 29 '07 #1
12 3466
Bastie said:
Hello,

I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?
Why would you need to? Just write the code portably.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 29 '07 #2
On 29 Mrz., 17:09, Richard Heathfield <r...@see.sig.invalidwrote:
Bastie said:
Hello,
I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?

Why would you need to? Just write the code portably.
Not all code are so portably - for example the code to read all files
in the directory need (i think so) under win the winapi...

Mar 29 '07 #3
Bastie said:
On 29 Mrz., 17:09, Richard Heathfield <r...@see.sig.invalidwrote:
>Bastie said:
Hello,
I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I
use ONE makefile under both os - how can I detect the os in the
make script?

Why would you need to? Just write the code portably.
Not all code are so portably - for example the code to read all files
in the directory need (i think so) under win the winapi...
Easy - just isolate the non-portable bits into separate modules, write
two versions with the same name (e.g. dirwalk.c), keep one of them on
the Win32 system and the other on the Linux system, and your makefile
stays the same on both systems. No worries.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 29 '07 #4
On 29 Mrz., 17:09, Richard Heathfield <r...@see.sig.invalidwrote:
Bastie said:
Hello,
I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?

Why would you need to? Just write the code portably.
Not all code are so portably - for example the code to read all files
in the directory need (i think so) under win the winapi...

Mar 29 '07 #5
On 29 Mar, 15:50, "Bastie" <Real.Bas...@googlemail.comwrote:
Hello,

I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?

Has anybody an example?
Thanks
<OT>
Look at GNU Autoconf perhaps? But it may be overkill.
</OT>

Mar 29 '07 #6
Bastie <Re*********@googlemail.comwrote:
I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?
I don't think you can. Windows nmake is incompatible with *nix make.

When that came up for me I learned a bit of autoconf, enough to
generate a parametrized Linux Makefile and config.h . On the
Windows side I installed mingw and msys so I could run the configure
script. That gave me a Windows config.h and a Makefile. I can
build with msys but I need to target Visual Studio, so I ditched
the Makefile and kept just the config.h to put in a Studio project
generated from scratch (hate those wizards!).
--
pa at panix dot com
Mar 29 '07 #7
On Thu, 29 Mar 2007 16:33:52 +0000 (UTC), in comp.lang.c ,
pa@see.signature.invalid (Pierre Asselin) wrote:
>Bastie <Re*********@googlemail.comwrote:
>I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?

I don't think you can. Windows nmake is incompatible with *nix make.
Neither nmake nor make are part of the OS. Versions of gnu make exist
for multiple platforms.
>When that came up for me I learned a bit of autoconf, enough to
generate a parametrized Linux Makefile and config.h .
Yup.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 29 '07 #8
Pierre Asselin wrote:
Bastie <Re*********@googlemail.comwrote:
>I need to code some libraries for win and linux os and hope make
or somethink can help me to automate my build process. But how
can I use ONE makefile under both os - how can I detect the os
in the make script?

I don't think you can. Windows nmake is incompatible with *nix make.
So what? Just use gnu make on both systems. It's available.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Mar 30 '07 #9
On 29 Mrz., 23:21, Mark McIntyre <markmcint...@spamcop.netwrote:
On Thu, 29 Mar 2007 16:33:52 +0000 (UTC), in comp.lang.c ,

p...@see.signature.invalid (Pierre Asselin) wrote:
Bastie <Real.Bas...@googlemail.comwrote:
I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?
I don't think you can. Windows nmake is incompatible with *nix make.

Neither nmake nor make are part of the OS. Versions of gnu make exist
for multiple platforms.
When that came up for me I learned a bit of autoconf, enough to
generate a parametrized Linux Makefile and config.h .
OK, if I use gno make how can I test the os where make running:

[pseudocode]
IF OS==WIN
use header-path from VC
ELSE IF OS==*NIX
user header-path from GCC
....
END-IF
[/pseudocode]

Mar 30 '07 #10
On Mar 29, 11:49 pm, "Bastie" <Real.Bas...@googlemail.comwrote:
On 29 Mrz., 23:21, Mark McIntyre <markmcint...@spamcop.netwrote:
On Thu, 29 Mar 2007 16:33:52 +0000 (UTC), in comp.lang.c ,
p...@see.signature.invalid (Pierre Asselin) wrote:
>Bastie <Real.Bas...@googlemail.comwrote:
>I need to code some libraries for win and linux os and hope make or
>somethink can help me to automate my build process. But how can I use
>ONE makefile under both os - how can I detect the os in the make
>script?
>I don't think you can. Windows nmake is incompatible with *nix make.
Neither nmake nor make are part of the OS. Versions of gnu make exist
for multiple platforms.
>When that came up for me I learned a bit of autoconf, enough to
>generate a parametrized Linux Makefile and config.h .

OK, if I use gno make how can I test the os where make running:

[pseudocode]
IF OS==WIN
use header-path from VC
ELSE IF OS==*NIX
user header-path from GCC
...
END-IF
[/pseudocode]
wxWidgets seems to have solved the problem with templates for
different platforms and make applications. QT has a platform specific
makefile generator with qmake from the .pro project file.
Unfortunately they're both for C++, thus OT here. However, you can
take a look at what wxWidgets is doing and, maybe, you can adapt that
to your needs. At the same time, both wxWidgets and QT are supposed to
be cross platform so they don't have to deal with including platform
specific safeguards in the make files.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)

Mar 30 '07 #11
On 29 Mar 2007 20:49:35 -0700, Bastie <Re*********@googlemail.comwrote:
....
OK, if I use gno make
It's "Gnu make" or "GNU make", not "gno make".
how can I test the os where make running:

[pseudocode]
IF OS==WIN
use header-path from VC
ELSE IF OS==*NIX
user header-path from GCC
...
END-IF
[/pseudocode]
You are worrying too much, I think. Firstly, gcc and the MS compilers
will both have a sensible default search paths for include files.

Secondly, the compilers themselves will define preprocessor symbols
which you can ifdef on, in the source code, if needed. But read the
"#ifdef considered harmful" paper by Henry Spencer et al.

Thirdly, why not have two different makefiles for the different
environments? If what you do isn't complex, neither of them will be
complex, either. And you can always solve that later, if needed.

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn!
Mar 31 '07 #12
On Mar 29, 10:50 am, "Bastie" <Real.Bas...@googlemail.comwrote:
Hello,

I need to code some libraries for win and linux os and hope make or
somethink can help me to automate my build process. But how can I use
ONE makefile under both os - how can I detect the os in the make
script?

Has anybody an example?
Thanks
you might try checking out QT by trolltech, one code for Win,*nix,Mac
it is C++ based, but the signals/slots are pretty cool

Apr 1 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: inquirydog | last post by:
Hello- I, the inquirydog, would like to solicit suggestions for a new web page I am making: I am creating a simple website that will translate concepts between windows os's, Linux, and the...
12
by: Mike Dee | last post by:
A very very basic UTF-8 question that's driving me nuts: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I...
3
by: Gaetan Poitras | last post by:
I need to know if we can install our database 10g on a linux server, install our AS10g on a linux server and then install on each Windows XP developer 10g ? Is this combinaison will work fine? I...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
9
by: John Eric Hanson | last post by:
My company is considering a development path in which we develop code on 32 bit Windows machines to run remotely on 64 bit Linux machines. What could go wrong?
4
by: John Owens | last post by:
Hi, I'm looking for a plugin for Visual Studio .NET or another IDE etc that would allow me to develop on Windows but have the compiler and debugger and code run on Linux. e.g. Code using...
4
by: Tim Golden | last post by:
Tim Golden enlightened us with: > > Well, I'm with you. I'm sure a lot of people will chime in to point > > out just how flexible and useful and productive Linux is as a > > workstation, but every...
0
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
4
by: peter | last post by:
I've come across a weird difference between the behaviour of the Tkinter checkbox in Windows and Linux. The issue became apparent in some code I wrote to display an image in a fixed size canvas...
20
by: macca | last post by:
Hi, I just started a new web developer job (my first actually) and the machine they gave me to use is a Mac. Two days in and I'm running a Win XP environment on my Mac at work (using VMWare), ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.