|
| 1 | +### ABOUT |
| 2 | + |
| 3 | +This small, frugal, self-containing (apart from a working MSVC shell, of |
| 4 | +course) build scaffolding creates "true" static builds of SFML for MSVC, |
| 5 | +as opposed to the shipped prebuilt lib versions that still depend on the |
| 6 | +MSVC (redistributable) runtime library DLLs, that may or may not be present |
| 7 | +on a target Windows instance. |
| 8 | + |
| 9 | +IOW, the official SFML binaries have been compiled with `-MD` (and `-MDd` |
| 10 | +for DEBUG), whereas this setup builds with `-MT` (and `-MTd`) by default. |
| 11 | +(You can still build for the DLL version of the CRT with `build CRT=dll`.) |
| 12 | + |
| 13 | +Note that it's not possible to mix differently compiled object code, so |
| 14 | +if you want to ensure that your app (or even just a simple static lib) that |
| 15 | +uses SFML doesn't "secretly" depend on any of the MSVC runtime DLLs, then |
| 16 | +recompiling SFML from source is your only option. |
| 17 | + |
| 18 | +The generated static libs with the also static CRT dependency will have |
| 19 | +an extra `-s` suffix (in addition to the official one), e.g. |
| 20 | +`sfml-window-s-s.lib` or `sfml-window-s-s-d.lib`. (This scheme follows the |
| 21 | +original implicit general logic of "-s for static, nothing for DLL"...) |
| 22 | + |
| 23 | +NOTE: The external `OpenAL.dll` library will still be linked dynamically |
| 24 | +(no way around that, AFAIK), but at least you can just easily ship that |
| 25 | +along with your executable (unlike the MSVC Redist. package). |
| 26 | + |
| 27 | +------------------------------------------------------------------------------ |
| 28 | + |
| 29 | +### BEWARE! |
| 30 | + |
| 31 | +This is an experimental proof-of-concept prototype tool for my own personal |
| 32 | +use, to quickly test integrating "SFML/MT" with some other projects. |
| 33 | + |
| 34 | +The scripts and the makefile have been ripped out of some other existing |
| 35 | +configurations, _where this build setup was already pretty experimental to |
| 36 | +begin with!_ :) (I've been test-driving the surprisingly usable built-in make |
| 37 | +tool of [BusyBox-w32](https://github.com/rmyorston/busybox-w32/).) |
| 38 | + |
| 39 | +So, this stuff here is full of weird remnants and junk -- OTOH, it still |
| 40 | +worked so well (thanks to the beautifully clean SFML repo, and its general |
| 41 | +build-friendly qualities, with all the external dependencies prepackaged* |
| 42 | +etc.) that I've just proceeded to baseline it as "the" build tool for this |
| 43 | +particular purpose of mine, in the context of my own projects. |
| 44 | + |
| 45 | +Your mileage may vary. |
| 46 | + |
| 47 | +\* <sub>FTR: I actually forgot that SFML comes with batteries included, and I |
| 48 | + initially downloaded & compiled everything from scratch, individually, |
| 49 | + fixing issues here and there etc., only to realize after-the-fact that |
| 50 | + I worked so hard for absolutely nothing... (I have a mild case of ADD, |
| 51 | + and didn't even realize that the repo already has an `extlibs` dir! :) )</sub> |
| 52 | + |
| 53 | +------------------------------------------------------------------------------ |
| 54 | + |
| 55 | +### BUILD STEPS |
| 56 | + |
| 57 | +#### 1. Download and unpack the SFML source repo |
| 58 | + |
| 59 | + https://github.com/SFML/SFML/archive/refs/heads/master.zip |
| 60 | + |
| 61 | + (Note that this is the latest pre-3.0 branch, very much in flux, but |
| 62 | + still very usable and robust, albeit breaking the API occasionally.) |
| 63 | + |
| 64 | + The unpacked repo (should be `SFML-master` -- adjust the build script |
| 65 | + if it isn't) is expeted to be in the same dir as the `build` script. |
| 66 | + |
| 67 | +#### 2. One small fix... |
| 68 | + |
| 69 | + There's one thing I had to fix there: disable FLAC's assert.h in |
| 70 | + `extlibs\headers\FLAC`. It kept failing with `assert` being an undefined |
| 71 | + identifier, probably due to the `INCLUDE` path (ordering) set up by the |
| 72 | + scripts, and I couldn't quickly find the reason; but strangely enough, |
| 73 | + just taking that header down fixed it... :-o |
| 74 | + |
| 75 | +#### 3. CRUCIAL: Remove the unused platform sources! |
| 76 | + |
| 77 | + This experimental makefile can't skip directories, and would just want |
| 78 | + to compile all the C/C++ files it can find in the source tree. So, |
| 79 | + |
| 80 | + ALL THE IRRELEVANT PLATFORM-SPECIFIC SOURCES MUST BE MOVED OUT |
| 81 | + OF THE WAY MANUALLY! |
| 82 | + |
| 83 | + |
| 84 | + Fortunately, this is very easy, too: just remove all but the `Win32` subdirs |
| 85 | + under `src`, namely from: |
| 86 | + |
| 87 | + - Window |
| 88 | + - Main |
| 89 | + - Network |
| 90 | + - System |
| 91 | + |
| 92 | + (or wherever else you may find any). |
| 93 | + |
| 94 | +#### 4. Run `build` |
| 95 | + |
| 96 | + You can specify `CRT=dll` to build the original ("half") static libs, and |
| 97 | + `DEBUG=1` for a debug version. E.g.: |
| 98 | + |
| 99 | + build |
| 100 | + |
| 101 | + would build the fully static libs in release mode (-DNDEBUG -O2), while |
| 102 | + |
| 103 | + build CRT=dll DEBUG=1 |
| 104 | + |
| 105 | + would build for the DLL version of th MSVC runtime, with debug info and |
| 106 | + disabled optimizations. |
| 107 | + |
| 108 | + The generated .lib files are in the `lib` dir, created inside the repo, so |
| 109 | + that now it has a compatible layout with the official pre-built packages. |
| 110 | + (Except the `bin` dir, as this build tool does not build DLLs. It probably |
| 111 | + could, but I just didn't bother adding that without a good reason.) |
| 112 | + |
| 113 | + Note: each of the four supported build combinations are built in separate |
| 114 | + parallel "VPATH" trees, so you can incrementally rebuild them, if you wish, |
| 115 | + without interference. |
| 116 | + |
| 117 | +#### 5. There's no `build clean` |
| 118 | + |
| 119 | +Just delete the `.build.tmp` dir (or only its build-mode specific subtree |
| 120 | +that you want to fully rebuild). |
0 commit comments