[Patch] New Makefile

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

[Patch] New Makefile

Postby HarryTuttle » Sat Mar 11, 2017 9:30 am

This patch should:

- auto set some compile-time variables (includes, libraries, etc.) and will compile and link 32/64 versions based on host system environment (at last works under MSYS2)

- outputs objects to "_obj" and binaries to "_bin" avoiding some clutter in main repository tree.

- show less verbose and more cleaner compile progress status like this:
Code: Select all
Compiling Src/OSD/SDL/SDLInputSystem.cpp...
Compiling Src/OSD/Windows/DirectInputSystem.cpp...
Compiling Src/OSD/Outputs.cpp...
Compiling Src/OSD/Windows/WinOutputs.cpp...
Compiling Src/OSD/Logger.cpp...
Compiling Src/Pkgs/tinyxml2.cpp...
Compiling Src/Debugger/Debugger.cpp...
Compiling Src/Debugger/ConsoleDebugger.cpp...
...
Compiling Src/Debugger/CPU/Musashi68KDebug.cpp...
Compiling Src/Debugger/CPU/Z80Debug.cpp...
Linking _bin/supermodel.exe...


- be multithread-friendly so that issuing "make -jx" with x > 1 now works as expected (and is a lot faster too!).

compile options:
VERBOSE = [0|1] with '1' reverts to old verbose progress status
ENABLE_DEBUGGER = [0|1] with '1' include console-based debugger in emulator (like the original makefile)

Testing, as always, is welcome and appreciated. Let me know!
Attachments
diff.zip
(3.18 KiB) Downloaded 335 times
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] New Makefile

Postby Kacperas » Sun Mar 12, 2017 1:05 pm

I've tried to build Supermodel on this MSYS2, using your makefile. While multithread speeds up the process greatly, compilation fails at linking. :(

