diff options
Diffstat (limited to 'rules/CC/foreign/make')
-rw-r--r-- | rules/CC/foreign/make/EXPRESSIONS | 130 | ||||
-rw-r--r-- | rules/CC/foreign/make/RULES | 154 |
2 files changed, 104 insertions, 180 deletions
diff --git a/rules/CC/foreign/make/EXPRESSIONS b/rules/CC/foreign/make/EXPRESSIONS index 7d733a6..ba98154 100644 --- a/rules/CC/foreign/make/EXPRESSIONS +++ b/rules/CC/foreign/make/EXPRESSIONS @@ -2,6 +2,7 @@ { "vars": [ "source_dir" , "subdir" + , "localbase_dir" , "configure" , "configure_options" , "make_targets" @@ -10,14 +11,6 @@ , "make_jobs" , "pre_cmds" , "post_cmds" - , "var_cc" - , "var_cxx" - , "var_ccflags" - , "var_cxxflags" - , "var_ldflags" - , "var_ar" - , "var_prefix" - , "var_destdir" , "CC" , "CXX" , "CFLAGS" @@ -31,6 +24,8 @@ , "PREFIX" , "BUILD_POSITION_INDEPENDENT" , "TIMEOUT_SCALE" + , "defaults-transition" + , "host-defaults-transition" ] , "imports": { "artifacts": ["", "field_artifacts"] @@ -43,11 +38,22 @@ , "default-ENV": ["CC", "default-ENV"] , "default-TOOLCHAIN": ["CC", "default-TOOLCHAIN"] , "default-NON_SYSTEM_TOOLS": ["CC", "default-NON_SYSTEM_TOOLS"] + , "expand_exec_tool": ["./", "..", "expand_exec_tool"] } , "expression": { "type": "let*" , "bindings": - [ ["TOOLCHAIN_DIR", "toolchain"] + [ [ "expand_exec" + , { "type": "let*" + , "bindings": + [ [ "defaults-transition" + , {"type": "var", "name": "host-defaults-transition"} + ] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "expand_exec_tool"} + } + ] + , ["TOOLCHAIN_DIR", "toolchain"] , ["TOOLCHAIN", {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}] , [ "TOOLCHAIN" , { "type": "to_subdir" @@ -131,81 +137,9 @@ , "$1": [ {"type": "CALL_EXPRESSION", "name": "default-ENV"} , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}} - , { "type": "singleton_map" - , "key": - { "type": "if" - , "cond": {"type": "var", "name": "var_cc"} - , "then": - {"type": "join", "$1": {"type": "var", "name": "var_cc"}} - , "else": "CC" - } - , "value": {"type": "var", "name": "CC"} - } - , { "type": "singleton_map" - , "key": - { "type": "if" - , "cond": {"type": "var", "name": "var_cxx"} - , "then": - {"type": "join", "$1": {"type": "var", "name": "var_cxx"}} - , "else": "CXX" - } - , "value": {"type": "var", "name": "CXX"} - } - , { "type": "singleton_map" - , "key": - { "type": "if" - , "cond": {"type": "var", "name": "var_ccflags"} - , "then": - { "type": "join" - , "$1": {"type": "var", "name": "var_ccflags"} - } - , "else": "CFLAGS" - } - , "value": {"type": "var", "name": "CFLAGS"} - } - , { "type": "singleton_map" - , "key": - { "type": "if" - , "cond": {"type": "var", "name": "var_cxxflags"} - , "then": - { "type": "join" - , "$1": {"type": "var", "name": "var_cxxflags"} - } - , "else": "CXXFLAGS" - } - , "value": {"type": "var", "name": "CXXFLAGS"} - } - , { "type": "singleton_map" - , "key": - { "type": "if" - , "cond": {"type": "var", "name": "var_ldflags"} - , "then": - { "type": "join" - , "$1": {"type": "var", "name": "var_ldflags"} - } - , "else": "LDFLAGS" - } - , "value": {"type": "var", "name": "LDFLAGS"} - } - , { "type": "singleton_map" - , "key": - { "type": "if" - , "cond": {"type": "var", "name": "var_ar"} - , "then": - {"type": "join", "$1": {"type": "var", "name": "var_ar"}} - , "else": "AR" - } - , "value": {"type": "var", "name": "AR"} - } - , { "type": "singleton_map" - , "key": - { "type": "if" - , "cond": {"type": "var", "name": "var_prefix"} - , "then": - {"type": "join", "$1": {"type": "var", "name": "var_prefix"}} - , "else": "PREFIX" - } - , "value": {"type": "var", "name": "PREFIX"} + , { "type": "env" + , "vars": + ["CC", "CXX", "CFLAGS", "CXXFLAGS", "LDFLAGS", "AR", "PREFIX"] } ] } @@ -251,7 +185,10 @@ , "$1": [ [ "set -eu" , "mkdir scratch" - , "readonly TMPDIR=\"$(pwd)/scratch\"" + , "readonly ROOT=\"$(pwd)\"" + , "export TMPDIR=\"$(pwd)/scratch\"" + , "export DESTDIR=\"$(pwd)/install\"" + , "export LOCALBASE=\"$(pwd)/localbase\"" ] , { "type": "if" , "cond": {"type": "var", "name": "pre_cmds"} @@ -264,18 +201,14 @@ ] } } - , [ "readonly SUBDIR=\"$1\"" - , "readonly VAR_DESTDIR=$2" - , "shift 2" - ] + , ["readonly SUBDIR=\"$1\"", "shift"] , { "type": "if" , "cond": {"type": "var", "name": "configure_args"} , "then": - [ "( readonly ROOT=\"$(pwd)\"" - , " cd \"source/${SUBDIR}\"" + [ "( cd \"source/${SUBDIR}\"" , { "type": "join" , "$1": - [ "./configure " + [ "${ROOT}/expand_exec TMPDIR DESTDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR PREFIX -- ./configure " , { "type": "join_cmd" , "$1": {"type": "var", "name": "configure_args"} } @@ -291,7 +224,7 @@ , "body": { "type": "join" , "$1": - [ "make \"$@\" -C \"source/${SUBDIR}\" ${VAR_DESTDIR}=$(pwd)/install " + [ "${ROOT}/expand_exec TMPDIR DESTDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR PREFIX -- make DESTDIR=${DESTDIR} -C \"source/${SUBDIR}\" \"$@\" " , { "type": "join_cmd" , "$1": [{"type": "var", "name": "target"}] } @@ -325,6 +258,11 @@ , "$1": [ {"type": "var", "name": "TOOLCHAIN"} , {"type": "var", "name": "source_dir"} + , {"type": "var", "name": "expand_exec"} + , { "type": "var" + , "name": "localbase_dir" + , "default": {"type": "empty_map"} + } , {"type": "var", "name": "script"} ] } @@ -333,12 +271,6 @@ , "$1": [ ["/bin/sh", "run_make.sh"] , [{"type": "var", "name": "SUBDIR"}] - , { "type": "if" - , "cond": {"type": "var", "name": "var_destdir"} - , "then": - [{"type": "join", "$1": {"type": "var", "name": "var_destdir"}}] - , "else": ["DESTDIR"] - } , {"type": "var", "name": "make_options"} , { "type": "if" , "cond": {"type": "var", "name": "make_jobs"} diff --git a/rules/CC/foreign/make/RULES b/rules/CC/foreign/make/RULES index 992ec2a..79e6b2b 100644 --- a/rules/CC/foreign/make/RULES +++ b/rules/CC/foreign/make/RULES @@ -1,5 +1,12 @@ { "data": - { "doc": ["Data produced by Configure and Make build and install."] + { "doc": + [ "Data produced by Configure and Make build and install." + , "" + , "All variables accessible to commands and options are: \"TMPDIR\"," + , "\"LOCALBASE\", \"CC\", \"CXX\", \"CFLAGS\", \"CXXFLAGS\", \"LDFLAGS\"," + , "\"AR\", and \"PREFIX\". \"LOCALBASE\" contains the path to the" + , "installed artifacts from \"deps\"." + ] , "target_fields": ["project"] , "string_fields": [ "subdir" @@ -13,17 +20,11 @@ , "post_cmds" , "out_files" , "out_dirs" - , "var_cc" - , "var_cxx" - , "var_ccflags" - , "var_cxxflags" - , "var_ldflags" - , "var_ar" - , "var_prefix" - , "var_destdir" ] , "config_vars": - [ "CC" + [ "ARCH" + , "HOST_ARCH" + , "CC" , "CXX" , "CFLAGS" , "CXXFLAGS" @@ -47,7 +48,10 @@ ] , "configure": ["Run ./configure if non-empty."] , "configure_options": - ["The configure options (the \"--prefix\" option is automatically set."] + [ "The configure options (the \"--prefix\" option is automatically set." + , "Variables can be accessed via \"$(<varname>)\", e.g., \"$(TMPDIR)\"" + , "for variable \"$TMPDIR\"." + ] , "targets": [ "The Make targets to build in the specified order" , "(default: [\"install\"])." @@ -59,8 +63,10 @@ , "taken, with the default value being \"/\"." ] , "options": - [ "Make options for the configuration phase." - , "(e.g., [\"-f\", \"Makefile\", \"ARCH=x86\"])" + [ "Make options for the configuration phase" + , "(e.g., [\"-f\", \"Makefile\", \"ARCH=x86\", \"LD=$(CC)\"]). Variables" + , "can be accessed via \"$(<varname>)\", e.g., \"$(TMPDIR)\" for" + , "variable \"$TMPDIR\"." ] , "jobs": [ "Number of jobs to run simultaneously. If omitted, Make's default" @@ -68,16 +74,16 @@ ] , "pre_cmds": [ "List of commands executed in the project directory before calling" - , "Make. Useful for renaming files or directories. Note that data" - , "between \"pre_cmds\" and \"post_cmds\" can be exchanged via $TMPDIR," - , "which is uniquely reserved for this action." + , "Configure or Make. Useful for renaming files or directories. Note" + , "that data between \"pre_cmds\" and \"post_cmds\" can be exchanged via" + , "\"$TMPDIR\", which is uniquely reserved for this action." ] , "post_cmds": [ "List of commands executed in the install directory after successful" , "installation but before the output files are collected. Useful for" , "renaming files or directories. Note that data between \"pre_cmds\" and" - , "\"post_cmds\" can be exchanged via $TMPDIR, which is uniquely reserved" - , "for this action." + , "\"post_cmds\" can be exchanged via \"$TMPDIR\", which is uniquely" + , "reserved for this action." ] , "out_files": [ "Paths to the produced output files. The paths are considered relative" @@ -89,22 +95,6 @@ , "relative to the install directory." , "Note that \"out_files\" and \"out_dirs\" may not overlap." ] - , "var_cc": - ["Variable name used to specify the C compiler (default: \"CC\")."] - , "var_cxx": - ["Variable name used to specify the C++ compiler (default: \"CXX\")."] - , "var_ccflags": - ["Variable name used to specify the C flags (default: \"CFLAGS\")."] - , "var_cxxflags": - ["Variable name used to specify the C++ flags (default: \"CXXFLAGS\")."] - , "var_ldflags": - ["Variable name used to specify the link flags (default: \"LDFLAGS\")."] - , "var_ar": - ["Variable name used to specify the archiver (default: \"AR\")."] - , "var_prefix": - ["Variable name used to specify the prefix (default: \"PREFIX\")."] - , "var_destdir": - ["Variable name used to specify the destdir (default: \"DESTDIR\")."] } , "config_doc": { "CC": @@ -174,6 +164,11 @@ { "stage_field": ["", "stage_singleton_field"] , "make-build": "make-build" , "strip-prefix": ["./", "..", "strip-prefix"] + , "for host": ["transitions", "for host"] + } + , "config_transitions": + { "defaults": + [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}] } , "expression": { "type": "let*" @@ -222,14 +217,10 @@ , ["make_jobs", {"type": "FIELD", "name": "jobs"}] , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] - , ["var_cc", {"type": "FIELD", "name": "var_cc"}] - , ["var_cxx", {"type": "FIELD", "name": "var_cxx"}] - , ["var_ccflags", {"type": "FIELD", "name": "var_ccflags"}] - , ["var_cxxflags", {"type": "FIELD", "name": "var_cxxflags"}] - , ["var_ldflags", {"type": "FIELD", "name": "var_ldflags"}] - , ["var_ar", {"type": "FIELD", "name": "var_ar"}] - , ["var_prefix", {"type": "FIELD", "name": "var_prefix"}] - , ["var_destdir", {"type": "FIELD", "name": "var_destdir"}] + , ["defaults-transition", {"type": "empty_map"}] + , [ "host-defaults-transition" + , {"type": "CALL_EXPRESSION", "name": "for host"} + ] , ["full_install_dir", {"type": "CALL_EXPRESSION", "name": "make-build"}] , [ "install_dir" , { "type": "ACTION" @@ -276,7 +267,14 @@ } } , "library": - { "doc": ["Library produced by Configure and Make build and install."] + { "doc": + [ "Library produced by Configure and Make build and install." + , "" + , "All variables accessible to commands and options are: \"TMPDIR\"," + , "\"LOCALBASE\", \"CC\", \"CXX\", \"CFLAGS\", \"CXXFLAGS\", \"LDFLAGS\"," + , "\"AR\", and \"PREFIX\". \"LOCALBASE\" contains the path to the" + , "installed artifacts from \"deps\"." + ] , "target_fields": ["project", "deps"] , "string_fields": [ "subdir" @@ -300,17 +298,11 @@ , "hdr_prefix" , "lib_prefix" , "pc_prefix" - , "var_cc" - , "var_cxx" - , "var_ccflags" - , "var_cxxflags" - , "var_ldflags" - , "var_ar" - , "var_prefix" - , "var_destdir" ] , "config_vars": - [ "CC" + [ "ARCH" + , "HOST_ARCH" + , "CC" , "CXX" , "CFLAGS" , "CXXFLAGS" @@ -357,7 +349,7 @@ , "taken, with the default value being \"/\"." ] , "options": - [ "Make options for the configuration phase." + [ "Make options for the build phase." , "(e.g., [\"-f\", \"Makefile\", \"ARCH=x86\"])" ] , "jobs": @@ -366,16 +358,16 @@ ] , "pre_cmds": [ "List of commands executed in the project directory before calling" - , "Make. Useful for renaming files or directories. Note that data" - , "between \"pre_cmds\" and \"post_cmds\" can be exchanged via $TMPDIR," - , "which is uniquely reserved for this action." + , "Configure or Make. Useful for renaming files or directories. Note" + , "that data between \"pre_cmds\" and \"post_cmds\" can be exchanged via" + , "\"$TMPDIR\", which is uniquely reserved for this action." ] , "post_cmds": [ "List of commands executed in the install directory after successful" , "installation but before the output files are collected. Useful for" , "renaming files or directories (e.g., in case of SONAME mismatch). Note" , "that data between \"pre_cmds\" and \"post_cmds\" can be exchanged via" - , "$TMPDIR, which is uniquely reserved for this action." + , "\"$TMPDIR\", which is uniquely reserved for this action." ] , "out_hdrs": [ "Paths to produced public header files. The path is considered" @@ -424,22 +416,6 @@ , "directory components are joined with \"/\". Defaults to" , "\"lib/pkgconfig\" if not set." ] - , "var_cc": - ["Variable name used to specify the C compiler (default: \"CC\")."] - , "var_cxx": - ["Variable name used to specify the C++ compiler (default: \"CXX\")."] - , "var_ccflags": - ["Variable name used to specify the C flags (default: \"CFLAGS\")."] - , "var_cxxflags": - ["Variable name used to specify the C++ flags (default: \"CXXFLAGS\")."] - , "var_ldflags": - ["Variable name used to specify the link flags (default: \"LDFLAGS\")."] - , "var_ar": - ["Variable name used to specify the archiver (default: \"AR\")."] - , "var_prefix": - ["Variable name used to specify the prefix (default: \"PREFIX\")."] - , "var_destdir": - ["Variable name used to specify the destdir (default: \"DESTDIR\")."] } , "config_doc": { "CC": @@ -506,6 +482,12 @@ , "make-build": "make-build" , "strip-prefix": ["./", "..", "strip-prefix"] , "prebuilt result": ["CC/prebuilt", "prebuilt result"] + , "install-deps": ["CC", "install-with-deps stage"] + , "for host": ["transitions", "for host"] + } + , "config_transitions": + { "defaults": + [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}] } , "expression": { "type": "let*" @@ -564,6 +546,20 @@ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} } ] + , [ "localbase_dir" + , { "type": "to_subdir" + , "subdir": "localbase" + , "msg": "dependency installation files may not overlap" + , "$1": + { "type": "let*" + , "bindings": + [ ["pc-install-dir", "lib/pkgconfig"] + , ["targets", {"type": "FIELD", "name": "deps"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "install-deps"} + } + } + ] , [ "installed_dirs" , { "type": "foreach" , "var": "dir_path" @@ -629,14 +625,10 @@ , ["make_jobs", {"type": "FIELD", "name": "jobs"}] , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] - , ["var_cc", {"type": "FIELD", "name": "var_cc"}] - , ["var_cxx", {"type": "FIELD", "name": "var_cxx"}] - , ["var_ccflags", {"type": "FIELD", "name": "var_ccflags"}] - , ["var_cxxflags", {"type": "FIELD", "name": "var_cxxflags"}] - , ["var_ldflags", {"type": "FIELD", "name": "var_ldflags"}] - , ["var_ar", {"type": "FIELD", "name": "var_ar"}] - , ["var_prefix", {"type": "FIELD", "name": "var_prefix"}] - , ["var_destdir", {"type": "FIELD", "name": "var_destdir"}] + , ["defaults-transition", {"type": "empty_map"}] + , [ "host-defaults-transition" + , {"type": "CALL_EXPRESSION", "name": "for host"} + ] , ["full_install_dir", {"type": "CALL_EXPRESSION", "name": "make-build"}] , [ "install_dir" , { "type": "ACTION" |