Menu

Build process.

Ysblokje
2020-08-14
2020-09-07
  • Ysblokje

    Ysblokje - 2020-08-14

    Hi,

    I would like to know if the makefiles are manually maintained or build using netbeans. And is netbeans the way you work on this project.

    Regardless of the answer would you be open to patches adding CMake or Meson project files?

    Regards,
    Ys

     
  • Michal Hucik

    Michal Hucik - 2020-08-19

    Hello, I have organize project on Linux in Netbeans ver. 8.1 because newest versions of Netbeans unfortunately doesn't suit me. Makefile structure is based on Netbeans, but is manually tuned by me. I need this way for cross-compilling, debugging in IDE, for experiments with another libraries, etc.
    I often switch Netbeans IDE between different platforms whose code is different and often need make tests on Linux and on Windows at the same time.

    I believe, that other project managers like cmake, etc. are much smarter, but I'm afraid that these methods will not be compatible with my development methods and environment. Unfortunately, I no have experience with them....

    However, if you think that it could be maintained by both methods without interfering with each other, then I will not mind.

     
  • Ysblokje

    Ysblokje - 2020-08-19

    Thank you for the response. I've started a version that uses cmake.

     
  • Ysblokje

    Ysblokje - 2020-08-25

    @chaky I have created a temporary git repo for myself with a cmake branch. It contains 1 modification to a script and a whole lot of CMakeLists.txt files. I tested the results and "works for me" , but my workflow is using Archlinux but YMMV.
    https://gitlab.com/ysblokje/mz800emu

    If you could take a look and possibly provide some comments that would be great.
    The next thing I need to do is to create some crosscompiling setup.

    Maybe we should also discuss some of the things you have tweak on platforms so I might be able to automate a few things?

     
    • Michal Hucik

      Michal Hucik - 2020-08-30

      Hi, I got to emulator today...
      I'm using now Centos 7.8 as development desktop. This system is already a little bit older, but I mean so this is still usable.

      My testing: on my PC as first I must change required cmake version to 2.8.12.2

      $ mkdir build; cd build
      $ cmake ..

      ... see attached cmake-output.txt

      All packages reported as unavailable I have available in the pkg-config tool:

      $ pkg-config --list-all|egrep "glib-2.0|gtk+-3.0|libsoup-2.4"
      libsoup-2.4 libsoup - a glib-based HTTP library
      glib-2.0 GLib - C Utility Library
      gtk+-3.0 GTK+ - GTK+ Graphical UI Library

      Another specialty which is realised by current Makefile system is creation of src/build_time.c ... This is created from the shell script tools/create_buildtime.sh
      I think so this do not will be completely standard build option for the cmake :)
      build_time.c is compilation timestamp with informations about svn revision. I'm use this in version check functions and for unique snaphot identification.

       
  • Ysblokje

    Ysblokje - 2020-08-30

    Thanks for looking!

    My testing: on my PC as first I must change required cmake version to 2.8.12.2

    2.8.12 is already 7 years old at this point. And I try to write cmake in the "new" modern cmake style. (>3.0) . Perhaps you could try to use one of the installers from cmake.org if there's no newer version via EPEL (or what is it called these days).

    All packages reported as unavailable I have available in the pkg-config tool:

    This is probably due too old cmake, I would need to investigate.

    Another specialty which is realised by current Makefile system is creation of src/build_time.c ... This is created from the shell script tools/create_buildtime.sh
    I think so this do not will be completely standard build option for the cmake :)
    build_time.c is compilation timestamp with informations about svn revision. I'm use this in version check functions and for unique snaphot identification.

    Nah not that special, I call the script from cmake too. I changed the script only a little to make it also work with git svn commands.

    I will try to use a centos7.8 docker image or something to see how close I can come to getting that to work without too much hassle. I am just glad I dropped the idea of using cmake + conan so that all the libraries would be pulled/build using the conan c/c++ package manager.

    Thanks again for looking!

     
  • Ysblokje

    Ysblokje - 2020-08-30

    Okay, I found that EPEL has cmake3 in it's repositories!
    I have changed some files to make them compile on centos 7.8 now. Using some docker image I created it now compiles on "centos 7.8" for me.

    Let me know what you think.

     
  • Michal Hucik

    Michal Hucik - 2020-08-31

    Hello, thanks for changes of cmake configuration. I have now installed cmake3 (version 3.17.3) from EPEL and I think so Linux compillation is OK.

    OK, what we are need for compilations:

    • if is target system like Unix, so must be defined -DLINUX

    • for Windows target must be defined -DWINDOWS -DWINDOWS_X86

    In the past I've experimented a bit with Win64 (-DWINDOWS_X64), but this is stil for testing only.

    For windows compilation target is required object app.o with the program icon. This is created with the windres tool:

    ${WINDRES} src/windows_icon/app.rc -o app.o

    For cross compilations to Windows I'm use the Mingw. All tools (pkg-config, gcc, windres) uses prefix.

    Win32 has prefix i686-w64-mingw32-
    Win64 has prefix x86_64-w64-mingw32-

    LibSDL2 in Mingw version is not nativly integrated in Mingw pkg-config, but uses own configuration scripts. I have this scripts localised in /usr/local:

    SDL2_CONFIG_MINGW32=/usr/local/cross-tools/i686-w64-mingw32/bin/sdl2-config
    SDL2_CONFIG_MINGW64=/usr/local/cross-tools/x86_64-w64-mingw32/bin/sdl2-config

    SDL2 cross-compiling tool sdl-config used with option --libs create standard linker definitions, but for mz800emu is not good use linker option '-mwindows', because this option supress output console.
    In the Makefile is this fixed by using sed:

    PROJECT_LIBS += ${shell ${SDL2_CONFIG} --libs | /bin/sed -e 's/-mwindows//'}

    I think so that's all :)

     

    Last edit: Michal Hucik 2020-08-31
    • Ysblokje

      Ysblokje - 2020-08-31

      Ok, this is almost easy stuff now ;) I'll probably work on it tonight.

       
      • Ysblokje

        Ysblokje - 2020-09-01

        Ok my and my big mouth. Not so easy because of SDL2.
        On my system SDL2 from mingw did have the .pc file so that was easy enough. I have written a lot of code to make it work if that file is missing.

        OK, what we are need for compilations:

        if is target system like Unix, so must be defined -DLINUX
        
        for Windows target must be defined -DWINDOWS -DWINDOWS_X86
        

        In the past I've experimented a bit with Win64 (-DWINDOWS_X64), but this is stil for testing only.

        Done.

        For windows compilation target is required object app.o with the program icon. This is created with the windres tool:

        ${WINDRES} src/windows_icon/app.rc -o app.o

        Also done, checked the crossbuild binary on a windows machine even

        For cross compilations to Windows I'm use the Mingw. All tools (pkg-config, gcc, windres) uses prefix.

        Win32 has prefix i686-w64-mingw32-
        Win64 has prefix x86_64-w64-mingw32-

        Check the toolchain*.cmake files & readme.md

        LibSDL2 in Mingw version is not nativly integrated in Mingw pkg-config, but uses own configuration scripts. I have this scripts localised in /usr/local:

        SDL2_CONFIG_MINGW32=/usr/local/cross-tools/i686-w64-mingw32/bin/sdl2-config
        SDL2_CONFIG_MINGW64=/usr/local/cross-tools/x86_64-w64-mingw32/bin/sdl2-config

        SDL2 cross-compiling tool sdl-config used with option --libs create standard linker definitions, but for mz800emu is not good use linker option '-mwindows', because this option supress output console.
        In the Makefile is this fixed by using sed:

        PROJECT_LIBS += ${shell ${SDL2_CONFIG} --libs | /bin/sed -e 's/-mwindows//'}

        That was a harder one to solve, but I think have that covered now too.

        I'll be awaiting your new comments. Also I would not be surpriced if there's a way to use cmake from Netbeans, but I haven't looked into that. I am mostly a vim / qtcreator person

         
        • Michal Hucik

          Michal Hucik - 2020-09-02

          Hi, I found a trap on SDL2 cross compilation. I have compiled my own SDL2 and SDL2 for Mingw.
          After run 'make install' in native SDL2 is copied sdl2.pc file into /usr/local/lib/pkgconfig/ directory.
          This path mus be set in environment variable PKG_CONFIG_PATH.
          After run 'make cross' in Mingw SDL2 is created sdl2-config file - localised into /usr/local/cross-tools/ directory structure. I have now linked this file into /usr/local/bin/i686-w64-mingw32-sdl2-config.

          Complications lie in i686-w64-mingw32-pkg-config, because this tool uses the same environment variable like native pkg-config, so gives bad config parameters for sdl2.

          The problem is, of course, solvable by environment variable or move right sdl2.pc into /usr/lib/pkgconfig/ and /usr/...Mingw.../usr/lib/pkgconfig/ directory structure, but it's confusing.

          Maybe it would be good to search executable i686-w64-mingw32-sdl2-config at the first time.


          OK, when is solved previous problem and is used right sdl2.pc or i686-w64-mingw32-sdl2-config so cmake is successfully done. Compilation is OK, but the linker is reporting an error:

          [100%] Linking C executable mz800emu.exe
          /usr/lib/gcc/i686-w64-mingw32/4.9.3/../../../../i686-w64-mingw32/bin/ld: cannot find -lSDL2main
          /usr/lib/gcc/i686-w64-mingw32/4.9.3/../../../../i686-w64-mingw32/bin/ld: cannot find -lSDL2
          

          Here is --libs config:

          -L/usr/local/cross-tools/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
          
           
          • Ysblokje

            Ysblokje - 2020-09-02

            I think I found what the issue is with the link failure. because for me everything is in the same location I didn't notice I forgot to add the library location(s) to the imported SDL2::SDL2 target.
            This should be fixed now.

            Also I tried netbeans 8.1 and I noticed it understands cmake so that was nice to see and try.

             
            • Michal Hucik

              Michal Hucik - 2020-09-02

              Hi, latest version is now OK!

              Is posible set any own compiler and linker options? For example '-pedantic -Wall'. Sometime I need switch between production '-O2' and development version '-O0 -g', add ElectricFences, etc.

              ad Netbeans: I tryed to create Netbeans project with existing sources managed by cmake. It is posible, but on this new project is not available organisation source files into Netbeans logical folders, or switching betwen project profiles and I dont know if is available full refractorization.

              For example if You open my original project in Netbeans, You can online switch betwen my prepared profiles Release-Win32, Release-Linux, Debug-Linux, etc. This switch is realised by one Makefile. The editor environment immediately accepts the change of the header include directories and you can online see differences caused by different versions of gtk3+ in native inux and in Mingw32, etc.

              However, I think so this is not necessary for end users which only need compile his own binary version of mz800emu.

              I think your latest configuration of cmake is good. If you don't mind, I'll add it to my mz800emu project.

               
              • Ysblokje

                Ysblokje - 2020-09-02

                Is posible set any own compiler and linker options? For example '-pedantic -Wall'.
                Sometime I need switch between production '-O2' and development version '-O0 -g',
                add ElectricFences, etc.

                What I normally do is change CMAKE_BUILD_TYPE to Debug or Release. You really want to look at cmake-gui to tell you all the options if you are a "graphical" person.
                QtCreator also gives you all the options in a nice menu and proposes multi config too at first load of a cmake project (release / debug / various kits you might have set up)

                But yes it is possible to adjust CFLAGS using either the cmake gui or just cmake cli.
                Also if you want to add this as an option to turn off or on I can do that before you merge this.

                 
                • Ysblokje

                  Ysblokje - 2020-09-02

                  I added a few options to easy the setting up of those things you mentioned, also I made cmake require you setup a build type, if you want anything else than release.

                  Hope that helps.

                   
                  • Michal Hucik

                    Michal Hucik - 2020-09-07

                    Thank you, cmake configurations are now added into project.

                     
                    • Ysblokje

                      Ysblokje - 2020-09-07

                      awesome... now I can go back to fixing my actual mz800 ;)

                       

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.
Try Free →