Code: Select all
$ make -j8
Creating folder _bin...
Creating folder _obj...
Compiling Src/Util/Format.cpp...
Compiling Src/Util/NewConfig.cpp...
Compiling Src/Graphics/New3D/R3DScrollFog.cpp...
Compiling Src/CPU/PowerPC/PPCDisasm.cpp...
Compiling Src/Games.cpp...
Compiling Src/Config.cpp...
Compiling Src/INIFile.cpp...
Compiling Src/BlockFile.cpp...
Compiling Src/Model3/93C46.cpp...
Compiling Src/ROMLoad.cpp...
Compiling Src/Pkgs/unzip.c...
Compiling Src/Pkgs/ioapi.c...
Compiling Src/Graphics/Legacy3D/Error.cpp...
Compiling Src/Pkgs/glew.c...
Compiling Src/Graphics/Shader.cpp...
Compiling Src/Model3/Real3D.cpp...
Compiling Src/Graphics/Legacy3D/Legacy3D.cpp...
Compiling Src/Graphics/Legacy3D/Models.cpp...
Compiling Src/Graphics/Legacy3D/TextureRefs.cpp...
Compiling Src/Graphics/New3D/New3D.cpp...
Compiling Src/Graphics/New3D/Mat4.cpp...
Compiling Src/Graphics/New3D/Model.cpp...
Compiling Src/Graphics/New3D/PolyHeader.cpp...
Compiling Src/Graphics/New3D/Texture.cpp...
Compiling Src/Graphics/New3D/TextureSheet.cpp...
Compiling Src/Graphics/New3D/VBO.cpp...
Compiling Src/Graphics/New3D/Vec.cpp...
Compiling Src/Graphics/New3D/R3DShader.cpp...
Compiling Src/Graphics/New3D/R3DFloat.cpp...
Compiling Src/Graphics/Render2D.cpp...
Compiling Src/Model3/TileGen.cpp...
Compiling Src/Model3/Model3.cpp...
Compiling Src/CPU/PowerPC/ppc.cpp...
Compiling Src/OSD/SDL/Main.cpp...
Compiling Src/OSD/SDL/Audio.cpp...
Compiling Src/OSD/SDL/Thread.cpp...
Compiling Src/Model3/SoundBoard.cpp...
Compiling Src/Sound/SCSP.cpp...
Compiling Src/Sound/SCSPDSP.cpp...
Compiling Src/CPU/68K/68K.cpp...
Compiling Src/CPU/68K/Musashi/m68kmake.c...
Compiling Src/Model3/DSB.cpp...
Compiling Src/CPU/Z80/Z80.cpp...
Compiling Src/Model3/IRQ.cpp...
Compiling Src/Model3/53C810.cpp...
Linking _obj/m68kmake.exe...
Compiling Src/Model3/PCI.cpp...
Compiling Src/Model3/RTC72421.cpp...
Compiling Src/Model3/DriveBoard.cpp...
Compiling Src/Model3/MPC10x.cpp...
Compiling Src/Inputs/Input.cpp...
Compiling Src/Inputs/Inputs.cpp...
Compiling Src/Inputs/InputSource.cpp...
Compiling Src/Inputs/InputSystem.cpp...
Compiling Src/Inputs/InputTypes.cpp...
Compiling Src/Inputs/MultiInputSource.cpp...
Compiling Src/OSD/SDL/SDLInputSystem.cpp...
Compiling Src/OSD/Windows/DirectInputSystem.cpp...
Compiling Src/OSD/Outputs.cpp...
Compiling Src/OSD/Windows/WinOutputs.cpp...
Compiling Src/Sound/MPEG/audio.cpp...
Compiling Src/Sound/MPEG/dump.cpp...
Compiling Src/Sound/MPEG/getbits.cpp...
Compiling Src/Sound/MPEG/getdata.cpp...
Compiling Src/Sound/MPEG/huffman.cpp...
Compiling Src/Sound/MPEG/layer2.cpp...
Compiling Src/Sound/MPEG/layer3.cpp...
Compiling Src/Sound/MPEG/misc2.cpp...
Compiling Src/Sound/MPEG/position.cpp...
Compiling Src/Sound/MPEG/transform.cpp...
Compiling Src/Sound/MPEG/util.cpp...
Compiling Src/Model3/Crypto.cpp...
Compiling Src/OSD/Logger.cpp...
Compiling Src/Pkgs/tinyxml2.cpp...
Preprocessing m68k_in.c...
--------------------------------------------------------------------------------

                Musashi v3.3 68000, 68008, 68010, 68EC020, 68020 emulator
                Copyright 1998-2000 Karl Stenerud (karl@mame.net)

Generated 1962 opcode handlers from 513 primitives
--------------------------------------------------------------------------------
Compiling Src/CPU/68K/Musashi/m68kcpu.c...
Compiling _obj/m68kopnz.c...
Compiling _obj/m68kopdm.c...
Compiling _obj/m68kopac.c...
Compiling _obj/m68kops.c...
Linking _bin/supermodel.exe...
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lmingw32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lmingw32
collect2: error: ld returned 1 exit status
make: *** [makefile:179: all] Error 1


As there isn't any -lmingw32 in your makefile, I think this could be a distro problem or I'm missing another package... (not to mention, that I had to solve a bunch of other issues to get to this point)
Which MSYS2/MINIGW distro are you using?
Kacperas
 
Posts: 42
Joined: Tue Sep 27, 2011 9:35 am

Re: [Patch] New Makefile

Postby HarryTuttle » Sun Mar 12, 2017 2:08 pm

Kacperas wrote:I've tried to build Supermodel on this MSYS2, using your makefile. While multithread speeds up the process greatly, compilation fails at linking. :(


I currently use this: http://www.msys2.org it's a fork by a certain Alexpux (repository: https://github.com/Alexpux)

It's updated daily, and uses Arch Linux's Pacman as package manager. I build MAME, Supermodel, Cen64, Mupen64Plus and other small tools with it. It's super easy to install and maintain.

Note however: if you want to build under Windows (I use Windows 7 x64) you have to start either with:
Code: Select all
msys2_shell.cmd -mingw64

or:
Code: Select all
msys2_shell.cmd -mingw32


