# Building PHP, questions

- Thread: https://externals.io/message/73111
- Original archive: https://news-web.php.net/php.internals/73111
- Started by Kevin Ingwersen on 2014-03-13T16:52:40+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #73111 — Kevin Ingwersen — 2014-03-13T16:52:40+00:00

URL: https://externals.io/message/73111#73111

Hey there.

For a project I am working on,I want to implement a minimal version of PHP - really, just it and a very tiny subset of modules. Its for embeding PHP at the end. I can tell that I need to compile realyl everything from main and TSRM. But what other fiels do I need to compile - AND generate? I know I have to generate config.h - but what does it depend on?

I am not going to be able to use Autotools - because I am porting it into a build system I am contributing to.

Kind regards, Ingwie

---

## #73113 — johannes@schlueters.de — 2014-03-13T17:15:32+00:00

URL: https://externals.io/message/73111#73113 · In reply to: #73111

> Hey there.
> 
> For a project I am working on,I want to implement a minimal version of
> PHP - really, just it and a very tiny subset of modules. Its for

Define minimal.
cd Zend && ./buildconf && configure && make
combined with one or two trivial patches to get rid of TSRM dependencies
gives you a standalone library containing only the engine. The result of
configure --disable-all in the php source is the minimum useful thing.

>  embeding PHP at the end. I can tell that I need to compile realyl
> everything from main and TSRM. But what other fiels do I need to
> compile - AND generate? I know I have to generate config.h - but what
> does it depend on?

The ones referenced from the current build system's Makefile. I doubt
anybody keeps an extra list. Mind that i.e. TSRM becomes quite small in
non-tsrm mode.

> I am not going to be able to use Autotools - because I am porting it
> into a build system I am contributing to.

Why? You can always build PHP as a library using --enable-embed (add
"=static" if you want it to be a static library) and use that from your
other project, yes this adds a dependency but avoids lots of build
issues.

johannes

---

## #73114 — Kevin Ingwersen — 2014-03-13T18:15:05+00:00

URL: https://externals.io/message/73111#73114 · In reply to: #73113

The thing is, that the build itself cant run buildconf or configure, so I have to „port“ the libphp5 part to the build system I am using.
With minimal, I just mean to have a runnable scripting engine. Basicaly, i want to rebuild what you get when using —disable-all —enable-static —enable-embed. 
How far is TSMRC a dependency of PHP actually? I might actually need the thread sefety, so I bet i should compile that in in any case.
Am 13.03.2014 um 18:15 schrieb Johannes Schlüter <johannes@schlueters.de>:

> 
> > […]
> 
> Define minimal.
> cd Zend && ./buildconf && configure && make
> combined with one or two trivial patches to get rid of TSRM dependencies
> gives you a standalone library containing only the engine. The result of
> configure --disable-all in the php source is the minimum useful thing.
> 
> > […]
> 
> The ones referenced from the current build system's Makefile. I doubt
> anybody keeps an extra list. Mind that i.e. TSRM becomes quite small in
> non-tsrm mode.
> 
> > […]
> 
> Why? You can always build PHP as a library using --enable-embed (add
> "=static" if you want it to be a static library) and use that from your
> other project, yes this adds a dependency but avoids lots of build
> issues.
> 
> johannes

---

## #73115 — Pierre Joye — 2014-03-13T18:41:55+00:00

URL: https://externals.io/message/73111#73115 · In reply to: #73114

hi,

On Thu, Mar 13, 2014 at 7:15 PM, Kevin Ingwersen
<ingwie2000@googlemail.com> wrote:
> The thing is, that the build itself cant run buildconf or configure, so I have to „port“ the libphp5 part to the build system I am using.
> With minimal, I just mean to have a runnable scripting engine. Basicaly, i want to rebuild what you get when using —disable-all —enable-static —enable-embed.

Do you do that for all dependencies you have for your project (libs)?

PHP embend is nothing else that just another library. As Johannes
suggested, it could be much easier for you to simply use the static
build instead of redoing the configure&build scripts, and much easier
to update to newer versions as well.

> How far is TSMRC a dependency of PHP actually? I might actually need the thread sefety, so I bet i should compile that in in any case.

You can hardly remove it, unless you want to spend weeks patching php.
It is a requirement for thread safety too (TSRM mean Thread safe
resource manager :).

Cheers,
-- 
Pierre

@pierrejoye | http://www.libgd.org

---

## #73116 — Kevin Ingwersen — 2014-03-13T18:50:22+00:00

URL: https://externals.io/message/73111#73116 · In reply to: #73115

Hey.

Yes, all dependencies are being ported to that build system. PHP is the biggest dependency though. There are many scripting languages I like, that are even small (ph7, objectscript) - but I trust the original PHP the most - so I wish to use it in my project. Hence, to make it compatible with my project, I also need to make it build-able in my project.

About TSRM; thats fine. I didnt expect it to be removed - an dhonestly, why patching a way a feature thats actually very useful? ^^

As said, I am unable to use autotools before, during or after the build process, so if I want to or not, I must compile a basic PHP by myself, including generating the needed header files - config.h if I am not wrong.

Kind regards, Ingwie
Am 13.03.2014 um 19:41 schrieb Pierre Joye <pierre.php@gmail.com>:

> hi,
> 
> On Thu, Mar 13, 2014 at 7:15 PM, Kevin Ingwersen
> <ingwie2000@googlemail.com> wrote:
> > […]
> 
> Do you do that for all dependencies you have for your project (libs)?
> 
> PHP embend is nothing else that just another library. As Johannes
> suggested, it could be much easier for you to simply use the static
> build instead of redoing the configure&build scripts, and much easier
> to update to newer versions as well.
> 
> > […]
> 
> You can hardly remove it, unless you want to spend weeks patching php.
> It is a requirement for thread safety too (TSRM mean Thread safe
> resource manager :).
> 
> Cheers,

---

## #73117 — Anatol Belski — 2014-03-13T18:52:54+00:00

URL: https://externals.io/message/73111#73117 · In reply to: #73114

Hi,


> The thing is, that the build itself cant run buildconf or configure, so I
>  have to „port“ the libphp5 part to the build system I am using. With
I think you could run configure & make from your build system and link
against .so or static. That were the easiest way. Otherwise you'll
probably need to sort out all the needed stuff manually (files, headers,
preprocessor, etc.)

> minimal, I just mean to have a runnable scripting engine. Basicaly, i want
> to rebuild what you get when using —disable-all —enable-static
> —enable-embed.
> How far is TSMRC a dependency of PHP actually? I might actually need the
> thread sefety, so I bet i should compile that in in any case. Am 13.03.2014
> um 18:15 schrieb Johannes Schlüter <johannes@schlueters.de>:
>
> > […]
>
>
>
> --
> 
> 
>
>
>

Regards

Anatol

---

## #73118 — johannes@schlueters.de — 2014-03-13T18:53:09+00:00

URL: https://externals.io/message/73111#73118 · In reply to: #73114

> The thing is, that the build itself cant run buildconf or configure,
> so I have to „port“ the libphp5 part to the build system I am using.

I don't understand that requirement. I don't understand what is limiting
you from building PHP first, then the other thing. Just like one does
with most other applications people embed PHP in (i.e. Apache httpd,
Microsoft IIS, ... ok, yeah there the process is the other way round,
but that's a build detail, php-irssi is the same way round
https://svn.php.net/viewvc/archived/embed/trunk/php-irssi/ )

> With minimal, I just mean to have a runnable scripting engine.
> Basicaly, i want to rebuild what you get when using —disable-all —
> enable-static —enable-embed. 

so, as said, check the Makefile to see what is referenced in there.
(Hint: start with PHP_GLOBAL_OBJS in there) but you are entering a land
of pain. The file structure can change with each minor release.

Oh and the other generated files ... simply run configure for an out of
tree build ...  `cd php-src && mkdir foo && cd foo && ../configure &&
find -type f`

> How far is TSMRC a dependency of PHP actually? I might actually need
> the thread sefety, so I bet i should compile that in in any case.

If you "might actually need" thread safety you "might actually" compile
it in, if not set the flags accordingly for not having build 90% of
TSRM. (actually I thin you need to set flags to enable it, off is
default ...) If you don't need it what do you want to optimize for? Sure
one can patch things out, but that increases maintenance costs and
increases need for testing.

johannes

---

## #73119 — johannes@schlueters.de — 2014-03-13T18:59:20+00:00

URL: https://externals.io/message/73111#73119 · In reply to: #73116

> Hey.
> 
> Yes, all dependencies are being ported to that build system. PHP is
> the biggest dependency though. There are many scripting languages I
> like, that are even small (ph7, objectscript) - but I trust the
> original PHP the most - so I wish to use it in my project. Hence, to
> make it compatible with my project, I also need to make it build-able
> in my project.

what kind of platform/system is that, that not even cross-compiling
(which isn't fully supported but still simpler than recreating a build
system) and statically linking won't work?

johannes

---

## #73121 — Kevin Ingwersen — 2014-03-13T19:34:27+00:00

URL: https://externals.io/message/73111#73121 · In reply to: #73119

The main platforms are supposed to be Windows, Linux and Mac. The largest problem that I am encountering is with the varity of compilers and build systems. The build system I am working has an auto-detect feature for compilers, and can handle compiling in a rather fast way (its about to learn parallel building by default). Building PHP on Windows is a pita, if you cant use Visual Studio’s command line - I am usualy building with mingw, but trying to make mingw portable, is problematic.
In the end, the project will be capable of packing userdata into its binary, by creating a zip file, converting it into a C string (char array) and then running it. But most users won’t have a build system or such, so I am trying to create some kind of „automatic build“ - which can easily be achieved with the build system that I am using. Once it’s few files are compiled, it works cross platform and can handle anything from selecting compilers to generating files. Its less of a hassle than letting people set up mingw first - cause I can just ship a portable version of MinGW that can do the job.

It probably sounds much like gibberish, because I am kind of sleepy too. But in general, I want to avoid making even more dependencies. Theo the rlibrarys in use were ported from CMake and are relatively small. So I wanted to port PHP to that build system to keep things in one place.
Am 13.03.2014 um 19:59 schrieb Johannes Schlüter <johannes@schlueters.de>:

> 
> > […]
> 
> what kind of platform/system is that, that not even cross-compiling
> (which isn't fully supported but still simpler than recreating a build
> system) and statically linking won't work?
> 
> johannes
