internals:cmake:notes

CMake Work Notes

Linux buildchain

  • buildconf

Shell script to recreate user tarball, two options –force and –debug, if –$force regenerate anyway, if debug only add SUPPRESS_WARNINGS=“” to make invocation. Extract version from `grep '^PHP_EXTRA_VERSION=' configure.in` to check if is dev, and check Zend directory to check if is Zend v1 or Zend v2 (this is deprecated?) At end call make -s -f build/build.mk ZENDDIR=Zend

  • build/build.mk
    • ($STAMP) - call buildcheck.sh (check autoconf version > 2.13 and inform)
    • ($ALWAYS) == generated_lists - makefile_am_files, config_h_files, config_m4_files » generated_lists
    • (action) call build/build2.mk - all: mkinstalldirs install-sh missing configure main/php_config.h.in
      • touch mkinstalldirs install-sh missing
      • cat acinclude.m4 ./build/libtool.m4 > aclocal.m4
      • autoconf (to regenerate ./configure)
      • autoheader (to regenerate acconfig.h)
    • Ready to configure.

At this step generated files are:

? acconfig.h
? aclocal.m4
? autom4te.cache/output.0
? autom4te.cache/requests
? autom4te.cache/traces.0
? configure
? generated_lists
? install-sh
? main/php_config.h.in
? missing
? mkinstalldirs
  • ./configure
? Makefile
? Makefile.fragments
? Makefile.objects
? TSRM/tsrm_config.h
? Zend/zend_config.h
? config.log
? config.nice
? config.status
? ext/date/lib/timelib_config.h
? ext/iconv/php_have_bsd_iconv.h
? ext/iconv/php_have_glibc_iconv.h
? ext/iconv/php_have_ibm_iconv.h
? ext/iconv/php_have_iconv.h
? ext/iconv/php_have_libiconv.h
? ext/iconv/php_iconv_supports_errno.h
? ext/iconv/php_php_iconv_h_path.h
? ext/iconv/php_php_iconv_impl.h
? ext/pdo_sqlite/sqlite/src/config.h
? ext/pdo_sqlite/sqlite/src/sqlite3.h
? ext/sqlite/libsqlite/src/config.h
? ext/sqlite/libsqlite/src/sqlite.h
? libtool
? main/build-defs.h
? main/internal_functions.c
? main/internal_functions_cli.c
? main/php_config.h
? php5.spec
? sapi/cli/php.1
? scripts/man1/php-config.1
? scripts/man1/phpize.1
? scripts/php-config
? scripts/phpize

Windows buildchain

  • Windows side: buildconf.bat execute → cscript /nologo win32\build\buildconf.js %*, Javascript script that build the configure.js.

Components

Zend

  • Zend/Makefile.am
  • Zend/acconfig.h
  • Zend/Zend.m4
Configuring Zend
checking for bison version... (cached) 2.3 (ok)
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for limits.h... (cached) yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for stdarg.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for signal.h... (cached) yes
checking for unix.h... (cached) no
checking for stdlib.h... (cached) yes
checking for dlfcn.h... (cached) yes
checking for mach-o/dyld.h... (cached) no
checking for size_t... (cached) yes
checking return type of signal handlers... void
checking for uint... yes
checking for ulong... yes
checking for int32_t... yes
checking for uint32_t... yes
checking for vprintf... (cached) yes
checking for _doprnt... (cached) no
checking for working memcmp... yes
checking for working alloca.h... (cached) yes
checking for alloca... (cached) yes
checking for memcpy... (cached) yes
checking for strdup... (cached) yes
checking for getpid... yes
checking for kill... yes
checking for strtod... yes
checking for strtol... yes
checking for finite... yes
checking for fpclass... (cached) no
checking for sigsetjmp... no
checking whether sprintf is broken... no
checking for finite... (cached) yes
checking for isfinite... no
checking for isinf... (cached) yes
checking for isnan... (cached) yes
checking whether fp_except is defined... no
checking for dlfcn.h... (cached) yes
checking whether dlsym() requires a leading underscore in symbol names... no
checking virtual machine dispatch method... CALL
checking whether to enable thread-safety... no
checking whether to enable inline optimization for GCC... yes
checking whether to enable Zend debugging... no
checking for inline... inline
checking target system is Darwin... no
checking for MM alignment and log values... done
checking for memory allocation using mmap(MAP_ANON)... yes
checking for memory allocation using mmap("/dev/zero")... yes
checking for mremap... yes

Generated post-configued:

  • zend_config.h