depending in what type of binary you want to build. But using for example:
Code: Select all
msys2_shell.cmd -msys

you will not able to build native windows binaries, unless you want cross-compile. Let me know! :)
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] New Makefile

Postby Kacperas » Sun Mar 12, 2017 2:46 pm

HarryTuttle wrote:I currently use this: http://www.msys2.org it's a fork by a certain Alexpux (repository: https://github.com/Alexpux)

By chance, I've installed the same one (different link to the same thing). Well, Pacman was the reason, why I've chose this disto. :)

HarryTuttle wrote:Note however: if you want to build under Windows (I use Windows 7 x64) you have to start either with:
Code: Select all
msys2_shell.cmd -mingw64
[...]
you will not able to build native windows binaries, unless you want cross-compile.

That did the trick. :)
Thank you for help.
Kacperas
 
Posts: 42
Joined: Tue Sep 27, 2011 9:35 am

Re: [Patch] New Makefile

Postby HarryTuttle » Sun Mar 12, 2017 2:48 pm

Glad you did it! :D
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] New Makefile

Postby Bart » Mon Mar 13, 2017 10:37 pm

Thanks for all your hard work on this! I'm glad you and Ian are making amazing progress on the graphics engine. I've been swamped with other projects lately so I haven't had much time for Supermodel :( But I do intend to incorporate your changes, beginning with this one.

I'm using standard msys with tdm-gcc, so I don't have access to pkg-config. I think what I'll do is make a modification to fall back on hard-coded paths in the Makefile if pkg-config does not exist (I'm not a Makefile guru, so hopefully it's easy to detect when pkg-config fails to execute).
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: [Patch] New Makefile

Postby HarryTuttle » Tue Mar 14, 2017 5:39 am

Bart wrote:I'm using standard msys with tdm-gcc, so I don't have access to pkg-config. I think what I'll do is make a modification to fall back on hard-coded paths in the Makefile if pkg-config does not exist (I'm not a Makefile guru, so hopefully it's easy to detect when pkg-config fails to execute).


Ok! :)

I used pkg-config to automatize system libs and header inclusion and to be platform agnostic as possible as i can, however it's better to implement a fallback mechanism like you said.

BTW, "make" documentation is huge, I'm neither a guru and spent a whole day to figure out how to set variable overrides inside the makefile...
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] New Makefile

Postby Bart » Tue Apr 04, 2017 9:20 am

HarryTuttle wrote:
Bart wrote:I'm using standard msys with tdm-gcc, so I don't have access to pkg-config. I think what I'll do is make a modification to fall back on hard-coded paths in the Makefile if pkg-config does not exist (I'm not a Makefile guru, so hopefully it's easy to detect when pkg-config fails to execute).


Ok! :)

I used pkg-config to automatize system libs and header inclusion and to be platform agnostic as possible as i can, however it's better to implement a fallback mechanism like you said.

BTW, "make" documentation is huge, I'm neither a guru and spent a whole day to figure out how to set variable overrides inside the makefile...


make is really annoying me. I almost want to get rid of Makefiles and write a custom Python build script that automagically builds everything (we have something like this at work and it's super clever -- no need to ever write a Makefile, it just figures out what to build by itself).

I wanted to have the makefile detect whether pkg-config exists on the system but it seems there is no easy way to test whether a command can execute successfully?
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: [Patch] New Makefile

Postby HarryTuttle » Sun Jul 30, 2017 8:39 am

PATCH UPDATE for r620

Updated makefile for the recent changes. It's tested ONLY under MSYS2 environment (launched with "-mingw64 -mintty -here" command line parameters) running under Windows 7 x64.

It relies on the presence of "pkg-config" cli tool to get the environment paths for the various dependencies (includes and libs).
Attachments
diff_02.zip
(15.25 KiB) Downloaded 306 times
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] New Makefile

Postby Kacperas » Sun Jul 30, 2017 11:13 am

Thank you Harry.
It's working fine on Windows 10 x64.
Kacperas
 
Posts: 42
Joined: Tue Sep 27, 2011 9:35 am

Next

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest