{"id":14068185,"url":"https://github.com/kevinushey/configure","last_synced_at":"2025-04-12T21:09:16.929Z","repository":{"id":150772777,"uuid":"116407643","full_name":"kevinushey/configure","owner":"kevinushey","description":"Configure R packages for installation with R.","archived":false,"fork":false,"pushed_at":"2021-03-23T01:58:04.000Z","size":75,"stargazers_count":51,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T21:09:06.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinushey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-05T17:00:20.000Z","updated_at":"2025-03-22T12:47:39.000Z","dependencies_parsed_at":"2023-04-07T00:27:23.120Z","dependency_job_id":null,"html_url":"https://github.com/kevinushey/configure","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinushey%2Fconfigure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinushey%2Fconfigure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinushey%2Fconfigure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinushey%2Fconfigure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinushey","download_url":"https://codeload.github.com/kevinushey/configure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631676,"owners_count":21136562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:06:00.655Z","updated_at":"2025-04-12T21:09:16.910Z","avatar_url":"https://github.com/kevinushey.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# configure\n\nConfigure R packages for installation with R.\n\n## Motivation\n\nWriting portable package `configure` scripts is painful. It's even more painful\nbecause you often need to do it twice: once for Unix, and once for Windows (with\n`configure.win`). And the same tools you might use to generate a `configure`\nscript (say, [autoconf](https://www.gnu.org/software/autoconf/autoconf.html))\nmight not be available when you want to write `configure.win`. This package\nseeks to solve that problem by:\n\n- Allowing you to configure your R package directly with R; and\n- Providing a set of functions for accomplishing common configuration tasks.\n\n## Usage\n\nFirst, prepare your package by invoking:\n\n```r\nconfigure::use_configure()\n```\n\nThis will write out a few files to your package's directory.\n\n- configure\n- configure.win\n- cleanup\n- cleanup.win\n- tools/config.R\n\nThe `configure{.win}` and `cleanup{.win}` scripts invoke the `tools/config.R`\nscript. This script performs some automatic package configuration (described\nlater), and also sources a user-defined configure script at\n`tools/config/configure.R`, or a cleanup script at `tools/config/cleanup.R`.\n\nIt is not necessary for your package to import or explicitly depend on the\n`configure` package. The `use_configure()` function will copy all required files\ndirectly to `tools/config.R`, so in essence your package will embed all of\nthe functionality provided by `configure`.\n\n## Understanding configure and cleanup\n\nHere's a rough timeline of what happens when R attempts to install your package\nfrom a source tarball. When `R CMD INSTALL` is invoked (either directly by the\nuser, or perhaps from a helper function like `install.packages()` or one of\nthe `devtools::install_*()` functions), the following occurs:\n\n- If the `--preclean` option was supplied, the `cleanup{.win}` script will\n  be run. This is off by default.\n\n- Next, unless `--no-configure` was passed, the `configure{.win}` script is run,\n  to prepare the package for installation.\n\n- Finally, if installation was invoked with `--clean`, the `cleanup{.win}`\n  script will be run.\n  \nNote that the default behavior is _not_ to run `cleanup{.win}` during install\n(one must explicitly request it from R); however, CRAN compliance checks will\nstill ensure that you do clean up artefacts generated by `configure{.win}`. In\nother words, if you write a `configure{.win}` script, you almost certainly need\na `cleanup{.win}` script as well -- hence why this package generates both.\n \n### Configure\n\nThe main goal during the configure stage is to generate, or modify, files\nfor compilation or installation on the current platform. The primary mechanism\nthrough which this is accomplished is through translating `.in` files, with\nthe `configure_file()` helper function.\n\n```r\nconfigure_file(\"src/Makevars.in\")\n```\n\nThis will substitute variables of the form `@VAR@` with the associated\ndefinition discovered in the configuration database. By default, the\nconfiguration database is empty, but you can populate it using the\n`configure_define()` function. For example, you might use the following\nto define the value for a variable called `STDVER`:\n\n```r\ndefine(STDVER = \"c++11\")\n```\n\nIf you want to read R's configuration -- for example, to discover what C\ncompiler should be used for compilation -- you can use the `read_r_config()`\nfunction:\n\n```r\nread_r_config(\"CC\", \"CXX\")\n```\n\nThe configuration database will automatically be populated with the values\nrequested by R for `CC` and `CXX` in this case.\n\n## Cleanup\n\nThe cleanup stage's primary purpose is to remove files created during the\nconfigure stage. For example, we might want to remove the generated\nMakevars files generated earlier:\n\n```r\nunlink(\"src/Makevars\")\n```\n\n## Automatic Configuration\n\nThe `configure` package tries to perform some of the most common configuration\nand cleanup steps automatically, to avoid overburdening the user when possible.\nIn particular, all `.in` files discovered within the package top-level\ndirectory, `R/`, and `src/` folders are automatically configured and cleaned up\nas required. This implies that, in many cases, it should be sufficient for a\nuser to write a `configure.R` script whose only purpose is to define\nconfiguration variables.\n\nAs an example, the `configure` package uses itself to manage configuration.\nThe file\n[R/zzz.R.in](https://github.com/kevinushey/configure/blob/master/R/zzz.R.in)\ncontains the single line:\n\n```r\n.PACKAGE \u003c- \"@PACKAGE_NAME@\"\n```\n\nAnd the file at\n[tools/config/configure.R](https://github.com/kevinushey/configure/blob/master/tools/config/configure.R)\ncontains only:\n\n```r\ndefine(PACKAGE_NAME = \"configure\")\n```\n\nand the existing machinery automatically generates and cleans up `zzz.R`\nas appropriate.\n\n## Licensing\n\nThese components are licensed to you under the\n[MIT license](https://opensource.org/licenses/MIT), which should be compatible\nwith all other major open-source licenses. However, if you prefer, you are free\nto instead re-license these components using the same open-source license you're\nreleasing your R package under, as long as that license is a\n[CRAN-compatible](https://cran.rstudio.com/web/licenses/) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinushey%2Fconfigure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinushey%2Fconfigure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinushey%2Fconfigure/lists"}