configure.in

  • Zend/acinclude.m4 (Zend specific macro definitions)
  • PHP_CONFIG_NICE(config.nice) - ??
  • PHP_CANONICAL_HOST_TARGET
  • AC_CONFIG_HEADER(main/php_config.h)
  • PHP_MAJOR_VERSION=5
  • PHP_MINOR_VERSION=3
  • PHP_RELEASE_VERSION=0
  • PHP_EXTRA_VERSION=“-dev”
  • PHP_VERSION=“$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION”
  • PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`

Extension PHP Macros

  • PHP_ARG_WITH()
  • PHP_ARG_ENABLE()
  • PHP_ADD_INCLUDE()
  • PHP_CHECK_LIBRARY()
  • PHP_ADD_LIBRARY_WITH_PATH()
  • PHP_SUBST()
  • PHP_NEW_EXTENSION()
  • PHP_ADD_BUILD_DIR()
  • PHP_ADD_MAKEFILE_FRAGMENT()

acinclude.m4 Macros

Output stylize macros for configure (help/runtime)

  • PHP_HELP_SEPARATOR(title) - Adds separator title into the configure –help display.
  • PHP_CONFIGURE_PART(title) - Adds separator title configure output.

Build system helper macros

  • PHP_DEF_HAVE(what) - Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'.
  • PHP_RUN_ONCE(namespace, variable, code) - execute code, if variable is not set in namespace.
  • PHP_EXPAND_PATH(path, variable) - expands path to an absolute path and assigns it to variable.
  • PHP_DEFINE(WHAT [, value[, directory]]) - Creates builddir/include/what.h and in there #define WHAT value.
  • PHP_SUBST(varname) - Adds variable with it's value into Makefile, e.g.: CC = gcc
  • PHP_SUBST_OLD(varname) - Same as PHP_SUBST() but also substitutes all @VARNAME@ instances in every file passed to AC_OUTPUT()
  • PHP_OUTPUT(file) - Adds “file” to the list of files generated by AC_OUTPUT

Build system base macros

  • PHP_CANONICAL_HOST_TARGET
  • PHP_INIT_BUILD_SYSTEM
  • PHP_GEN_GLOBAL_MAKEFILE
  • PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]])
  • PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])

Compiler characteristics checks

  • PHP_TARGET_RDYNAMIC - Checks whether -rdynamic is supported by the compiler. This is necessary for some targets to populate the global symbol table. Otherwise, dynamic modules would not be able to resolve PHP-related symbols. If successful, adds -rdynamic to PHP_LDFLAGS.
  • PHP_RUNPATH_SWITCH - Checks for -R, etc. switch.
  • PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
  • PHP_LIBGCC_LIBPATH(gcc) - Stores the location of libgcc in libgcc_libpath

Macros to modify LIBS, INCLUDES, etc. variables

  • PHP_REMOVE_USR_LIB(NAME) - Removes all -L/usr/$PHP_LIBDIR entries from variable NAME
  • PHP_EVAL_LIBLINE(libline, SHARED-LIBADD) - Use this macro, if you need to add libraries and or library search paths to the PHP build system which are only given in compiler notation.
  • PHP_EVAL_INCLINE(headerline) - Use this macro, if you need to add header search paths to the PHP build system which are only given in compiler notation.
  • PHP_ADD_LIBPATH(path [, SHARED-LIBADD]) - Adds a path to linkpath/runpath (LDFLAGS)
  • PHP_UTILIZE_RPATHS() - builds RPATHS/LDFLAGS from PHP_RPATHS
  • PHP_ADD_INCLUDE(path [,before]) - add an include path. if before is 1, add in the beginning of INCLUDES.
  • PHP_ADD_LIBRARY(library[, append[, shared-libadd]]) - add a library to the link line
  • PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]]) - add a library to the link line (deferred, not used during configure)
  • PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd]) - add a library to the link line and path to linkpath/runpath.if shared-libadd is not empty and $ext_shared is yes,shared-libadd will be assigned the library information
  • PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd]) - add a library to the link line (deferred) and path to linkpath/runpath (not deferred) if shared-libadd is not empty and $ext_shared is yes,shared-libadd will be assigned the library information
  • PHP_ADD_FRAMEWORK(framework [,before]) - add a (Darwin / Mac OS X) framework to the link line. if before is 1, the framework is added to the beginning of the line.
  • PHP_ADD_FRAMEWORKPATH(path [,before]) - add a (Darwin / Mac OS X) framework path to the link and include lines. default paths include (but are not limited to) /Local/Library/Frameworks and /System/Library/Frameworks, so these don't need to be specifically added. if before is 1, the framework path is added to the beginning of the relevant lines.
  • PHP_ADD_FRAMEWORK_WITH_PATH(framework, path) - Adds a (Darwin / Mac OS X) framework path and the framework itself to the link and include lines.
  • PHP_SET_LIBTOOL_VARIABLE(var) - Set libtool variable.

Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE

  • PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]]) - Sets PHP_ARG_NAME either to the user value or to the default value. default-val defaults to no. This will also set the variable ext_shared,and will overwrite any previous variable of that name.If extension-or-not is yes (default), then do the ENABLE_ALL check and run the PHP_ARG_ANALYZE_EX.
  • PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]]) - Sets PHP_ARG_NAME either to the user value or to the default value. default-val defaults to no. This will also set the variable ext_shared, and will overwrite any previous variable of that name. If extension-or-not is yes (default), then do the ENABLE_ALL check and run the PHP_ARG_ANALYZE_EX.

Build macros

  • PHP_BUILD_THREAD_SAFE
  • PHP_REQUIRE_CXX
  • PHP_BUILD_SHARED
  • PHP_BUILD_STATIC
  • PHP_BUILD_BUNDLE
  • PHP_BUILD_PROGRAM
  • PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext) - Basically sets up the link-stage for building module-name from object_var in build-dir.
  • PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]]) - Selects the SAPI name and type (static, shared, programm) and optionally also the source-files for the SAPI-specific objects.
  • PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags[, cxx[, zend_ext]]]]]) - dnl Includes an extension in the build.

“extname” is the name of the ext/ subdir where the extension resides. “sources” is a list of files relative to the subdir which are used to build the extension. “shared” can be set to “shared” or “yes” to build the extension as a dynamically loadable library. Optional parameter “sapi_class” can be set to “cli” to mark extension build only with CLI or CGI sapi's. “extra-cflags” are passed to the compiler, with @ext_srcdir@ and @ext_builddir@ being substituted.

  • PHP_WITH_SHARED - Checks whether $withval is “shared” or starts with “shared,XXX” and sets $shared to “yes” or “no”, and removes “shared,?” stuff from $withval.
  • PHP_ADD_EXTENSION_DEP(extname, depends [, depconf]) - This macro is scanned by genif.sh when it builds the internal functions list, so that modules can be init'd in the correct order

$1 = name of extension, $2 = extension upon which it depends $3 = optional: if true, it's ok for $2 to have not been configured default is false and should halt the build.

Checks for structures, typedefs, broken functions, etc.

  • _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
  • PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
  • PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
  • PHP_CHECK_IN_ADDR_T
  • PHP_TIME_R_TYPE - Check type of reentrant time-related functions Type can be: irix, hpux or POSIX
  • PHP_PWRITE_TEST
  • PHP_PREAD_TEST
  • PHP_MISSING_TIME_R_DECL
  • PHP_READDIR_R_TYPE
  • PHP_TM_GMTOFF
  • PHP_STRUCT_FLOCK
  • PHP_SOCKLEN_T
  • PHP_MISSING_FCLOSE_DECL - See if we have broken header files like SunOS has.
  • PHP_AC_BROKEN_SPRINTF - Check for broken sprintf(), C99 conformance
  • PHP_AC_BROKEN_SNPRINTF - Check for broken snprintf(), C99 conformance
  • PHP_SOLARIS_PIC_WEIRDNESS - Solaris requires main code to be position independent in order to let shared objects find symbols. Weird. Ugly.

Must be run after all –with-NN options that let the user choose dynamic extensions, and after the gcc test.

  • PHP_SYS_LFS - dnl The problem is that the default compilation flags in Solaris 2.6 won't let programs access large files; you need to tell the compiler that you actually want your programs to work on large files. For more details about this brain damage please see: http://www.sas.com/standards/large.file/x_open.20Mar96.html
  • PHP_SOCKADDR_CHECKS
  • PHP_DECLARED_TIMEZONE
  • PHP_EBCDIC
  • PHP_BROKEN_GETCWD - Some systems, notably Solaris, cause getcwd() or realpath to fail if a component of the path has execute but not read permissions
  • PHP_BROKEN_GLIBC_FOPEN_APPEND
  • PHP_FOPENCOOKIE

Library/function existance and build sanity checks

  • PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]]) - Wrapper for AC_CHECK_LIB
  • PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]]) - El cheapo wrapper for AC_CHECK_LIB
  • PHP_CHECK_FUNC_LIB(func, libs) - This macro checks whether 'func' or 'func' exists in the specified library. Defines HAVE_func and HAVE_library if found and adds the library to LIBS. This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC * PHP_CHECK_FUNC(func, …) - This macro checks whether 'func' or 'func' exists in the default libraries and as a fall back in the specified library. Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  • PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]]) - This macro checks whether build works and given function exists.
internals/cmake/notes.txt · Last modified: 2011/04/06 12:59 (external edit)