Windows and Linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bastie

    #1

    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

  • Richard Heathfield

    #2
    Re: Windows and Linux

    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

    email: rjh at the above domain, - www.

    Comment

    • Bastie

      #3
      Re: Windows and Linux

      On 29 Mrz., 17:09, Richard Heathfield <r...@see.sig.i nvalidwrote:
      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...

      Comment

      • Richard Heathfield

        #4
        Re: Windows and Linux

        Bastie said:
        On 29 Mrz., 17:09, Richard Heathfield <r...@see.sig.i nvalidwrote:
        >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

        email: rjh at the above domain, - www.

        Comment

        • Bastie

          #5
          Re: Windows and Linux

          On 29 Mrz., 17:09, Richard Heathfield <r...@see.sig.i nvalidwrote:
          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...

          Comment

          • mark_bluemel@pobox.com

            #6
            Re: Windows and Linux

            On 29 Mar, 15:50, "Bastie" <Real.Bas...@go oglemail.comwro te:
            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>

            Comment

            • Pierre Asselin

              #7
              Re: Windows and Linux

              Bastie <Real.Bastie@go oglemail.comwro te:
              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

              Comment

              • Mark McIntyre

                #8
                Re: Windows and Linux

                On Thu, 29 Mar 2007 16:33:52 +0000 (UTC), in comp.lang.c ,
                pa@see.signatur e.invalid (Pierre Asselin) wrote:
                >Bastie <Real.Bastie@go oglemail.comwro te:
                >
                >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

                Comment

                • CBFalconer

                  #9
                  Re: Windows and Linux

                  Pierre Asselin wrote:
                  Bastie <Real.Bastie@go oglemail.comwro te:
                  >
                  >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

                  Comment

                  • Bastie

                    #10
                    Re: Windows and Linux

                    On 29 Mrz., 23:21, Mark McIntyre <markmcint...@s pamcop.netwrote :
                    On Thu, 29 Mar 2007 16:33:52 +0000 (UTC), in comp.lang.c ,
                    >
                    p...@see.signat ure.invalid (Pierre Asselin) wrote:
                    Bastie <Real.Bas...@go oglemail.comwro te:
                    >
                    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]

                    Comment

                    • Nelu

                      #11
                      Re: Windows and Linux

                      On Mar 29, 11:49 pm, "Bastie" <Real.Bas...@go oglemail.comwro te:
                      On 29 Mrz., 23:21, Mark McIntyre <markmcint...@s pamcop.netwrote :
                      >
                      >
                      >
                      On Thu, 29 Mar 2007 16:33:52 +0000 (UTC), in comp.lang.c ,
                      >
                      p...@see.signat ure.invalid (Pierre Asselin) wrote:
                      >Bastie <Real.Bas...@go oglemail.comwro te:
                      >
                      >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...)

                      Comment

                      • Jorgen Grahn

                        #12
                        Re: Windows and Linux

                        On 29 Mar 2007 20:49:35 -0700, Bastie <Real.Bastie@go oglemail.comwro te:
                        ....
                        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.dyn dns.org R'lyeh wgah'nagl fhtagn!

                        Comment

                        • verdverm@gmail.com

                          #13
                          Re: Windows and Linux

                          On Mar 29, 10:50 am, "Bastie" <Real.Bas...@go oglemail.comwro te:
                          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

                          Comment

                          Working...