├── 0_0_COVER.md ├── 1_0_INTRO.md ├── 2_0_MAKEFILE.md ├── 2_1_0_VARIABLES.md ├── 2_1_1_0_MASTER_VARIABLES.md ├── 2_1_1_1_PATHS.md ├── 2_1_1_2_COMPILATION_LINKING.md ├── 2_1_1_3_STRIPPING_CODESIGNING.md ├── 2_1_1_4_0_SCHEMATA.md ├── 2_1_1_4_1_DEFAULT_SCHEMATA.md ├── 2_1_1_5_0_TARGET.md ├── 2_1_1_5_1_DEFAULT_TARGETS.md ├── 2_1_1_5_2_DEFAULT_PLATFORMS.md ├── 2_1_1_5_3_DEFAULT_COMMON_TARGETS.md ├── 2_1_1_6_INSTANCES.md ├── 2_1_2_INSTANCES.md ├── Markdown.pl ├── README ├── RefMarkup.pl ├── core.css ├── genhtml.sh ├── theosref.css └── theosref_legacy.md /0_0_COVER.md: -------------------------------------------------------------------------------- 1 | ============================= BACON PUBLISHING LLC ============================= 2 | 3 | # The Theos Documentation 4 | 5 | VERSION 1. 6 | 7 | As written by **Daniel Ferreira (theiostream)**. 8 | 9 | This document would not have been possible without the following people: 10 | 11 | * Dustin Howett -> Theos, #theos, always commenting on obscure features. 12 | * Jay Freeman -> irc.saurik.com 13 | * Max Shavrick -> Teaching me of Theos' existence. 14 | 15 | Source Material: 16 | 17 | * The Make Manual, by the GNU Project 18 | * "Chapter 1. Makefiles", by Dustin Howett 19 | 20 | ============================= BACON PUBLISHING LLC ============================= 21 | -------------------------------------------------------------------------------- /1_0_INTRO.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | %INDENT% 4 | 5 | **Theos** (formerly iphone-framework) is a set of Makefiles designed to take away the complexity of building and organizing iPhoneOS projects without the use of Xcode (or even Mac OS X). 6 | 7 | Theos is developed mainly by Dustin Howett (DHowett) and available via [**Git**](http://github.com/DHowett/theos/) and [Subversion](http://svn.howett.net/svn/theos/). 8 | 9 | Theos features a robust build system driven by [**GNU Make**](http://www.gnu.org/software/make/), which makes its Makefiles easily-read, concise, and extensible. 10 | 11 | Getting started is as simple as `git clone git://github.com/DHowett/theos`: Theos's installation is designed to be easy and portable. One of Theos' principles was to never require any bootstrapping. 12 | 13 | Theos also features a set of other components such as [**Logos**](http://iphonedevwiki.net/index.php/Logos) and [**NIC**](http://theos.howett.net/nic), which are documented elsewhere. This document will focus on Theos' Makefile system. 14 | 15 | %INDENTEND% 16 | 17 | ## Conceptual Notes 18 | 19 | %INDENT% 20 | 21 | A **project** refers to a directory hierarchy containing a Theos Makefile, related files and subprojects. 22 | 23 | Theos Makefiles are written in *make* (specifically, *GNU make*). As such, all Make syntax is valid, including rules, variable definitions, and so forth. Theos provides built-in variables and rules (herein documented), but can be side-stepped and expanded wherever necessary. 24 | 25 | For a (very) in-depth reference on Make, check the [GNU `make' manual](http://www.gnu.org/software/make/manual/make.html). 26 | 27 | %INDENTEND% 28 | -------------------------------------------------------------------------------- /2_0_MAKEFILE.md: -------------------------------------------------------------------------------- 1 | # Makefiles 2 | 3 | Theos is, simply put, a **set of makefiles** initially designed to allow development for the iPhone, but had evolved into a powerful generic system, useful for any case where a normal Makefile would be used. 4 | 5 | Theos' variables and rules will be documented in the following sections: 6 | 7 | * Variables 8 | * Master Variables 9 | * Theos Path Variables 10 | * Compilation/Linking Variables 11 | * Stripping/Signing Variables 12 | * Schemas 13 | * Theos Schemas 14 | * Targets 15 | * Theos Targets 16 | * Theos Platforms 17 | * Theos Common Targets 18 | * Instance Specifiers 19 | * Other 20 | 21 | * Instance Variables 22 | * Instances 23 | * Instance Variables 24 | * Bundles 25 | * Applications 26 | * Frameworks 27 | * Libraries 28 | * Tweaks 29 | * Tools 30 | 31 | * Rules 32 | * Invokable 33 | * Implementable 34 | 35 | * Modules 36 | -------------------------------------------------------------------------------- /2_1_0_VARIABLES.md: -------------------------------------------------------------------------------- 1 | # Variables 2 | 3 | %INDENT% 4 | 5 | Theos provides variables that can be modified to control the build process on a global and per-[instance](./2_1_2_INSTANCES.md) basis. 6 | 7 | For general information on *make Variables*, refer to [*Using Variables*](http://www.gnu.org/software/make/manual/make.html#Using-Variables) in the GNU make Manual. 8 | 9 | %INDENTEND% 10 | 11 | ## Variable Types and Scope 12 | 13 | %INDENT% 14 | 15 | * **Constants (%R%)**: Variables whose values should not be changed. They are used for querying the build environment and theos settings. They are valid across all Theos Makefiles. 16 | 17 | * **System Variables (%S%)**: Variables that can be set to modify global state for all instances and sub-instances under a given Makefile. Variables of this sort are shared between make and sub-make instances. 18 | 19 | * **Command-line Variables (%C%)**: Variables specifically designed to be set during a command-line invocation of `make`. These variables also modify state for all instances and sub-instances under a given Makefile. 20 | 21 | * **Local Variables (%L%)**: Variables whose value is valid only on the Make instance where they are defined. 22 | 23 | * **Private Variables**: Undocumented variables which are either deprecated or aren't meant to be used. 24 | 25 | For more detail on the scoping of make variables, refer to [*Recursive Use of Make*](http://www.gnu.org/software/make/manual/make.html#Recursion) in the GNU make Manual. 26 | 27 | A Theos convention holds that, save `THEOS_`-prepended variables, lowercase variable names are to be used as Command-Line Variables and uppercase ones to be defined in Makefiles. This will be discussed further on a per-variable basis. 28 | 29 | This section of the documentation is split into two main parts: **Master Variables** (which specify global build settings) and **Instance Variables** (which specify instance-specific build settings). For more details on instances, refer to [Section 2.1.2](./2_1_2_INSTANCES.md). 30 | 31 | %INDENTEND% 32 | -------------------------------------------------------------------------------- /2_1_1_0_MASTER_VARIABLES.md: -------------------------------------------------------------------------------- 1 | # Master Variables 2 | 3 | Master Variables are make variables used to control the build process globally and to specify instances. -------------------------------------------------------------------------------- /2_1_1_1_PATHS.md: -------------------------------------------------------------------------------- 1 | # Path Variables 2 | 3 | The variables in this section pertain to: 4 | 5 | * Querying where Theos stores certain resource files which may need to be referenced. 6 | * Designating directories wherein Theos should store build-related output files. 7 | 8 | ## Theos Resource Locations 9 | 10 | %INDENT% 11 | 12 | ###### THEOS %R% 13 | The path to Theos. 14 | 15 | Defined in *common.mk*. 16 | 17 | ###### THEOS\_MAKE_PATH %R% 18 | The path where Theos' Makefiles are located. 19 | Save `common.mk`, Theos Makefile inclusions should be based on this variable. 20 | 21 | Defined in *common.mk*. 22 | 23 | ###### THEOS\_BIN_PATH %R% 24 | The path where Theos stores its binaries. 25 | Install, query and bootstrap scripts, Logos, NIC, and others are stored here. 26 | 27 | Defined in *common.mk*. 28 | 29 | ###### THEOS\_LIBRARY_PATH %R% 30 | The path where linkable libraries are kept. 31 | This directory is added to the linker's *library search path* for each built instance. 32 | 33 | Defined in *common.mk*. 34 | 35 | ###### THEOS\_INCLUDE_PATH %R% 36 | The path where headers meant for use in Theos projects are stored. 37 | This directory is added to the compiler's *include path* for each built object. 38 | 39 | Defined in *common.mk*. 40 | 41 | ###### THEOS\_MODULE_PATH %R% 42 | The path where [Theos Modules](./6_0_MODULES.md) are stored. 43 | 44 | Defined in *common.mk*. 45 | 46 | %INDENTEND% 47 | 48 | ## Project Build Locations 49 | 50 | %INDENT% 51 | 52 | ###### THEOS\_BUILD\_DIR %S% 53 | The directory which houses a project's object directory, staging directory and built packages. 54 | 55 | Defaults to the project's root directory. 56 | Defined in *common.mk*. 57 | 58 | 59 | ###### THEOS\_OBJ\_DIR\_NAME %S% 60 | The name of the directory which houses a project's built object files and main executable. 61 | 62 | Defaults to "obj". 63 | Defined in *common.mk*. 64 | 65 | ###### THEOS\_STAGING\_DIR %S% 66 | The name of the project's [staging](./4_1_INVOKABLE.md#package) directory. 67 | 68 | Defaults to "\_". 69 | Defined in *common.mk*. 70 | 71 | %INDENTEND% 72 | -------------------------------------------------------------------------------- /2_1_1_2_COMPILATION_LINKING.md: -------------------------------------------------------------------------------- 1 | # Compilation/Linking Variables 2 | 3 | The variables in this section pertain to: 4 | 5 | * Compilation 6 | * Linking 7 | 8 | ## Tool Specification 9 | 10 | %INDENT% 11 | 12 | (Organization note: SCHEMA is not here, so should TARGET be, since it doesn't specify any tool directly? It seems right, but doesn't quite make sense if analyzed so) 13 | 14 | ###### TARGET %S% 15 | The system for which Theos is to build projects. Also defines miscellaneous build aspects. 16 | Refer to [TARGET flags](./3_1_5_TARGET.md#TARGET) for more information. 17 | 18 | Defaults and availability are platform-wise. 19 | 20 | ###### TARGET\_CC %R% 21 | Specifies the path to the C compiler. 22 | It is used during compilation of C and Objective-C files. 23 | 24 | Defaults and definition on a per-target basis. 25 | 26 | ###### TARGET\_CXX %R% 27 | Specifies the path to the C++ compiler. 28 | It is used during compilation of C++ and Objective-C++ files. 29 | 30 | Defaults and definition on a per-target basis. 31 | 32 | ###### TARGET\_LD %R% 33 | Specifies the path to the linker. 34 | It is used during linkage of object files. 35 | 36 | Defaults and definition on a per-target basis. 37 | 38 | %INDENTEND% 39 | 40 | ## Flag Specification 41 | 42 | %INDENT% 43 | 44 | ###### ADDITIONAL\_CFLAGS %L% 45 | Specifies additional flags to be passed into the C and C++ compiler upon compilation. 46 | It is used during compilation of C, Objective-C, C++ and Objective-C++ files. 47 | 48 | Defaults to empty. 49 | Defined in `common.mk`. 50 | 51 | ###### ADDITIONAL\_CCFLAGS %L% 52 | Specifies additional flags to be passed into the C++ compiler upon compilation. 53 | It is used during compilation of C++ and Objective-C++ files. 54 | 55 | Defaults to empty. 56 | Defined in `common.mk`. 57 | 58 | ###### ADDITIONAL\_OBJCFLAGS %L% 59 | Specifies additional flags to be passed into the Objective-C compiler upon compilation. 60 | It is used during compilation of Objective-C and Objective-C++ files. 61 | 62 | Defaults to empty. 63 | Defined in `common.mk`. 64 | 65 | ###### ADDITIONAL\_OBJCCFLAGS %L% 66 | Specifies additional flags to be passed into the Objective-C++ compiler upon compilation. 67 | It is used during compilation of Objective-C++ files. 68 | 69 | Defaults to empty. 70 | Defined in `common.mk`. 71 | 72 | ###### ADDITIONAL\_LDFLAGS %L% 73 | Specifies additional flags to be passed into the linker. 74 | It is used during linking of object files. 75 | 76 | Defaults to empty. 77 | Defined in `common.mk`. 78 | 79 | ###### ADDITIONAL\_LOGOSFLAGS %L% 80 | Specifies additional flags to be passed into the [Logos Preprocessor](http://theiostream.com/logos). 81 | It is used during preprocessing of Logos files. 82 | 83 | ###### OPTFLAG %L% 84 | Specifies the compiler optimization flag. 85 | 86 | Defaults to `-O2`. 87 | Defined in `common.mk`. 88 | 89 | %INDENTEND% 90 | 91 | ## Miscellaneous 92 | 93 | %INDENT% 94 | 95 | ###### DEBUG %D% 96 | Controls compilation of debug symbols and stripping. 97 | Being used, adds `-ggdb -DDEBUG` to the compiler flags and disables optimization and stripping. `+debug` is also added to the package build identifier. 98 | 99 | Use [`debug` SCHEMA](./2_1_1_4_1_DEFAULT_SCHEMATA.md#debug) instead. 100 | This was written during a Skype conversation with females. 101 | 102 | Defaults to `false`. 103 | Defined in `common.mk`. 104 | 105 | %INDENTEND% 106 | -------------------------------------------------------------------------------- /2_1_1_3_STRIPPING_CODESIGNING.md: -------------------------------------------------------------------------------- 1 | # Stripping/Codesigning Variables 2 | 3 | The variables in this section pertain to: 4 | 5 | * Stripping 6 | * Codesigning 7 | 8 | ## Tool Specification 9 | 10 | %INDENT% 11 | 12 | ###### TARGET %S% 13 | The system for which Theos is to build projects. Also defines miscellaneous build aspects. 14 | Refer to [TARGET flags](./3_1_5_TARGET.md#TARGET) for more information. 15 | 16 | Defaults and availability are platform-wise. 17 | 18 | ###### TARGET\_STRIP %R% 19 | Specifies the path to the `strip` tool. 20 | It is used during executable binary stripping. 21 | 22 | Defaults and definition on a per-target basis. 23 | 24 | ###### TARGET\_CODESIGN %R% 25 | Specifies the path of the codesigning tool. 26 | It is used during codesigning. 27 | 28 | Usually, `ldid`, rather than `codesign`, is used for signing. 29 | 30 | Defaults and definition on a per-target basis. 31 | 32 | %INDENTEND% 33 | 34 | ## Flag Specification 35 | 36 | %INDENT% 37 | 38 | ###### TARGET\_STRIP\_FLAGS %S% 39 | Specifies flags to be passed into `strip` upon stripping. 40 | This variable is an exception to the convention that `TARGET_` variables are meant to be read-only and set only on a per-target basis. 41 | 42 | Defaults and definition on a per-target basis. 43 | 44 | ###### TARGET\_CODESIGN\_FLAGS 45 | Specifies flags to be passed into the codesigning tool upon codesigning. 46 | This variable is an exception to the convention that `TARGET_` variables are meant to be read-only and set only on a per-target basis. 47 | 48 | Defaults and definition on a per-target basis. 49 | 50 | %INDENTEND% 51 | -------------------------------------------------------------------------------- /2_1_1_4_0_SCHEMATA.md: -------------------------------------------------------------------------------- 1 | # Schemas ("Schemata") 2 | 3 | This section pertains to: 4 | 5 | * The creation and use of Theos schemas ("Schemata") 6 | 7 | ## Concept 8 | 9 | %INDENT% 10 | 11 | Schemas are a way to manage a group of [specific master variables](./2_1_1_4_SCHEMATA.md#affected-variables) which can have their effect easily turned off or on. 12 | 13 | An example is the built-in `debug` schema, which when enabled adds extra options to CFLAGS. 14 | 15 | %INDENTEND% 16 | 17 | ## Enabling 18 | 19 | %INDENT% 20 | 21 | ###### SCHEMA 22 | Specifies enabled schemas. 23 | 24 | Schemas are enabled by their names separated by spaces. 25 | 26 | Example: 27 | 28 | %CODE% 29 | 30 | \# enable schemas "schema1" and "schema2" 31 |
32 | SCHEMA = schema1 schema2 33 | 34 | %CODEEND% 35 | 36 | Defaults to empty. 37 | Defined in `common.mk`. 38 | 39 | %INDENTEND% 40 | 41 | ## Describing the Schema 42 | 43 | %INDENT% 44 | 45 | The schema is described by specifying what variables have their values affected by its enabling. Doing so can be done by declaring a variable with the format `schema.VARIABLE`, so that enabling `schema` will do changes to a possible query of variable `VARIABLE`. 46 | 47 | Example: 48 | 49 | # Enabling schema1 will add the '-DSCHEMA1ENABLED' additional compiler flags. 50 | schema1.CFLAGS = -DSCHEMA1ENABLED 51 | 52 | %INDENTEND% 53 | 54 | ## Affected Variables 55 | 56 | %INDENT% 57 | 58 | These variables can be changed by schemas, with different behavior: 59 | 60 | (we need description) 61 | 62 | * SUBPROJECTS: how? 63 | * OBJ_FILES 64 | * FRAMEWORKS 65 | * LIBRARIES 66 | * PRIVATE_FRAMEWORKS 67 | * CFLAGS 68 | * CCFLAGS 69 | * OBJCFLAGS 70 | * OBJCCFLAGS 71 | * LOGOSFLAGS 72 | * LDFLAGS 73 | * CODESIGN_FLAGS 74 | * STRIP_FLAGS 75 | 76 | %INDENTEND% 77 | 78 | ## Conventions 79 | 80 | %INDENT% 81 | 82 | * Schema names should be lowercase. 83 | 84 | %INDENTEND% 85 | -------------------------------------------------------------------------------- /2_1_1_4_1_DEFAULT_SCHEMATA.md: -------------------------------------------------------------------------------- 1 | # Theos Schemas 2 | 3 | This document pertains to: 4 | 5 | * Schemas available for use in the default Theos installation, with the `SCHEMA` variable. 6 | 7 | ###### debug 8 | 9 | Controls compilation of debug symbols and stripping. 10 | When enabled, `--DDEBUG -ggdb` compiler flags are added, `-ggdb` linker flags are added, and optimization is disabled. Additionally, `+debug` is added to the output package name. 11 | -------------------------------------------------------------------------------- /2_1_1_5_0_TARGET.md: -------------------------------------------------------------------------------- 1 | # Targets and Platforms 2 | 3 | This section pertains to: 4 | 5 | * Detailed explanation of setting the `TARGET` variable, defined in previous sections as a way of controlling the build process. 6 | * Information on how targets and platforms are defined and handled by Theos. 7 | 8 | ## Selecting a target 9 | 10 | %INDENT% 11 | 12 | ###### TARGET %S% (String) 13 | 14 | The system for which Theos is to build projects. Also defines miscellaneous build aspects. 15 | Defaults and availability are platform-wise. 16 | 17 | TARGET flags are split by colons (`:`), and different targets may parse these flags in different ways. The first flag is always used to define the target name, still. 18 | 19 | For more information on how Theos' default targets handle flags, read [Theos Default Targets](./2_1_1_5_1_DEFAULT_TARGETS.md). This document focuses on the behavior of Theos regarding targets. 20 | 21 | Theos Targets should never directly read from `TARGET`. For more information, refer to [\_THEOS\_TARGET\_ARG\_X](nolink). 22 | 23 | %INDENTEND% 24 | 25 | ## Platforms 26 | 27 | %INDENT% 28 | 29 | Platforms are automatically picked by Theos through the output of `uname -s` (kernel name). For more information on this tool, refer to [uname(1)](http://linux.die.net/man/1/uname). 30 | 31 | Each platform has a makefile included to define special behavior through variables. This makefile is placed at `$(THEOS_MAKE_PATH)/platforms/.mk`. 32 | 33 | These variables are described as follows. This section does not focus on the behavior defined by default Theos platforms. For such information, refer to [Theos Default Platforms](./2_1_1_5_2_DEFAULT_PLATFORMS.md). 34 | 35 | ###### \_THEOS\_PLATFORM\_LOADED %?% (Boolean) 36 | 37 | Defines whether Theos has loaded a platform. 38 | 39 | Each platform should check for this value to be undefined before defining platform variables, and when doing so, it should set this variable to [TRUE](./2_1_1_X_VARIABLE_CLASSES.md#Boolean). 40 | 41 | Defaults to empty. 42 | 43 | ###### THEOS\_PLATFORM\_NAME %?% (String) 44 | 45 | The human-readable name of this platform, rather than the kernel name of the system. 46 | 47 | Defaults to empty. 48 | 49 | ###### \_THEOS\_PLATFORM\_DEFAULT\_TARGET %?% (String) 50 | 51 | The default target for the platform to build to. Refer to [Target Selection](./2_1_1_5_TARGETS.md#targets) for more detail. 52 | 53 | Defaults to empty. 54 | 55 | ###### \_THEOS\_PLATFORM\_DU\_EXCLUDE %?% (String) 56 | 57 | The exclude flag for [du(1)](http://linux.die.net/man/1/du). 58 | 59 | Defaults to empty. 60 | 61 | ###### \_THEOS\_PLATFORM\_MD5SUM %?% (String) 62 | 63 | The name of the MD5 Sum generation program in the system. 64 | 65 | Defaults to empty. 66 | 67 | %INDENTEND% 68 | 69 | ## Targets 70 | 71 | %INDENT% 72 | 73 | Targets are picked by Theos through the Target Name. The Target Name can be defined either on the platform (through the [\_THEOS\_PLATFORM\_DEFAULT\_TARGET](needlink) variable, or through the first flag of the [TARGET](needlink) variable. 74 | 75 | Targets can be part of one of the following categories: 76 | 77 | * Native: It describes the building process having as a target the same platform it's built at. 78 | * Non-native: It describes the building process having as a target a different platform from the one it's built at. 79 | 80 | Each target has a makefile included to define special behavior through variables. This makefile should be placed at `$(THEOS_MAKE_PATH)/targets//.mk`. Usually, platform target directories should contain a `native.mk` makefile symlinking to the native target. 81 | 82 | These variables are defined as follows. This section does not focus on the behavior defined by default Theos platforms. For such information, refer to [Theos Default Targets](./2_1_1_5_2_DEFAULT_TARGETS.md). 83 | 84 | These variables should *only* be set by the target if they are previously undefined, otherwise the user's build configuration might be overriden. 85 | 86 | Before defining these variables, check for `_THEOS_TARGET_LOADED` being undefined. They should only be set if this condition is true. 87 | 88 | Some rules can also be defined or overriden in these makefiles. 89 | 90 | *(NOTE: In this context variables marked as system-wise are usually **only** to be written in this context, and should be considered read-only for other purposes.)* 91 | 92 | ### Target Variables 93 | 94 | %INDENT% 95 | 96 | ###### \_THEOS\_TARGET\_LOADED (Boolean) 97 | 98 | Defines whether the target was loaded. 99 | Should always be set to `true` on the start of the target Makefile. 100 | 101 | Defaults to empty. 102 | 103 | ###### THEOS\_TARGET\_NAME 104 | 105 | Defines the name of the target. 106 | Should always be set. 107 | 108 | Defaults to empty. 109 | 110 | ###### TARGET\_EXE\_EXT %S% (String) 111 | 112 | Defines the extension for binaries for the target. 113 | 114 | Defaults to empty. 115 | 116 | ###### TARGET\_LIB\_EXT %S% (String) 117 | 118 | Defines the extension for libraries for the target. 119 | 120 | Defaults to empty. 121 | 122 | ###### TARGET\_CC %S% (String) 123 | 124 | Defines the path of the C compiler for the target. 125 | 126 | Defaults to empty. 127 | 128 | ###### TARGET\_CXX %S% (String) 129 | 130 | Defines the path of the C++ compiler for the target. 131 | 132 | Defaults to empty. 133 | 134 | ###### TARGET\_LD %S% (String) 135 | 136 | Defines the path of the linker for the target. 137 | Should usually be set to the C++ compiler. 138 | 139 | Defaults to empty. 140 | 141 | ###### \_THEOS\_TARGET\_CFLAGS %S% (String) 142 | 143 | Defines compiler flags specially from the target. 144 | 145 | Defaults to empty. 146 | 147 | ###### TARGET\_CFLAGS\_DYNAMICLIB 148 | 149 | The compiler flags to be applied when building a dynamic library for the target. 150 | 151 | Defaults to empty. 152 | 153 | ###### \_THEOS\_TARGET\_ONLY\_OBJCFLAGS 154 | 155 | ???????? 156 | 157 | Defaults to empty. 158 | 159 | ###### \_THEOS\_TARGET\_LDFLAGS %S% (String) 160 | 161 | Defines linker flags specially from the target. 162 | Should contain `-multiply_defined suppress`. 163 | 164 | Defaults to empty. 165 | 166 | ###### TARGET\_LDFLAGS\_DYNAMICLIB 167 | 168 | The linker flags to be applied when building a dynamic library for the target. 169 | 170 | Defaults to empty. 171 | 172 | ###### TARGET\_STRIP 173 | 174 | Defines the path of the [strip(1)](http://linux.die.net/man/1/strip) tool. 175 | 176 | Defaults to empty. 177 | 178 | ###### TARGET\_STRIP\_FLAGS 179 | 180 | Defines the flags for the [strip(1)](http://linux.die.net/man/1/strip) tool. 181 | 182 | Defaults to empty. 183 | 184 | ###### TARGET\_CODESIGN\_ALLOCATE 185 | 186 | Defines the path for the [codesign\_allocate(1)](http://developer.apple.com/library/Mac/#documentation/Darwin/Reference/ManPages/man1/codesign_allocate.1.html) tool. 187 | 188 | Defaults to empty. 189 | 190 | ###### TARGET\_CODESIGN 191 | 192 | Defines the path for the codesigning tool. 193 | It can be usually set to [codesign(1)](https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/codesign.1.html) or `ldid`. 194 | 195 | Defaults to empty. 196 | 197 | ###### TARGET\_CODESIGN\_FLAGS 198 | 199 | Defines the flags for the codesigning tool. 200 | 201 | Defaults to empty. 202 | 203 | ###### TARGET\_PRIVATE\_FRAMEWORK\_PATH 204 | 205 | The path to private frameworks inside the sysroot. 206 | 207 | Defaults to empty. 208 | 209 | ###### ARCHS 210 | 211 | Defines the architecture of the output object files for the target. 212 | 213 | Defaults to empty. 214 | 215 | ###### \_THEOS\_TARGET\_SUPPORTS\_BUNDLES (Boolean) 216 | 217 | An unused variable. 218 | 219 | Defaults to empty. 220 | 221 | ###### \_THEOS\_TARGET\_BUNDLE\_INFO\_PLIST\_SUBDIRECTORY 222 | 223 | When creating a bundle with `bundle.mk`, the subdirectory where the Info.plist file will be placed. 224 | 225 | Defaults to empty. 226 | 227 | ###### \_THEOS\_TARGET\_BUNDLE\_RESOURCE\_SUBDIRECTORY 228 | 229 | When creating a bundle with `bundle.mk`, the subdirectory where the bundle resources will be placed. 230 | 231 | Defaults to empty. 232 | 233 | ###### \_THEOS\_TARGET\_BUNDLE\_BINARY\_SUBDIRECTORY 234 | 235 | When creating a bundle with `bundle.mk`, the subdirectory where the bundle main executable will be placed. 236 | 237 | Defaults to empty. 238 | 239 | %INDENTEND% 240 | 241 | ### Target Data Variables 242 | 243 | %INDENT% 244 | 245 | These variables can be read by the target to suit itself to the project's needs. 246 | 247 | ###### \_\_THEOS\_TARGET\_ARG\_X 248 | 249 | Special variable name. Here, *X* is a number which starts on 1. 250 | 251 | This variable can be used for querying the Xth flag of the `TARGET` variable, instead of directly parsing the `TARGET` variable. 252 | 253 | This variable is empty if the Xth flag of `TARGET` is empty. Otherwise, it is filled with content. 254 | 255 | ###### SYSROOT 256 | 257 | This variable, if defined, specifies the desired system root for the target. Its data should then be considered when setting `_THEOS_TARGET_CFLAGS` and `_THEOS_TARGET_LDFLAGS`. 258 | 259 | Defaults to empty. 260 | 261 | %INDENTEND% 262 | 263 | ### Common Variables 264 | 265 | %INDENT% 266 | 267 | When some target variables are common across targets (for instance, for all Windows targets, the executable extension will be .exe), by convention a makefile should be created at `$(THEOS_MAKE_PATH)/targets/_common/.mk`, and this makefile should be included by all targets that have this common variable. 268 | 269 | The documentation of which common targets Theos offers and which target variables are usually placed there, refer to [Default Common Targets](./2_1_1_5_3_DEFAULT_COMMON_TARGETS.md). 270 | 271 | %INDENTEND% 272 | 273 | %INDENTEND% 274 | -------------------------------------------------------------------------------- /2_1_1_5_1_DEFAULT_TARGETS.md: -------------------------------------------------------------------------------- 1 | # Theos Targets 2 | 3 | This document pertains to: 4 | 5 | * Documentation of the functionality from default Theos targets. 6 | 7 | This document will be divided between targets by platform. When documented, `TARGET` variable flags will always start at the second flag (that is, disregarding the target specifier). 8 | 9 | ## Darwin (OSX) 10 | 11 | %INDENT% 12 | 13 | ### iphone (iPhone OS) 14 | 15 | %INDENT% 16 | 17 | #### `TARGET` flags 18 | 19 | %INDENT% 20 | 21 | For this target, the `TARGET` variable flags that can be applied are: 22 | 23 | * (Optional) `clang` Flag: If set to `clang`, `clang` is used as the C/C++ compiler instead of `gcc`. 24 | * SDK Version Flag: Defines the SDK version for the build. If empty or set to `latest`, defaults to the latest SDK version found. 25 | * Deployment Target Flag: Defines the deployment target for the build, represented by an iPhone OS version number. If empty, defaults to `3.0`. 26 | 27 | %INDENTEND% 28 | 29 | #### Variables 30 | 31 | %INDENT% 32 | 33 | Variables which define behavior of this target's configuration are: 34 | 35 | ###### SYSROOT 36 | 37 | Defines the system root for the build. 38 | Should only be used if there is no way of letting Theos track the SDK traditionally. 39 | 40 | Defaults to the `$(THEOS_PLATFORM_SDK_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk`. 41 | 42 | ###### ARCHS 43 | 44 | Defines the architecture for the build. 45 | It is not recommended to set this variable, since Theos will attempt to optimize the supported architectures based on the defined deployment target and SDK version. 46 | 47 | Defaults to: 48 | 49 | * If SDK version is >= 6.0 and deployment target is < 4.3, `armv7`; 50 | * If SDK version is >= 6.0 and deployment target is >= 4.3, `armv7 armv7s`; 51 | * If SDK version is < 6.0, and deployment target is >= 3.0, `armv6 armv7`; 52 | * If SDK version is < 6.0, and deployment target is < 3.0, `armv6`. 53 | 54 | %INDENTEND% 55 | 56 | #### Tools 57 | 58 | %INDENT% 59 | 60 | Tools are found using [xcrun(1)](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/xcrun.1.html), with parameter `-sdk iphoneos`. The tools are defined as follows: 61 | 62 | * C Compiler: If `TARGET` flag `clang` was activated, `clang`. Otherwise, `gcc`. 63 | * C++ Compiler: If `TARGET` flag `clang` was activated, `clang++`. Otherwise, `g++`. 64 | * Linker: The C++ Compiler is used. 65 | * Strip: `strip`. 66 | * codesign\_allocate: Found using `xcrun(1)` flag `-find codesign_allocate`. 67 | * codesign: `ldid`. 68 | 69 | %INDENTEND% 70 | 71 | #### Flags 72 | 73 | %INDENT% 74 | 75 | Regarding the flags of building tools as specified by the target: 76 | 77 | * SDK flags are: 78 | * `-arch ` for each defined architecture 79 | * `-isysroot ` for the system root 80 | * `-D__IPHONE_OS_VERSION_MIN_REQUIRED=__IPHONE_` for the deployment target 81 | * `-miphoneos-version-min=` for the deployment target. 82 | 83 | * Flags for the compiler are the above SDK flags. 84 | * Flags for the linker are the above SDK flags, plus `-multiply_defined suppress`. 85 | * Flags for `strip` default to `-x`. 86 | * Flags for the codesigning tool default to `-S`. 87 | * The Private Framework path is defined with `$(SYSROOT)/System/Library/PrivateFrameworks`. 88 | 89 | %INDENTEND% 90 | 91 | #### Included Common Targets 92 | 93 | %INDENT% 94 | 95 | TODO. 96 | 97 | %INDENTEND% 98 | 99 | %INDENTEND% 100 | 101 | ### macosx/native (Mac OS X) 102 | 103 | %INDENT% 104 | 105 | #### `TARGET` Flags 106 | 107 | %INDENT% 108 | 109 | For this target, the `TARGET` variable flags that can be applied are: 110 | 111 | * (Optional) `clang` Flag: If set to `clang`, `clang` is used as the C/C++ compiler instead of `gcc`. 112 | * Deployment Target Flag: Defines the deployment target for the build, represented by a Mac OS X version number. If empty, no deployment target is applied. 113 | 114 | %INDENTEND% 115 | 116 | #### Variables 117 | 118 | %INDENT% 119 | 120 | Variables which define behavior of this target's configuration are: 121 | 122 | ###### ARCHS 123 | 124 | Defines the architecture for the build. 125 | 126 | Defaults to `i386 x86_64`. 127 | 128 | %INDENTEND% 129 | 130 | #### Tools 131 | 132 | %INDENT% 133 | 134 | Tools are found using [xcrun(1)](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/xcrun.1.html), with parameter `-sdk macosx`. The tools are defined as follows: 135 | 136 | * C Compiler: If `TARGET` flag `clang` was activated, `clang`. Otherwise, `gcc`. 137 | * C++ Compiler: If `TARGET` flag `clang` was activated, `clang++`. Otherwise, `g++`. 138 | * Linker: The C++ Compiler is used. 139 | * Strip: `strip`. 140 | * codesign\_allocate: Found using `xcrun(1)` flag `-find codesign_allocate`. 141 | * codesign: None. 142 | 143 | %INDENTEND% 144 | 145 | #### Flags 146 | 147 | %INDENT% 148 | 149 | Regarding the flags of building tools as specified by the target: 150 | 151 | * Flags for the compiler are `-arch ` for each defined architecure, and `-mmacosx-version-min=` for the deployment target. 152 | * Flags for the linker are the same as the compiler ones, plus `-multiply_defined suppress`. 153 | * Flags for `strip` default to `-x`. 154 | * The Private Framework path is defined as `/System/Library/PrivateFrameworks`. 155 | 156 | %INDENTEND% 157 | 158 | #### Included Common Targets 159 | 160 | %INDENT% 161 | 162 | TODO. 163 | 164 | %INDENTEND% 165 | 166 | %INDENTEND% 167 | 168 | ### simulator (iPhone Simulator) 169 | 170 | %INDENT% 171 | 172 | #### `TARGET` flags 173 | 174 | %INDENT% 175 | 176 | For this target, the `TARGET` variable flags that can be applied are: 177 | 178 | * (Optional) `clang` Flag: If set to `clang`, `clang` is used as the C/C++ compiler instead of `gcc`. 179 | * SDK Version Flag: Defines the SDK version for the build. If empty or set to `latest`, defaults to the latest SDK version found. 180 | * Deployment Target Flag: Defines the deployment target for the build, represented by an iPhone OS version number. If empty, defaults to `3.0`. 181 | 182 | %INDENTEND% 183 | 184 | #### Variables 185 | 186 | %INDENT% 187 | 188 | Variables which define behavior of this target's configuration are: 189 | 190 | ###### SYSROOT 191 | 192 | Defines the system root for the build. 193 | Should only be used if there is no way of letting Theos track the SDK traditionally. 194 | 195 | Defaults to the `$(THEOS_PLATFORM_SDK_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneSimulator.sdk`. 196 | 197 | ###### ARCHS 198 | 199 | Defines the architecture for the build. 200 | 201 | Defaults to `i386`. 202 | 203 | ###### IPHONE\_SIMULATOR\_ROOT 204 | 205 | Defines the root directory of the simulator OS. Is required for installs. 206 | 207 | Defaults to empty. 208 | 209 | %INDENTEND% 210 | 211 | #### Tools 212 | 213 | %INDENT% 214 | 215 | Tools are found using [xcrun(1)](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/xcrun.1.html), with parameter `-sdk iphoneos`. The tools are defined as follows: 216 | 217 | * C Compiler: If `TARGET` flag `clang` was activated, `clang`. Otherwise, `gcc`. 218 | * C++ Compiler: If `TARGET` flag `clang` was activated, `clang++`. Otherwise, `g++`. 219 | * Linker: The C++ Compiler is used. 220 | * Strip: `strip`. 221 | * codesign\_allocate: Found using `xcrun(1)` flag `-find codesign_allocate`. 222 | * codesign: No tool is assigned. 223 | 224 | %INDENTEND% 225 | 226 | #### Flags 227 | 228 | %INDENT% 229 | 230 | Regarding the flags of building tools as specified by the target: 231 | 232 | * SDK flags are: 233 | * `-arch ` for each defined architecure 234 | * `-isysroot ` for the system root 235 | * `-D__IPHONE_OS_VERSION_MIN_REQUIRED=__IPHONE_` for the deployment target 236 | * `-mmacosx-version-min=, where it is `10.6` if the target SDK version >= 4.0, and `10.5` if otherwise 237 | 238 | * Flags for the compiler are the above SDK flags, plus `-fobjc-abi-version=2 -fobjc-legacy-dispatch` if SDK version >= 3.2. 239 | * Flags for the linker are `-multiply_defined suppress`, above SDK flags, plus `-Xlinker -objc_abi_version -Xlinker 2` if SDK version >= 3.2. 240 | * Flags for `strip` default to `-x`. 241 | * Flags for the codesigning tool default to `-S`. 242 | * The Private Framework path is defined as `$(SYSROOT)/System/Library/PrivateFrameworks`. 243 | 244 | %INDENTEND% 245 | 246 | #### Rules 247 | 248 | %INDENT% 249 | 250 | This target overrides the following rules: 251 | 252 | ###### internal-install 253 | 254 | (goto rules documentation) 255 | 256 | Through the values on `IPHONE_SIMULATOR_ROOT`, installs the staging directory data into it. If it is not defined, provides an error message. 257 | 258 | %INDENTEND% 259 | 260 | #### Included Common Targets 261 | 262 | %INDENT% 263 | 264 | TODO. 265 | 266 | %INDENTEND% 267 | 268 | %INDENTEND% 269 | 270 | %INDENTEND% 271 | 272 | ## Darwin-arm (iPhone OS) 273 | 274 | %INDENT% 275 | 276 | ### iphone/native (iPhone OS) 277 | 278 | %INDENT% 279 | 280 | #### `TARGET` flags 281 | 282 | %INDENT% 283 | 284 | No `TARGET` flags can be applied for this target. 285 | 286 | %INDENTEND% 287 | 288 | #### Variables 289 | 290 | %INDENT% 291 | 292 | Variables which define behavior of this target's configuration are: 293 | 294 | ###### SYSROOT 295 | 296 | Defines the system root for the build. 297 | 298 | Defaults to `/var/sdk`. 299 | 300 | ###### SDKBINPATH 301 | 302 | Defines the path of the SDK build tools. 303 | 304 | Defaults to `/usr/bin`. 305 | 306 | ###### SDKTARGET 307 | 308 | Defines the tool prefix. ([TODO] A better explanation?) 309 | 310 | Defaults to `arm-apple-darwin9`. 311 | 312 | 313 | %INDENTEND% 314 | 315 | #### Tools 316 | 317 | %INDENT% 318 | 319 | Tools are found with the following path format: 320 | 321 | $(SDKBINPATH)/$(SDKTARGET)- 322 | 323 | The tool names are defined as follows: 324 | 325 | * C Compiler: `gcc`. 326 | * C++ Compiler: `g++`. 327 | * Linker: The C++ Compiler is used. 328 | * Strip: `strip`. 329 | * codesign\_allocate: `codesign_allocate`. 330 | * codesign: `ldid`. 331 | 332 | %INDENTEND% 333 | 334 | #### Flags 335 | 336 | %INDENT% 337 | 338 | Regarding the flags of building tools as specified by the target: 339 | 340 | * SDK flags are `-isysroot ` for the system root. 341 | * Flags for the compiler are the SDK flags. 342 | * Flags for the linker are the SDK flags, plus `-multiply_defined suppress`. 343 | * Flags for `strip` default to `-x`. 344 | * Flags for the codesigning tool default to `-S`. 345 | * The Private Framework path is defined as `$(SYSROOT)/System/Library/PrivateFrameworks`. 346 | 347 | %INDENTEND% 348 | 349 | #### Included Common Targets 350 | 351 | %INDENT% 352 | 353 | TODO. 354 | 355 | %INDENTEND% 356 | 357 | %INDENTEND% 358 | 359 | %INDENTEND% 360 | 361 | ## Linux 362 | 363 | %INDENT% 364 | 365 | ### iphone (iPhone OS) 366 | 367 | %INDENT% 368 | 369 | #### `TARGET` flags 370 | 371 | %INDENT% 372 | 373 | No `TARGET` flags can be applied for this target. 374 | 375 | %INDENTEND% 376 | 377 | #### Variables 378 | 379 | %INDENT% 380 | 381 | Variables which define behavior of this target's configuration are: 382 | 383 | ###### SYSROOT 384 | 385 | Defines the system root for the build. 386 | 387 | Defaults to `/opt/iphone-sdk-3.0/sysroot`. 388 | 389 | ###### SDKBINPATH 390 | 391 | Defines the path of the SDK build tools. 392 | 393 | Defaults to `/opt/iphone-sdk-3.0/prefix/bin`. 394 | 395 | ###### SDKTARGET 396 | 397 | Defines the tool prefix. ([TODO] A better explanation?) 398 | 399 | Defaults to `arm-apple-darwin9`. 400 | 401 | %INDENTEND% 402 | 403 | #### Tools 404 | 405 | %INDENT% 406 | 407 | Tools are found with the following path format: 408 | 409 | $(SDKBINPATH)/$(SDKTARGET)- 410 | 411 | The tool names are defined as follows: 412 | 413 | * C Compiler: `gcc`. 414 | * C++ Compiler: `g++`. 415 | * Linker: The C++ Compiler is used. 416 | * Strip: `strip`. 417 | * codesign\_allocate: `codesign_allocate`. 418 | * codesign: `ldid`. 419 | 420 | %INDENTEND% 421 | 422 | #### Flags 423 | 424 | %INDENT% 425 | 426 | Regarding the flags of building tools as specified by the target: 427 | 428 | * SDK flags are `-isysroot ` for the system root. 429 | * Flags for the compiler are the SDK flags. 430 | * Flags for the linker are the SDK flags, plus `-multiply_defined suppress`. 431 | * Flags for `strip` default to `-x`. 432 | * Flags for the codesigning tool default to `-S`. 433 | * The Private Framework path is defined as `$(SYSROOT)/System/Library/PrivateFrameworks`. 434 | 435 | %INDENTEND% 436 | 437 | #### Included Common Targets 438 | 439 | %INDENT% 440 | 441 | TODO. 442 | 443 | %INDENTEND% 444 | 445 | %INDENTEND% 446 | 447 | ### linux/native (Linux) 448 | 449 | %INDENT% 450 | 451 | #### `TARGET` flags 452 | 453 | %INDENT% 454 | 455 | * Cross-compiling flag: Specifies the tool prefix. 456 | 457 | %INDENTEND% 458 | 459 | #### Variables 460 | 461 | %INDENT% 462 | 463 | There are no variables which define extra behavior for this target. 464 | 465 | %INDENTEND% 466 | 467 | #### Tools 468 | 469 | %INDENT% 470 | 471 | Tools are found with the following path format: 472 | 473 | - 474 | 475 | * C Compiler: `gcc`. 476 | * C++ Compiler: `g++`. 477 | * Linker: The C++ Compiler is used. 478 | * Strip: `strip`. 479 | * codesign\_allocate: None. 480 | * codesign: None. 481 | 482 | %INDENTEND% 483 | 484 | #### Flags 485 | 486 | %INDENT% 487 | 488 | No flags are specified to any tools by default. 489 | 490 | %INDENTEND% 491 | 492 | #### Included Common Targets 493 | 494 | %INDENT% 495 | 496 | TODO. 497 | 498 | %INDENTEND% 499 | 500 | %INDENTEND% 501 | 502 | %INDENTEND% 503 | -------------------------------------------------------------------------------- /2_1_1_5_2_DEFAULT_PLATFORMS.md: -------------------------------------------------------------------------------- 1 | # Theos Platforms 2 | 3 | This document pertains to: 4 | 5 | * Platforms available in the Theos installation, and how they behave. 6 | 7 | ### Darwin (OSX) 8 | 9 | %INDENT% 10 | 11 | In this platform the native SDK root is set through [xcode-select(1)](http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html), with the `-print-path` option. 12 | 13 | The default target is `iphone`, the [du(1)](http://linux.die.net/man/1/du) exclude flag is `-I`, and the MD5Sum generation program is called `md5`. 14 | 15 | %INDENTEND% 16 | 17 | ### Darwin-arm (iPhone OS) 18 | 19 | %INDENT% 20 | 21 | In this platform there is no set SDK root, as the default and only supported target is the native. 22 | 23 | The [du(1)](http://linux.die.net/man/1/du) exclude flag is `--exclude`, and the MD5Sum generation program is `md5sum`. 24 | 25 | %INDENTEND% 26 | 27 | ### Linux 28 | 29 | %INDENT% 30 | 31 | In this platform there is no set SDK root. 32 | 33 | The default target is `iphone`, the [du(1)](http://linux.die.net/man/1/du) exclude flag is `--exclude`, and the MD5Sum generation program is `md5sum`. 34 | 35 | %INDENTEND% 36 | -------------------------------------------------------------------------------- /2_1_1_5_3_DEFAULT_COMMON_TARGETS.md: -------------------------------------------------------------------------------- 1 | # Theos Common Targets 2 | 3 | This document pertains to: 4 | 5 | * Common targets available in the default Theos installation, and how they behave. 6 | 7 | ### darwin 8 | 9 | This is the common target for all Darwin targets. It sets: 10 | 11 | * `TARGET_EXE_EXT` to empty. 12 | * `TARGET_LIB_EXT` to '.dylib'. 13 | * `TARGET_LDFLAGS_DYNAMICLIB` to '-dynamiclib -install\_name "$(LOCAL\_INSTALL\_PATH)/$(1)"'. 14 | * `TARGET_CFLAGS_DYNAMICLIB` to empty. 15 | * `_THEOS_TARGET_ONLY_OBJCFLAGS` to '-std=c99'. 16 | * `_THEOS_TARGET_SUPPORTS_BUNDLES` to 'true'. 17 | 18 | ### linux 19 | 20 | This is the common target for all Linux targets. It sets: 21 | 22 | * `TARGET_EXE_EXT` to empty. 23 | * `TARGET_LIB_EXT` to '.so'. 24 | * `TARGET_LDFLAGS_DYNAMICLIB` to '-shared -Wl,-soname,$(1)'. 25 | * `TARGET_CFLAGS_DYNAMICLIB` to `-fPIC`. 26 | 27 | ### darwin\_flat\_bundle 28 | 29 | This is the common target for all targets whose produced bundles should be flat (that is, have all files on the root directory). It sets: 30 | 31 | * `_THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY` to empty. 32 | * `_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY` to empty. 33 | * `_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY` to empty. 34 | 35 | ### darwin\_hierarchial\_bundle 36 | 37 | This is the common target for all targets whose produced bundles should be hierarchial (that is, have a specific subdirectory structure). It sets: 38 | 39 | * `_THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY` to '/Contents'. 40 | * `_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY` to '/Contents/Resources'. 41 | * `_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY` to '/Contents/MacOS'. 42 | -------------------------------------------------------------------------------- /2_1_1_6_INSTANCES.md: -------------------------------------------------------------------------------- 1 | # Instance Name Variables 2 | 3 | The variables in this section pertain to: 4 | 5 | * Declaring Instances 6 | 7 | ## Concept 8 | 9 | %INDENT% 10 | 11 | The concept of instances can be found inside the [Instances](./2_1_2_INSTANCES.md) section, as well as a differentiation in depth of each default instance type, and how instance names come into effect. 12 | 13 | Due to a conceptual paradigm, we chose to document these variables under the Master Variables section to later expand on them on the Instances section. 14 | 15 | %INDENTEND% 16 | 17 | ## Variables 18 | 19 | %INDENT% 20 | 21 | All variables default to an empty value. 22 | 23 | ###### TOOL\_NAME 24 | 25 | Specifies space-separated tool instance names. 26 | 27 | Requires `tool.mk` to be imported to take effect. 28 | 29 | ###### LIBRARY\_NAME 30 | 31 | Specifies space-separated library instance names. 32 | 33 | Requires `library.mk` to be imported to take effect. 34 | 35 | ###### TWEAK\_NAME 36 | 37 | Specifies space-separated tweak instance names. 38 | 39 | Requires `tweak.mk` to be imported to take effect. 40 | 41 | ###### BUNDLE\_NAME 42 | 43 | Specifies space-separated bundle instance names. 44 | 45 | Requires `bundle.mk` to be imported to take effect. 46 | 47 | ###### APPLICATION\_NAME 48 | 49 | Specifies space-separated application instance names. 50 | 51 | Requires `application.mk` to be imported to take effect. 52 | 53 | ###### FRAMEWORK\_NAME 54 | 55 | Specifies space-separated framework instance names. 56 | 57 | Requires `framework.mk` to be imported to take effect. 58 | 59 | ###### SUBPROJECT\_NAME 60 | 61 | Specifies space-separated subproject instance names. 62 | 63 | Required `subproject.mk` to be imported to take effect. 64 | 65 | %INDENTEND% 66 | -------------------------------------------------------------------------------- /2_1_2_INSTANCES.md: -------------------------------------------------------------------------------- 1 | # The Instance Variable System 2 | 3 | Theos features an "instance" system based on that of [GNUStep Make](http://www.gnustep.org/resources/documentation/Developer/Make/Manual/make_toc.html), which allows the developer to manage multiple build targets (libraries, tools, applications...) inside a single project. 4 | 5 | Instances specify **what should be built** and **how**, as well as **where it belongs on the filesystem**. 6 | 7 | We understand instance variables as variables that, for determined instance, define how something should be built, as opposed to master variables, that apply globally for an entire project. For example, taking `program` as an instance name: 8 | 9 | %CODE% 10 | 11 | program_FILES = file.c main.c 12 | program_FRAMEWORKS = UIKit 13 | program_INSTALL_PATH = /usr/bin 14 | 15 | %CODEEND% 16 | 17 | A list of instance names to be built by a project is specified by the [Instance Specifier Variables](./2_1_1_6_INSTANCES.md), documented elsewhere. 18 | 19 | This section will document a list of instance variables, both general ones that apply for all instances and specific one for each instance type, and will discuss the application of each instance type in Theos, as well as how to extend Theos by creating instance types. 20 | -------------------------------------------------------------------------------- /Markdown.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # Markdown -- A text-to-HTML conversion tool for web writers 5 | # 6 | # Copyright (c) 2004 John Gruber 7 | # 8 | # 9 | 10 | 11 | package Markdown; 12 | require 5.006_000; 13 | use strict; 14 | use warnings; 15 | 16 | use Digest::MD5 qw(md5_hex); 17 | use vars qw($VERSION); 18 | $VERSION = '1.0.1'; 19 | # Tue 14 Dec 2004 20 | 21 | ## Disabled; causes problems under Perl 5.6.1: 22 | # use utf8; 23 | # binmode( STDOUT, ":utf8" ); # c.f.: http://acis.openlib.org/dev/perl-unicode-struggle.html 24 | 25 | 26 | # 27 | # Global default settings: 28 | # 29 | my $g_empty_element_suffix = " />"; # Change to ">" for HTML output 30 | my $g_tab_width = 4; 31 | 32 | 33 | # 34 | # Globals: 35 | # 36 | 37 | # Regex to match balanced [brackets]. See Friedl's 38 | # "Mastering Regular Expressions", 2nd Ed., pp. 328-331. 39 | my $g_nested_brackets; 40 | $g_nested_brackets = qr{ 41 | (?> # Atomic matching 42 | [^\[\]]+ # Anything other than brackets 43 | | 44 | \[ 45 | (??{ $g_nested_brackets }) # Recursive set of nested brackets 46 | \] 47 | )* 48 | }x; 49 | 50 | 51 | # Table of hash values for escaped characters: 52 | my %g_escape_table; 53 | foreach my $char (split //, '\\`*_{}[]()>#+-.!') { 54 | $g_escape_table{$char} = md5_hex($char); 55 | } 56 | 57 | 58 | # Global hashes, used by various utility routines 59 | my %g_urls; 60 | my %g_titles; 61 | my %g_html_blocks; 62 | 63 | # Used to track when we're inside an ordered or unordered list 64 | # (see _ProcessListItems() for details): 65 | my $g_list_level = 0; 66 | 67 | 68 | #### Blosxom plug-in interface ########################################## 69 | 70 | # Set $g_blosxom_use_meta to 1 to use Blosxom's meta plug-in to determine 71 | # which posts Markdown should process, using a "meta-markup: markdown" 72 | # header. If it's set to 0 (the default), Markdown will process all 73 | # entries. 74 | my $g_blosxom_use_meta = 0; 75 | 76 | sub start { 1; } 77 | sub story { 78 | my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; 79 | 80 | if ( (! $g_blosxom_use_meta) or 81 | (defined($meta::markup) and ($meta::markup =~ /^\s*markdown\s*$/i)) 82 | ){ 83 | $$body_ref = Markdown($$body_ref); 84 | } 85 | 1; 86 | } 87 | 88 | 89 | #### Movable Type plug-in interface ##################################### 90 | eval {require MT}; # Test to see if we're running in MT. 91 | unless ($@) { 92 | require MT; 93 | import MT; 94 | require MT::Template::Context; 95 | import MT::Template::Context; 96 | 97 | eval {require MT::Plugin}; # Test to see if we're running >= MT 3.0. 98 | unless ($@) { 99 | require MT::Plugin; 100 | import MT::Plugin; 101 | my $plugin = new MT::Plugin({ 102 | name => "Markdown", 103 | description => "A plain-text-to-HTML formatting plugin. (Version: $VERSION)", 104 | doc_link => 'http://daringfireball.net/projects/markdown/' 105 | }); 106 | MT->add_plugin( $plugin ); 107 | } 108 | 109 | MT::Template::Context->add_container_tag(MarkdownOptions => sub { 110 | my $ctx = shift; 111 | my $args = shift; 112 | my $builder = $ctx->stash('builder'); 113 | my $tokens = $ctx->stash('tokens'); 114 | 115 | if (defined ($args->{'output'}) ) { 116 | $ctx->stash('markdown_output', lc $args->{'output'}); 117 | } 118 | 119 | defined (my $str = $builder->build($ctx, $tokens) ) 120 | or return $ctx->error($builder->errstr); 121 | $str; # return value 122 | }); 123 | 124 | MT->add_text_filter('markdown' => { 125 | label => 'Markdown', 126 | docs => 'http://daringfireball.net/projects/markdown/', 127 | on_format => sub { 128 | my $text = shift; 129 | my $ctx = shift; 130 | my $raw = 0; 131 | if (defined $ctx) { 132 | my $output = $ctx->stash('markdown_output'); 133 | if (defined $output && $output =~ m/^html/i) { 134 | $g_empty_element_suffix = ">"; 135 | $ctx->stash('markdown_output', ''); 136 | } 137 | elsif (defined $output && $output eq 'raw') { 138 | $raw = 1; 139 | $ctx->stash('markdown_output', ''); 140 | } 141 | else { 142 | $raw = 0; 143 | $g_empty_element_suffix = " />"; 144 | } 145 | } 146 | $text = $raw ? $text : Markdown($text); 147 | $text; 148 | }, 149 | }); 150 | 151 | # If SmartyPants is loaded, add a combo Markdown/SmartyPants text filter: 152 | my $smartypants; 153 | 154 | { 155 | no warnings "once"; 156 | $smartypants = $MT::Template::Context::Global_filters{'smarty_pants'}; 157 | } 158 | 159 | if ($smartypants) { 160 | MT->add_text_filter('markdown_with_smartypants' => { 161 | label => 'Markdown With SmartyPants', 162 | docs => 'http://daringfireball.net/projects/markdown/', 163 | on_format => sub { 164 | my $text = shift; 165 | my $ctx = shift; 166 | if (defined $ctx) { 167 | my $output = $ctx->stash('markdown_output'); 168 | if (defined $output && $output eq 'html') { 169 | $g_empty_element_suffix = ">"; 170 | } 171 | else { 172 | $g_empty_element_suffix = " />"; 173 | } 174 | } 175 | $text = Markdown($text); 176 | $text = $smartypants->($text, '1'); 177 | }, 178 | }); 179 | } 180 | } 181 | else { 182 | #### BBEdit/command-line text filter interface ########################## 183 | # Needs to be hidden from MT (and Blosxom when running in static mode). 184 | 185 | # We're only using $blosxom::version once; tell Perl not to warn us: 186 | no warnings 'once'; 187 | unless ( defined($blosxom::version) ) { 188 | use warnings; 189 | 190 | #### Check for command-line switches: ################# 191 | my %cli_opts; 192 | use Getopt::Long; 193 | Getopt::Long::Configure('pass_through'); 194 | GetOptions(\%cli_opts, 195 | 'version', 196 | 'shortversion', 197 | 'html4tags', 198 | ); 199 | if ($cli_opts{'version'}) { # Version info 200 | print "\nThis is Markdown, version $VERSION.\n"; 201 | print "Copyright 2004 John Gruber\n"; 202 | print "http://daringfireball.net/projects/markdown/\n\n"; 203 | exit 0; 204 | } 205 | if ($cli_opts{'shortversion'}) { # Just the version number string. 206 | print $VERSION; 207 | exit 0; 208 | } 209 | if ($cli_opts{'html4tags'}) { # Use HTML tag style instead of XHTML 210 | $g_empty_element_suffix = ">"; 211 | } 212 | 213 | 214 | #### Process incoming text: ########################### 215 | my $text; 216 | { 217 | local $/; # Slurp the whole file 218 | $text = <>; 219 | } 220 | print Markdown($text); 221 | } 222 | } 223 | 224 | 225 | 226 | sub Markdown { 227 | # 228 | # Main function. The order in which other subs are called here is 229 | # essential. Link and image substitutions need to happen before 230 | # _EscapeSpecialChars(), so that any *'s or _'s in the 231 | # and tags get encoded. 232 | # 233 | my $text = shift; 234 | 235 | # Clear the global hashes. If we don't clear these, you get conflicts 236 | # from other articles when generating a page which contains more than 237 | # one article (e.g. an index page that shows the N most recent 238 | # articles): 239 | %g_urls = (); 240 | %g_titles = (); 241 | %g_html_blocks = (); 242 | 243 | 244 | # Standardize line endings: 245 | $text =~ s{\r\n}{\n}g; # DOS to Unix 246 | $text =~ s{\r}{\n}g; # Mac to Unix 247 | 248 | # Make sure $text ends with a couple of newlines: 249 | $text .= "\n\n"; 250 | 251 | # Convert all tabs to spaces. 252 | $text = _Detab($text); 253 | 254 | # Strip any lines consisting only of spaces and tabs. 255 | # This makes subsequent regexen easier to write, because we can 256 | # match consecutive blank lines with /\n+/ instead of something 257 | # contorted like /[ \t]*\n+/ . 258 | $text =~ s/^[ \t]+$//mg; 259 | 260 | # Turn block-level HTML blocks into hash entries 261 | $text = _HashHTMLBlocks($text); 262 | 263 | # Strip link definitions, store in hashes. 264 | $text = _StripLinkDefinitions($text); 265 | 266 | $text = _RunBlockGamut($text); 267 | 268 | $text = _UnescapeSpecialChars($text); 269 | 270 | return $text . "\n"; 271 | } 272 | 273 | 274 | sub _StripLinkDefinitions { 275 | # 276 | # Strips link definitions from text, stores the URLs and titles in 277 | # hash references. 278 | # 279 | my $text = shift; 280 | my $less_than_tab = $g_tab_width - 1; 281 | 282 | # Link defs are in the form: ^[id]: url "optional title" 283 | while ($text =~ s{ 284 | ^[ ]{0,$less_than_tab}\[(.+)\]: # id = $1 285 | [ \t]* 286 | \n? # maybe *one* newline 287 | [ \t]* 288 | ? # url = $2 289 | [ \t]* 290 | \n? # maybe one newline 291 | [ \t]* 292 | (?: 293 | (?<=\s) # lookbehind for whitespace 294 | ["(] 295 | (.+?) # title = $3 296 | [")] 297 | [ \t]* 298 | )? # title is optional 299 | (?:\n+|\Z) 300 | } 301 | {}mx) { 302 | $g_urls{lc $1} = _EncodeAmpsAndAngles( $2 ); # Link IDs are case-insensitive 303 | if ($3) { 304 | $g_titles{lc $1} = $3; 305 | $g_titles{lc $1} =~ s/"/"/g; 306 | } 307 | } 308 | 309 | return $text; 310 | } 311 | 312 | 313 | sub _HashHTMLBlocks { 314 | my $text = shift; 315 | my $less_than_tab = $g_tab_width - 1; 316 | 317 | # Hashify HTML blocks: 318 | # We only want to do this for block-level HTML tags, such as headers, 319 | # lists, and tables. That's because we still want to wrap

s around 320 | # "paragraphs" that are wrapped in non-block-level tags, such as anchors, 321 | # phrase emphasis, and spans. The list of tags we're looking for is 322 | # hard-coded: 323 | my $block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/; 324 | my $block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/; 325 | 326 | # First, look for nested blocks, e.g.: 327 | #

328 | #
329 | # tags for inner block must be indented. 330 | #
331 | #
332 | # 333 | # The outermost tags must start at the left margin for this to match, and 334 | # the inner nested divs must be indented. 335 | # We need to do this before the next, more liberal match, because the next 336 | # match will start at the first `
` and stop at the first `
`. 337 | $text =~ s{ 338 | ( # save in $1 339 | ^ # start of line (with /m) 340 | <($block_tags_a) # start tag = $2 341 | \b # word break 342 | (.*\n)*? # any number of lines, minimally matching 343 | # the matching end tag 344 | [ \t]* # trailing spaces/tabs 345 | (?=\n+|\Z) # followed by a newline or end of document 346 | ) 347 | }{ 348 | my $key = md5_hex($1); 349 | $g_html_blocks{$key} = $1; 350 | "\n\n" . $key . "\n\n"; 351 | }egmx; 352 | 353 | 354 | # 355 | # Now match more liberally, simply from `\n` to `\n` 356 | # 357 | $text =~ s{ 358 | ( # save in $1 359 | ^ # start of line (with /m) 360 | <($block_tags_b) # start tag = $2 361 | \b # word break 362 | (.*\n)*? # any number of lines, minimally matching 363 | .* # the matching end tag 364 | [ \t]* # trailing spaces/tabs 365 | (?=\n+|\Z) # followed by a newline or end of document 366 | ) 367 | }{ 368 | my $key = md5_hex($1); 369 | $g_html_blocks{$key} = $1; 370 | "\n\n" . $key . "\n\n"; 371 | }egmx; 372 | # Special case just for
. It was easier to make a special case than 373 | # to make the other regex more complicated. 374 | $text =~ s{ 375 | (?: 376 | (?<=\n\n) # Starting after a blank line 377 | | # or 378 | \A\n? # the beginning of the doc 379 | ) 380 | ( # save in $1 381 | [ ]{0,$less_than_tab} 382 | <(hr) # start tag = $2 383 | \b # word break 384 | ([^<>])*? # 385 | /?> # the matching end tag 386 | [ \t]* 387 | (?=\n{2,}|\Z) # followed by a blank line or end of document 388 | ) 389 | }{ 390 | my $key = md5_hex($1); 391 | $g_html_blocks{$key} = $1; 392 | "\n\n" . $key . "\n\n"; 393 | }egx; 394 | 395 | # Special case for standalone HTML comments: 396 | $text =~ s{ 397 | (?: 398 | (?<=\n\n) # Starting after a blank line 399 | | # or 400 | \A\n? # the beginning of the doc 401 | ) 402 | ( # save in $1 403 | [ ]{0,$less_than_tab} 404 | (?s: 405 | 408 | ) 409 | [ \t]* 410 | (?=\n{2,}|\Z) # followed by a blank line or end of document 411 | ) 412 | }{ 413 | my $key = md5_hex($1); 414 | $g_html_blocks{$key} = $1; 415 | "\n\n" . $key . "\n\n"; 416 | }egx; 417 | 418 | 419 | return $text; 420 | } 421 | 422 | 423 | sub _RunBlockGamut { 424 | # 425 | # These are all the transformations that form block-level 426 | # tags like paragraphs, headers, and list items. 427 | # 428 | my $text = shift; 429 | 430 | $text = _DoHeaders($text); 431 | 432 | # Do Horizontal Rules: 433 | $text =~ s{^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$}{\n tags around block-level tags. 447 | $text = _HashHTMLBlocks($text); 448 | 449 | $text = _FormParagraphs($text); 450 | 451 | return $text; 452 | } 453 | 454 | 455 | sub _RunSpanGamut { 456 | # 457 | # These are all the transformations that occur *within* block-level 458 | # tags like paragraphs, headers, and list items. 459 | # 460 | my $text = shift; 461 | 462 | $text = _DoCodeSpans($text); 463 | 464 | $text = _EscapeSpecialChars($text); 465 | 466 | # Process anchor and image tags. Images must come first, 467 | # because ![foo][f] looks like an anchor. 468 | $text = _DoImages($text); 469 | $text = _DoAnchors($text); 470 | 471 | # Make links out of things like `` 472 | # Must come after _DoAnchors(), because you can use < and > 473 | # delimiters in inline links like [this](). 474 | $text = _DoAutoLinks($text); 475 | 476 | $text = _EncodeAmpsAndAngles($text); 477 | 478 | $text = _DoItalicsAndBold($text); 479 | 480 | # Do hard breaks: 481 | $text =~ s/ {2,}\n/ or tags. 493 | # my $tags_to_skip = qr!<(/?)(?:pre|code|kbd|script|math)[\s>]!; 494 | 495 | foreach my $cur_token (@$tokens) { 496 | if ($cur_token->[0] eq "tag") { 497 | # Within tags, encode * and _ so they don't conflict 498 | # with their use in Markdown for italics and strong. 499 | # We're replacing each such character with its 500 | # corresponding MD5 checksum value; this is likely 501 | # overkill, but it should prevent us from colliding 502 | # with the escape values by accident. 503 | $cur_token->[1] =~ s! \* !$g_escape_table{'*'}!gx; 504 | $cur_token->[1] =~ s! _ !$g_escape_table{'_'}!gx; 505 | $text .= $cur_token->[1]; 506 | } else { 507 | my $t = $cur_token->[1]; 508 | $t = _EncodeBackslashEscapes($t); 509 | $text .= $t; 510 | } 511 | } 512 | return $text; 513 | } 514 | 515 | 516 | sub _DoAnchors { 517 | # 518 | # Turn Markdown link shortcuts into XHTML
tags. 519 | # 520 | my $text = shift; 521 | 522 | # 523 | # First, handle reference-style links: [link text] [id] 524 | # 525 | $text =~ s{ 526 | ( # wrap whole match in $1 527 | \[ 528 | ($g_nested_brackets) # link text = $2 529 | \] 530 | 531 | [ ]? # one optional space 532 | (?:\n[ ]*)? # one optional newline followed by spaces 533 | 534 | \[ 535 | (.*?) # id = $3 536 | \] 537 | ) 538 | }{ 539 | my $result; 540 | my $whole_match = $1; 541 | my $link_text = $2; 542 | my $link_id = lc $3; 543 | 544 | if ($link_id eq "") { 545 | $link_id = lc $link_text; # for shortcut links like [this][]. 546 | } 547 | 548 | if (defined $g_urls{$link_id}) { 549 | my $url = $g_urls{$link_id}; 550 | $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid 551 | $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. 552 | $result = "? # href = $3 578 | [ \t]* 579 | ( # $4 580 | (['"]) # quote char = $5 581 | (.*?) # Title = $6 582 | \5 # matching quote 583 | )? # title is optional 584 | \) 585 | ) 586 | }{ 587 | my $result; 588 | my $whole_match = $1; 589 | my $link_text = $2; 590 | my $url = $3; 591 | my $title = $6; 592 | 593 | $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid 594 | $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. 595 | $result = " tags. 616 | # 617 | my $text = shift; 618 | 619 | # 620 | # First, handle reference-style labeled images: ![alt text][id] 621 | # 622 | $text =~ s{ 623 | ( # wrap whole match in $1 624 | !\[ 625 | (.*?) # alt text = $2 626 | \] 627 | 628 | [ ]? # one optional space 629 | (?:\n[ ]*)? # one optional newline followed by spaces 630 | 631 | \[ 632 | (.*?) # id = $3 633 | \] 634 | 635 | ) 636 | }{ 637 | my $result; 638 | my $whole_match = $1; 639 | my $alt_text = $2; 640 | my $link_id = lc $3; 641 | 642 | if ($link_id eq "") { 643 | $link_id = lc $alt_text; # for shortcut links like ![this][]. 644 | } 645 | 646 | $alt_text =~ s/"/"/g; 647 | if (defined $g_urls{$link_id}) { 648 | my $url = $g_urls{$link_id}; 649 | $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid 650 | $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. 651 | $result = "\"$alt_text\"";? # src url = $3 680 | [ \t]* 681 | ( # $4 682 | (['"]) # quote char = $5 683 | (.*?) # title = $6 684 | \5 # matching quote 685 | [ \t]* 686 | )? # title is optional 687 | \) 688 | ) 689 | }{ 690 | my $result; 691 | my $whole_match = $1; 692 | my $alt_text = $2; 693 | my $url = $3; 694 | my $title = ''; 695 | if (defined($6)) { 696 | $title = $6; 697 | } 698 | 699 | $alt_text =~ s/"/"/g; 700 | $title =~ s/"/"/g; 701 | $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid 702 | $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. 703 | $result = "\"$alt_text\"";" . _RunSpanGamut($1) . "\n\n"; 730 | }egmx; 731 | 732 | $text =~ s{ ^(.+)[ \t]*\n-+[ \t]*\n+ }{ 733 | "

" . _RunSpanGamut($1) . "

\n\n"; 734 | }egmx; 735 | 736 | 737 | # atx-style headers: 738 | # # Header 1 739 | # ## Header 2 740 | # ## Header 2 with closing hashes ## 741 | # ... 742 | # ###### Header 6 743 | # 744 | $text =~ s{ 745 | ^(\#{1,6}) # $1 = string of #'s 746 | [ \t]* 747 | (.+?) # $2 = Header text 748 | [ \t]* 749 | \#* # optional closing #'s (not counted) 750 | \n+ 751 | }{ 752 | my $h_level = length($1); 753 | "" . _RunSpanGamut($2) . "\n\n"; 754 | }egmx; 755 | 756 | return $text; 757 | } 758 | 759 | 760 | sub _DoLists { 761 | # 762 | # Form HTML ordered (numbered) and unordered (bulleted) lists. 763 | # 764 | my $text = shift; 765 | my $less_than_tab = $g_tab_width - 1; 766 | 767 | # Re-usable patterns to match list item bullets and number markers: 768 | my $marker_ul = qr/[*+-]/; 769 | my $marker_ol = qr/\d+[.]/; 770 | my $marker_any = qr/(?:$marker_ul|$marker_ol)/; 771 | 772 | # Re-usable pattern to match any entirel ul or ol list: 773 | my $whole_list = qr{ 774 | ( # $1 = whole list 775 | ( # $2 776 | [ ]{0,$less_than_tab} 777 | (${marker_any}) # $3 = first list item marker 778 | [ \t]+ 779 | ) 780 | (?s:.+?) 781 | ( # $4 782 | \z 783 | | 784 | \n{2,} 785 | (?=\S) 786 | (?! # Negative lookahead for another list item marker 787 | [ \t]* 788 | ${marker_any}[ \t]+ 789 | ) 790 | ) 791 | ) 792 | }mx; 793 | 794 | # We use a different prefix before nested lists than top-level lists. 795 | # See extended comment in _ProcessListItems(). 796 | # 797 | # Note: There's a bit of duplication here. My original implementation 798 | # created a scalar regex pattern as the conditional result of the test on 799 | # $g_list_level, and then only ran the $text =~ s{...}{...}egmx 800 | # substitution once, using the scalar as the pattern. This worked, 801 | # everywhere except when running under MT on my hosting account at Pair 802 | # Networks. There, this caused all rebuilds to be killed by the reaper (or 803 | # perhaps they crashed, but that seems incredibly unlikely given that the 804 | # same script on the same server ran fine *except* under MT. I've spent 805 | # more time trying to figure out why this is happening than I'd like to 806 | # admit. My only guess, backed up by the fact that this workaround works, 807 | # is that Perl optimizes the substition when it can figure out that the 808 | # pattern will never change, and when this optimization isn't on, we run 809 | # afoul of the reaper. Thus, the slightly redundant code to that uses two 810 | # static s/// patterns rather than one conditional pattern. 811 | 812 | if ($g_list_level) { 813 | $text =~ s{ 814 | ^ 815 | $whole_list 816 | }{ 817 | my $list = $1; 818 | my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol"; 819 | # Turn double returns into triple returns, so that we can make a 820 | # paragraph for the last item in a list, if necessary: 821 | $list =~ s/\n{2,}/\n\n\n/g; 822 | my $result = _ProcessListItems($list, $marker_any); 823 | $result = "<$list_type>\n" . $result . "\n"; 824 | $result; 825 | }egmx; 826 | } 827 | else { 828 | $text =~ s{ 829 | (?:(?<=\n\n)|\A\n?) 830 | $whole_list 831 | }{ 832 | my $list = $1; 833 | my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol"; 834 | # Turn double returns into triple returns, so that we can make a 835 | # paragraph for the last item in a list, if necessary: 836 | $list =~ s/\n{2,}/\n\n\n/g; 837 | my $result = _ProcessListItems($list, $marker_any); 838 | $result = "<$list_type>\n" . $result . "\n"; 839 | $result; 840 | }egmx; 841 | } 842 | 843 | 844 | return $text; 845 | } 846 | 847 | 848 | sub _ProcessListItems { 849 | # 850 | # Process the contents of a single ordered or unordered list, splitting it 851 | # into individual list items. 852 | # 853 | 854 | my $list_str = shift; 855 | my $marker_any = shift; 856 | 857 | 858 | # The $g_list_level global keeps track of when we're inside a list. 859 | # Each time we enter a list, we increment it; when we leave a list, 860 | # we decrement. If it's zero, we're not in a list anymore. 861 | # 862 | # We do this because when we're not inside a list, we want to treat 863 | # something like this: 864 | # 865 | # I recommend upgrading to version 866 | # 8. Oops, now this line is treated 867 | # as a sub-list. 868 | # 869 | # As a single paragraph, despite the fact that the second line starts 870 | # with a digit-period-space sequence. 871 | # 872 | # Whereas when we're inside a list (or sub-list), that line will be 873 | # treated as the start of a sub-list. What a kludge, huh? This is 874 | # an aspect of Markdown's syntax that's hard to parse perfectly 875 | # without resorting to mind-reading. Perhaps the solution is to 876 | # change the syntax rules such that sub-lists must start with a 877 | # starting cardinal number; e.g. "1." or "a.". 878 | 879 | $g_list_level++; 880 | 881 | # trim trailing blank lines: 882 | $list_str =~ s/\n{2,}\z/\n/; 883 | 884 | 885 | $list_str =~ s{ 886 | (\n)? # leading line = $1 887 | (^[ \t]*) # leading whitespace = $2 888 | ($marker_any) [ \t]+ # list marker = $3 889 | ((?s:.+?) # list item text = $4 890 | (\n{1,2})) 891 | (?= \n* (\z | \2 ($marker_any) [ \t]+)) 892 | }{ 893 | my $item = $4; 894 | my $leading_line = $1; 895 | my $leading_space = $2; 896 | 897 | if ($leading_line or ($item =~ m/\n{2,}/)) { 898 | $item = _RunBlockGamut(_Outdent($item)); 899 | } 900 | else { 901 | # Recursion for sub-lists: 902 | $item = _DoLists(_Outdent($item)); 903 | chomp $item; 904 | $item = _RunSpanGamut($item); 905 | } 906 | 907 | "
  • " . $item . "
  • \n"; 908 | }egmx; 909 | 910 | $g_list_level--; 911 | return $list_str; 912 | } 913 | 914 | 915 | 916 | sub _DoCodeBlocks { 917 | # 918 | # Process Markdown `
    ` blocks.
     919 | #	
     920 | 
     921 | 	my $text = shift;
     922 | 
     923 | 	$text =~ s{
     924 | 			(?:\n\n|\A)
     925 | 			(	            # $1 = the code block -- one or more lines, starting with a space/tab
     926 | 			  (?:
     927 | 			    (?:[ ]{$g_tab_width} | \t)  # Lines must start with a tab or a tab-width of spaces
     928 | 			    .*\n+
     929 | 			  )+
     930 | 			)
     931 | 			((?=^[ ]{0,$g_tab_width}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
     932 | 		}{
     933 | 			my $codeblock = $1;
     934 | 			my $result; # return value
     935 | 
     936 | 			$codeblock = _EncodeCode(_Outdent($codeblock));
     937 | 			$codeblock = _Detab($codeblock);
     938 | 			$codeblock =~ s/\A\n+//; # trim leading newlines
     939 | 			$codeblock =~ s/\s+\z//; # trim trailing whitespace
     940 | 
     941 | 			$result = "\n\n
    " . $codeblock . "\n
    \n\n"; 942 | 943 | $result; 944 | }egmx; 945 | 946 | return $text; 947 | } 948 | 949 | 950 | sub _DoCodeSpans { 951 | # 952 | # * Backtick quotes are used for spans. 953 | # 954 | # * You can use multiple backticks as the delimiters if you want to 955 | # include literal backticks in the code span. So, this input: 956 | # 957 | # Just type ``foo `bar` baz`` at the prompt. 958 | # 959 | # Will translate to: 960 | # 961 | #

    Just type foo `bar` baz at the prompt.

    962 | # 963 | # There's no arbitrary limit to the number of backticks you 964 | # can use as delimters. If you need three consecutive backticks 965 | # in your code, use four for delimiters, etc. 966 | # 967 | # * You can use spaces to get literal backticks at the edges: 968 | # 969 | # ... type `` `bar` `` ... 970 | # 971 | # Turns to: 972 | # 973 | # ... type `bar` ... 974 | # 975 | 976 | my $text = shift; 977 | 978 | $text =~ s@ 979 | (`+) # $1 = Opening run of ` 980 | (.+?) # $2 = The code block 981 | (?$c
    "; 990 | @egsx; 991 | 992 | return $text; 993 | } 994 | 995 | 996 | sub _EncodeCode { 997 | # 998 | # Encode/escape certain characters inside Markdown code runs. 999 | # The point is that in code, these characters are literals, 1000 | # and lose their special Markdown meanings. 1001 | # 1002 | local $_ = shift; 1003 | 1004 | # Encode all ampersands; HTML entities are not 1005 | # entities within a Markdown code span. 1006 | s/&/&/g; 1007 | 1008 | # Encode $'s, but only if we're running under Blosxom. 1009 | # (Blosxom interpolates Perl variables in article bodies.) 1010 | { 1011 | no warnings 'once'; 1012 | if (defined($blosxom::version)) { 1013 | s/\$/$/g; 1014 | } 1015 | } 1016 | 1017 | 1018 | # Do the angle bracket song and dance: 1019 | s! < !<!gx; 1020 | s! > !>!gx; 1021 | 1022 | # Now, escape characters that are magic in Markdown: 1023 | s! \* !$g_escape_table{'*'}!gx; 1024 | s! _ !$g_escape_table{'_'}!gx; 1025 | s! { !$g_escape_table{'{'}!gx; 1026 | s! } !$g_escape_table{'}'}!gx; 1027 | s! \[ !$g_escape_table{'['}!gx; 1028 | s! \] !$g_escape_table{']'}!gx; 1029 | s! \\ !$g_escape_table{'\\'}!gx; 1030 | 1031 | return $_; 1032 | } 1033 | 1034 | 1035 | sub _DoItalicsAndBold { 1036 | my $text = shift; 1037 | 1038 | # must go first: 1039 | $text =~ s{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 } 1040 | {$2}gsx; 1041 | 1042 | $text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 } 1043 | {$2}gsx; 1044 | 1045 | return $text; 1046 | } 1047 | 1048 | 1049 | sub _DoBlockQuotes { 1050 | my $text = shift; 1051 | 1052 | $text =~ s{ 1053 | ( # Wrap whole match in $1 1054 | ( 1055 | ^[ \t]*>[ \t]? # '>' at the start of a line 1056 | .+\n # rest of the first line 1057 | (.+\n)* # subsequent consecutive lines 1058 | \n* # blanks 1059 | )+ 1060 | ) 1061 | }{ 1062 | my $bq = $1; 1063 | $bq =~ s/^[ \t]*>[ \t]?//gm; # trim one level of quoting 1064 | $bq =~ s/^[ \t]+$//mg; # trim whitespace-only lines 1065 | $bq = _RunBlockGamut($bq); # recurse 1066 | 1067 | $bq =~ s/^/ /g; 1068 | # These leading spaces screw with
     content, so we need to fix that:
    1069 | 			$bq =~ s{
    1070 | 					(\s*
    .+?
    ) 1071 | }{ 1072 | my $pre = $1; 1073 | $pre =~ s/^ //mg; 1074 | $pre; 1075 | }egsx; 1076 | 1077 | "
    \n$bq\n
    \n\n"; 1078 | }egmx; 1079 | 1080 | 1081 | return $text; 1082 | } 1083 | 1084 | 1085 | sub _FormParagraphs { 1086 | # 1087 | # Params: 1088 | # $text - string to process with html

    tags 1089 | # 1090 | my $text = shift; 1091 | 1092 | # Strip leading and trailing lines: 1093 | $text =~ s/\A\n+//; 1094 | $text =~ s/\n+\z//; 1095 | 1096 | my @grafs = split(/\n{2,}/, $text); 1097 | 1098 | # 1099 | # Wrap

    tags. 1100 | # 1101 | foreach (@grafs) { 1102 | unless (defined( $g_html_blocks{$_} )) { 1103 | $_ = _RunSpanGamut($_); 1104 | s/^([ \t]*)/

    /; 1105 | $_ .= "

    "; 1106 | } 1107 | } 1108 | 1109 | # 1110 | # Unhashify HTML blocks 1111 | # 1112 | foreach (@grafs) { 1113 | if (defined( $g_html_blocks{$_} )) { 1114 | $_ = $g_html_blocks{$_}; 1115 | } 1116 | } 1117 | 1118 | return join "\n\n", @grafs; 1119 | } 1120 | 1121 | 1122 | sub _EncodeAmpsAndAngles { 1123 | # Smart processing for ampersands and angle brackets that need to be encoded. 1124 | 1125 | my $text = shift; 1126 | 1127 | # Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: 1128 | # http://bumppo.net/projects/amputator/ 1129 | $text =~ s/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/&/g; 1130 | 1131 | # Encode naked <'s 1132 | $text =~ s{<(?![a-z/?\$!])}{<}gi; 1133 | 1134 | return $text; 1135 | } 1136 | 1137 | 1138 | sub _EncodeBackslashEscapes { 1139 | # 1140 | # Parameter: String. 1141 | # Returns: The string, with after processing the following backslash 1142 | # escape sequences. 1143 | # 1144 | local $_ = shift; 1145 | 1146 | s! \\\\ !$g_escape_table{'\\'}!gx; # Must process escaped backslashes first. 1147 | s! \\` !$g_escape_table{'`'}!gx; 1148 | s! \\\* !$g_escape_table{'*'}!gx; 1149 | s! \\_ !$g_escape_table{'_'}!gx; 1150 | s! \\\{ !$g_escape_table{'{'}!gx; 1151 | s! \\\} !$g_escape_table{'}'}!gx; 1152 | s! \\\[ !$g_escape_table{'['}!gx; 1153 | s! \\\] !$g_escape_table{']'}!gx; 1154 | s! \\\( !$g_escape_table{'('}!gx; 1155 | s! \\\) !$g_escape_table{')'}!gx; 1156 | s! \\> !$g_escape_table{'>'}!gx; 1157 | s! \\\# !$g_escape_table{'#'}!gx; 1158 | s! \\\+ !$g_escape_table{'+'}!gx; 1159 | s! \\\- !$g_escape_table{'-'}!gx; 1160 | s! \\\. !$g_escape_table{'.'}!gx; 1161 | s{ \\! }{$g_escape_table{'!'}}gx; 1162 | 1163 | return $_; 1164 | } 1165 | 1166 | 1167 | sub _DoAutoLinks { 1168 | my $text = shift; 1169 | 1170 | $text =~ s{<((https?|ftp):[^'">\s]+)>}{
    $1}gi; 1171 | 1172 | # Email addresses: 1173 | $text =~ s{ 1174 | < 1175 | (?:mailto:)? 1176 | ( 1177 | [-.\w]+ 1178 | \@ 1179 | [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ 1180 | ) 1181 | > 1182 | }{ 1183 | _EncodeEmailAddress( _UnescapeSpecialChars($1) ); 1184 | }egix; 1185 | 1186 | return $text; 1187 | } 1188 | 1189 | 1190 | sub _EncodeEmailAddress { 1191 | # 1192 | # Input: an email address, e.g. "foo@example.com" 1193 | # 1194 | # Output: the email address as a mailto link, with each character 1195 | # of the address encoded as either a decimal or hex entity, in 1196 | # the hopes of foiling most address harvesting spam bots. E.g.: 1197 | # 1198 | # foo 1200 | # @example.com 1201 | # 1202 | # Based on a filter by Matthew Wickline, posted to the BBEdit-Talk 1203 | # mailing list: 1204 | # 1205 | 1206 | my $addr = shift; 1207 | 1208 | srand; 1209 | my @encode = ( 1210 | sub { '&#' . ord(shift) . ';' }, 1211 | sub { '&#x' . sprintf( "%X", ord(shift) ) . ';' }, 1212 | sub { shift }, 1213 | ); 1214 | 1215 | $addr = "mailto:" . $addr; 1216 | 1217 | $addr =~ s{(.)}{ 1218 | my $char = $1; 1219 | if ( $char eq '@' ) { 1220 | # this *must* be encoded. I insist. 1221 | $char = $encode[int rand 1]->($char); 1222 | } elsif ( $char ne ':' ) { 1223 | # leave ':' alone (to spot mailto: later) 1224 | my $r = rand; 1225 | # roughly 10% raw, 45% hex, 45% dec 1226 | $char = ( 1227 | $r > .9 ? $encode[2]->($char) : 1228 | $r < .45 ? $encode[1]->($char) : 1229 | $encode[0]->($char) 1230 | ); 1231 | } 1232 | $char; 1233 | }gex; 1234 | 1235 | $addr = qq{$addr}; 1236 | $addr =~ s{">.+?:}{">}; # strip the mailto: from the visible part 1237 | 1238 | return $addr; 1239 | } 1240 | 1241 | 1242 | sub _UnescapeSpecialChars { 1243 | # 1244 | # Swap back in all the special characters we've hidden. 1245 | # 1246 | my $text = shift; 1247 | 1248 | while( my($char, $hash) = each(%g_escape_table) ) { 1249 | $text =~ s/$hash/$char/g; 1250 | } 1251 | return $text; 1252 | } 1253 | 1254 | 1255 | sub _TokenizeHTML { 1256 | # 1257 | # Parameter: String containing HTML markup. 1258 | # Returns: Reference to an array of the tokens comprising the input 1259 | # string. Each token is either a tag (possibly with nested, 1260 | # tags contained therein, such as , or a 1261 | # run of text between tags. Each element of the array is a 1262 | # two-element array; the first is either 'tag' or 'text'; 1263 | # the second is the actual value. 1264 | # 1265 | # 1266 | # Derived from the _tokenize() subroutine from Brad Choate's MTRegex plugin. 1267 | # 1268 | # 1269 | 1270 | my $str = shift; 1271 | my $pos = 0; 1272 | my $len = length $str; 1273 | my @tokens; 1274 | 1275 | my $depth = 6; 1276 | my $nested_tags = join('|', ('(?:<[a-z/!$](?:[^<>]') x $depth) . (')*>)' x $depth); 1277 | my $match = qr/(?s: ) | # comment 1278 | (?s: <\? .*? \?> ) | # processing instruction 1279 | $nested_tags/ix; # nested tags 1280 | 1281 | while ($str =~ m/($match)/g) { 1282 | my $whole_tag = $1; 1283 | my $sec_start = pos $str; 1284 | my $tag_start = $sec_start - length $whole_tag; 1285 | if ($pos < $tag_start) { 1286 | push @tokens, ['text', substr($str, $pos, $tag_start - $pos)]; 1287 | } 1288 | push @tokens, ['tag', $whole_tag]; 1289 | $pos = pos $str; 1290 | } 1291 | push @tokens, ['text', substr($str, $pos, $len - $pos)] if $pos < $len; 1292 | \@tokens; 1293 | } 1294 | 1295 | 1296 | sub _Outdent { 1297 | # 1298 | # Remove one level of line-leading tabs or spaces 1299 | # 1300 | my $text = shift; 1301 | 1302 | $text =~ s/^(\t|[ ]{1,$g_tab_width})//gm; 1303 | return $text; 1304 | } 1305 | 1306 | 1307 | sub _Detab { 1308 | # 1309 | # Cribbed from a post by Bart Lateur: 1310 | # 1311 | # 1312 | my $text = shift; 1313 | 1314 | $text =~ s{(.*?)\t}{$1.(' ' x ($g_tab_width - length($1) % $g_tab_width))}ge; 1315 | return $text; 1316 | } 1317 | 1318 | 1319 | 1; 1320 | 1321 | __END__ 1322 | 1323 | 1324 | =pod 1325 | 1326 | =head1 NAME 1327 | 1328 | B 1329 | 1330 | 1331 | =head1 SYNOPSIS 1332 | 1333 | B [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ] 1334 | [ I ... ] 1335 | 1336 | 1337 | =head1 DESCRIPTION 1338 | 1339 | Markdown is a text-to-HTML filter; it translates an easy-to-read / 1340 | easy-to-write structured text format into HTML. Markdown's text format 1341 | is most similar to that of plain text email, and supports features such 1342 | as headers, *emphasis*, code blocks, blockquotes, and links. 1343 | 1344 | Markdown's syntax is designed not as a generic markup language, but 1345 | specifically to serve as a front-end to (X)HTML. You can use span-level 1346 | HTML tags anywhere in a Markdown document, and you can use block level 1347 | HTML tags (like
    and as well). 1348 | 1349 | For more information about Markdown's syntax, see: 1350 | 1351 | http://daringfireball.net/projects/markdown/ 1352 | 1353 | 1354 | =head1 OPTIONS 1355 | 1356 | Use "--" to end switch parsing. For example, to open a file named "-z", use: 1357 | 1358 | Markdown.pl -- -z 1359 | 1360 | =over 4 1361 | 1362 | 1363 | =item B<--html4tags> 1364 | 1365 | Use HTML 4 style for empty element tags, e.g.: 1366 | 1367 |
    1368 | 1369 | instead of Markdown's default XHTML style tags, e.g.: 1370 | 1371 |
    1372 | 1373 | 1374 | =item B<-v>, B<--version> 1375 | 1376 | Display Markdown's version number and copyright information. 1377 | 1378 | 1379 | =item B<-s>, B<--shortversion> 1380 | 1381 | Display the short-form version number. 1382 | 1383 | 1384 | =back 1385 | 1386 | 1387 | 1388 | =head1 BUGS 1389 | 1390 | To file bug reports or feature requests (other than topics listed in the 1391 | Caveats section above) please send email to: 1392 | 1393 | support@daringfireball.net 1394 | 1395 | Please include with your report: (1) the example input; (2) the output 1396 | you expected; (3) the output Markdown actually produced. 1397 | 1398 | 1399 | =head1 VERSION HISTORY 1400 | 1401 | See the readme file for detailed release notes for this version. 1402 | 1403 | 1.0.1 - 14 Dec 2004 1404 | 1405 | 1.0 - 28 Aug 2004 1406 | 1407 | 1408 | =head1 AUTHOR 1409 | 1410 | John Gruber 1411 | http://daringfireball.net 1412 | 1413 | PHP port and other contributions by Michel Fortin 1414 | http://michelf.com 1415 | 1416 | 1417 | =head1 COPYRIGHT AND LICENSE 1418 | 1419 | Copyright (c) 2003-2004 John Gruber 1420 | 1421 | All rights reserved. 1422 | 1423 | Redistribution and use in source and binary forms, with or without 1424 | modification, are permitted provided that the following conditions are 1425 | met: 1426 | 1427 | * Redistributions of source code must retain the above copyright notice, 1428 | this list of conditions and the following disclaimer. 1429 | 1430 | * Redistributions in binary form must reproduce the above copyright 1431 | notice, this list of conditions and the following disclaimer in the 1432 | documentation and/or other materials provided with the distribution. 1433 | 1434 | * Neither the name "Markdown" nor the names of its contributors may 1435 | be used to endorse or promote products derived from this software 1436 | without specific prior written permission. 1437 | 1438 | This software is provided by the copyright holders and contributors "as 1439 | is" and any express or implied warranties, including, but not limited 1440 | to, the implied warranties of merchantability and fitness for a 1441 | particular purpose are disclaimed. In no event shall the copyright owner 1442 | or contributors be liable for any direct, indirect, incidental, special, 1443 | exemplary, or consequential damages (including, but not limited to, 1444 | procurement of substitute goods or services; loss of use, data, or 1445 | profits; or business interruption) however caused and on any theory of 1446 | liability, whether in contract, strict liability, or tort (including 1447 | negligence or otherwise) arising in any way out of the use of this 1448 | software, even if advised of the possibility of such damage. 1449 | 1450 | =cut 1451 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | The Theos Documentation (theos-ref) 2 | 3 | For generating HTML output: 4 | - Use ./genhtml.sh 5 | 6 | For changing layouting: 7 | - Change theosref.css 8 | 9 | Please contribute to RefMarkup.pl! 10 | 11 | For contributing: 12 | - Please notify theiostream of your intentions. If recommended to contribute, create a fork and make a pull request. 13 | - Regardless of whether your pull request was merged or deleted, your fork should be deleted unless recommended not to by theiostream. 14 | - DO NOT FIX GIT'S WHITESPACE WARNINGS ELSE YOU RISK BREAKING THE LINE BREAK SYSTEM. 15 | 16 | Licensed under the Creative Commons Attribution-ShareAlike 2.0 Generic License (http://creativecommons.org/licenses/by-sa/2.0/). 17 | 18 | (c) 2013 Bacon Publishing, LLC 19 | Daniel Ferreira 20 | Dustin Howett 21 | -------------------------------------------------------------------------------- /RefMarkup.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | ## RefMarkup.pl 4 | ## theosref weird markup parser. 5 | 6 | $text = "\n\n"; 7 | while (<>) { $text .= $_; } 8 | 9 | # [THEOSREF] Change %INDENT% to css indent. 10 | $text =~ s/%INDENT%\n/
    /g; 11 | $text =~ s/\R%INDENTEND%/<\/div>/g; 12 | 13 | # Fix %CODE% 14 | $text =~ s/%CODE%\R/
    /g; 15 | $text =~ s/\R%CODEEND%/<\/code><\/div>/g; 16 | 17 | # [THEOSREF] %R%/%L% shit. 18 | $text =~ s/%R%/read-only<\/span>/g; 19 | $text =~ s/%S%/system<\/span>/g; 20 | $text =~ s/%C%/command-line<\/span>/g; 21 | $text =~ s/%L%/local<\/span>/g; 22 | $text =~ s/%D%/deprecated<\/span>/g; 23 | 24 | print $text; 25 | -------------------------------------------------------------------------------- /core.css: -------------------------------------------------------------------------------- 1 | @import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,200italic,300,600|Anonymous+Pro:400,700,400italic); 2 | 3 | body { 4 | font-family: 'Source Sans Pro', calibri, helvetica, "sans serif"; 5 | font-weight: 200; 6 | } 7 | body strong { 8 | font-weight: 600; 9 | } 10 | 11 | h1, h2, h3, h4, h5 { font-weight: 300; } 12 | 13 | h3 { font-size: 20px; } 14 | h4 { font-size: 18px; } 15 | h6 { 16 | font-family: 'Anonymous Pro', monospace; 17 | font-size: 16px; 18 | } 19 | 20 | code { 21 | font-family: 'Anonymous Pro', monospace; 22 | font-size: 10pt; 23 | margin: .15em; 24 | padding: .15em; 25 | background-color: #dddddd; 26 | border: 1px solid #bbbbbb; 27 | border-radius: 5px; 28 | -moz-border-radius: 5px; 29 | -webkit-border-radius: 5px; 30 | -o-border-radius: 5px; 31 | } 32 | 33 | code strong { 34 | font-weight: 700; 35 | } 36 | 37 | code span.required, code span.optional { 38 | font-size: 10pt !important; 39 | } 40 | 41 | span.deprecated, span.scope, span.readonly { 42 | padding-left: .4em; 43 | padding-right: .4em; 44 | font-size: 9pt; 45 | border-radius: 10px; 46 | -moz-border-radius: 10px; 47 | -webkit-border-radius: 10px; 48 | -o-border-radius: 10px; 49 | border: 1px solid; 50 | 51 | font-family: 'Source Sans Pro', calibri, helvetica, "sans serif"; 52 | font-weight: 200; 53 | } 54 | 55 | span.deprecated { 56 | background-color: #ffcccc; 57 | border-color: #cc0000; 58 | font-weight: bold; 59 | } 60 | 61 | span.scope { 62 | background-color: #ffffcc; 63 | border-color: #dddd00; 64 | font-style: italic; 65 | } 66 | 67 | span.readonly { 68 | background-color: #ffddaa; 69 | border-color: #ffa500; 70 | font-weight: bold; 71 | font-style: italic; 72 | } 73 | 74 | div.indent { 75 | margin-left: 1em; 76 | padding-left: 1em; 77 | border-left: 1px dashed #dddddd; 78 | } 79 | 80 | code span.comment { 81 | font-weight: bold; 82 | color: #00007f; 83 | } 84 | 85 | code span.string { 86 | font-weight: bold; 87 | color: #7f0000; 88 | } 89 | 90 | code span.variable { 91 | font-weight: bold; 92 | color: #007f00; 93 | } 94 | 95 | /* 96 | code.lvalue.readonly { 97 | border-color: #cc0000; 98 | } 99 | 100 | code.lvalue.readwrite { 101 | border-color: #00cc00; 102 | } 103 | */ 104 | -------------------------------------------------------------------------------- /genhtml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -d "./output" ]; then mkdir output; fi 4 | 5 | for x in *.md; do ./Markdown.pl $x | ./RefMarkup.pl > output/$x.html; done 6 | -------------------------------------------------------------------------------- /theosref.css: -------------------------------------------------------------------------------- 1 | @import url("./core.css"); 2 | 3 | body { 4 | /* we need this so the printed version won't have issues */ 5 | margin-left: 5%; 6 | } 7 | 8 | ul { 9 | margin-left: -12px; 10 | } 11 | 12 | h6 { 13 | margin-bottom: -15px; 14 | } 15 | -------------------------------------------------------------------------------- /theosref_legacy.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | #### Handling targets 4 | ###### TARGET 5 | Define the target, SDK version and deployment target for the project.
    6 | For usage/defaulting, refer to the **Platforms / Targets** section of this document. 7 | 8 | ###### ARCHS 9 | Define the architecture(s) which to build to.
    10 | For usage/defaulting, refer to the **Platforms / Targets** section of this document. 11 | 12 | ###### SYSROOT 13 | Manually define the path to the sysroot for cross-compiling.
    14 | For usage/defaulting, refer to the **Platforms / Targets** section of this document. 15 | 16 | ###### SDKBINPATH 17 | Manually define the path to build tools on iPhone and Linux platforms.
    18 | For usage/defaulting, refer to the **Platforms / Targets** section of this document. 19 | 20 | ###### SDKTARGET 21 | Manually define the prefix for iPhone-related cross-compiling tools on iPhone and Linux platforms.
    22 | For usage/defaulting, refer to the **Platforms / Targets** section of this document. 23 | 24 | #### Handling paths to building executables 25 | ###### TARGET_STRIP 26 | ###### TARGET\_STRIP_FLAGS 27 | ###### TARGET\_CODESIGN_ALLOCATE 28 | ###### TARGET_CODESIGN 29 | ###### TARGET\_CODESIGN_FLAGS 30 | 31 | ### Local Variables 32 | Local variables scope on the current Make instance, yet are not shared through Sub-make instances, unlike System Variables. 33 | 34 | Although, with the use of the `export` directive from Make, those variables will be shared through every sub-make. For more information on the topic, refer to [Sending Variables to a sub-make instance](http://www.gnu.org/software/make/manual/make.html#Variables_002fRecursion) on the Make manual. 35 | 36 | If one of these are passed in as **command-line variables**, they will also scope for sub-make instances, going against the concept of a local variable. Even not possible at times, the use of variables specifically designed for command-line use are preferred over their local equivalents when defining them from an invocation to the `make` tool. 37 | 38 | #### Setting schemas 39 | - SCHEMA 40 | Special variable. 41 | Check the "Schemas" section. 42 | 43 | ### Command-line Variables 44 | These variables, worth for project-wide (as System Variables) are meant to be **specifically** passed as command-line arguments to `make`. 45 | 46 | For the section regarding passing such arguments, check http://www.gnu.org/software/make/manual/make.html#Overriding 47 | 48 | #### Providing additional flags for build programs. 49 | These variables have no default values. 50 | 51 | - CFLAGS 52 | Additional flags to be passed to the C and C++ compiler every compilation inside the project. 53 | 54 | - CCFLAGS 55 | Additional flags to be passed to the C++ compiler every compilation inside the project. 56 | 57 | - OBJCFLAGS 58 | Additional flags to be passed to the Objective-C and Objective-C++ compiler every compilation inside the project. 59 | 60 | - OBJCCFLAGS 61 | Additional flags to be passed to the Objective-C++ compiler every compilation inside the project. 62 | 63 | - LDFLAGS 64 | Additional flags to be passed to the linker every link process inside the project. 65 | 66 | - LOGOSFLAGS 67 | Additional flags to be passed to the Logos Preprocessor when ran inside the project. 68 | (check the "Logos" document for more information) 69 | 70 | #### Install-related variables 71 | - THEOS_DEVICE_IP 72 | The IP to where the `make install` rule should transfer the produced Debian package through `make package` to. 73 | For more details on the `make install` rule, verify the "Built-in Rules" section. 74 | 75 | It defaults to nothing. 76 | 77 | #### Making the build process verbose 78 | - messages 79 | Does not filter build process messages from stdout. 80 | Takes either "yes" or "no", respectively whether to print messages or not. 81 | 82 | It defaults to "no". 83 | 84 | #### Setting schemas 85 | - schema 86 | Special variable. 87 | Check the "Schemas" section. 88 | 89 | ### Schemas 90 | Schemas' scope are local: just as Local Variables (they are valid for the project, but not for subprojects). 91 | 92 | Through the SCHEMA or schema variables and other definitions, schemas are a nice way of dynamically setting Theos behaviour such as appending compiler/linker flags, setting subprojects, etc. 93 | 94 | Schemas are enabled through a definition at the SCHEMA or schema variables. 95 | Example: SCHEMA = awesome cool (here schemas "awesome" and "cool" are enabled) 96 | 97 | In some cases Theos looks for variables under enabled schemas. If looking for "X", it'll run over enabled schemas to find "X". 98 | 99 | Let's say we have To find "X" under "AWESOME" – a currently enabled schema –, Theos will look for a variable named "AWESOME.X" defined. 100 | 101 | Example: 102 | # A case where Theos requires schemas is when asking for additional compiler flags. 103 | # Here, it would find the enabled schema "awesome". 104 | # Then it would use an internal function to find "CFLAGS" under enabled schemas. 105 | # On our case, since "awesome" is enabled it'll find "awesome.CFLAGS"... 106 | # ...which we declare here 107 | 108 | awesome.CFLAGS = -DAWESOME 109 | SCHEMA = awesome 110 | 111 | Under enabled schemas, the following possibilities can be searched (whereas x is an enabled schema): 112 | - x.SUBPROJECTS 113 | 114 | ### Private Variables 115 | Theos contains private/internal variables which are not documented here. As much as they may seem public and undocumented, *they are private*. 116 | 117 | You are, of course, able to set them anyway. Although you should hear what Dustin has to say about it: 118 | [22:46:27] <@DHowett> [...] internal, not public. setting it directly splodes things 119 | 120 | Yes, **splodes** (like, KABOOM). Pretty bad, huh? 121 | 122 | ## Instances 123 | 124 | ## Platforms / Targets 125 | ### Fundamentals 126 | The whole process of finding the correct SDK and setting the right target serves a more noble and important purpose: To define the sysroot and the sdkbinpath for building your software. 127 | 128 | The SYSROOT is an absolute path which can be specified to the compiler through the --sysroot or -isysroot compiler flags. It is an absolute path to gather libraries, frameworks and headers for building. 129 | When building natively, the sysroot is the system root directory (/), from where we are able to track linkable libraries, frameworks or headers, in places such as /usr/lib. 130 | When building for another platform – on our case, the iPhone – there is a SDK, which works basically as a sysroot for this device outside it! So we can link to frameworks, libraries and headers from the iPhone specifically, located in places such as SYSROOT/usr/lib. 131 | That makes it possible building for the platform outside it. This is called cross-compiling. 132 | 133 | The SDKBINPATH is a path where tools for cross-compiling can be found, such as the actual cross-compiler (which will compile stuff with iPhone stuff to build iPhone stuff), a linker, etc. Basically a whole development tool suite for a platform inside another platform. 134 | 135 | The next section will cover how Theos handles such things by default and how you can make Theos adapt specifically for your needs to find such things. 136 | 137 | #### Targets 138 | A target is, in theos, one of the following: 139 | - iphone (build for the iPhone) 140 | - macosx (build for Mac OSX) 141 | - simulator (build for the iPhone Simulator) 142 | - native (build for the platform Theos is currently running at) 143 | The default target is always "iphone". 144 | 145 | #### SDK Version 146 | The SDK version is used to define the target's SDK to use when building. 147 | If there are multiple SDK version in the SDK path, through the version inserted here it'll be able to decide which SDK specifically it'll use as a sysroot. 148 | 149 | #### Deployment target 150 | The deployment target defines how far back can your software run. If, for instance, the deployment target is iOS 4.3, it won't be run-able on older iOS versions. 151 | 152 | ### Building for the iPhone 153 | #### Finding the SDK 154 | Through these three values, it is possible to define the location of the SDK. 155 | - On Linux the SDK is assumed to be at /opt/iphone-sdk-3.0/sysroot. 156 | - On the iPhone the SDK is assumed to be at /var/sdk. It is not able to use the actual system root as the sysroot for building since Apple compressed all of linkable frameworks on the iOS filesystem on the dyld shared cache. 157 | - On OSX it'll use xcode-select(1) and xcrun(1) to define the iPhone SDK path and through text processing will force in the value inserted inside TARGET. If none of them are set, will get the latest one. 158 | 159 | #### Finding build tools 160 | And it is also possible to define the tools to use: 161 | - On OSX xcrun(1) is used to define the location of these tools. 162 | - On the iPhone the tools located at /usr/bin prefixed under SDKTARGET will be used. 163 | - On Linux the tools located at /opt/iphone-sdk-3.0/prefix/bin prefixed under SDKTARGET will be used. 164 | On both cases SDKTARGET defaults to "arm-apple-darwin9". 165 | 166 | On Linux or on the iPhone platform, you may use the SDKBINPATH variable to define the path of these tools, to be found alongside SDKTARGET. 167 | The path to these tools may also be specified in variables documented under "Binary Variables" under "System Variables" under "Variables". 168 | 169 | #### Setting Values 170 | The TARGET variable defines the target for the project to be built and can optionally set SDK version and deployment target for the software. 171 | 172 | For target iphone, it is defined as: 173 | TARGET = iphone (sets iPhone target) 174 | TARGET = :sdkversion: (sets only SDK version; valid as "iphone" is the default target) 175 | TARGET = ::deploymenttarget (sets only deployment target; valid as "iphone" is the default target) 176 | TARGET = iphone:sdkversion (sets iPhone target and SDK version) 177 | TARGET = iphone::deploymenttarget (sets iPhone target and deployment target) 178 | TARGET = iphone:sdkversion:deploymenttarget (sets iPhone target and other values) 179 | 180 | If the level of control for picking the SDK/Bin Path is not enough through the TARGET variable, it is possible to manually set the following variables: 181 | 182 | - SYSROOT 183 | The sysroot for cross-compiling. 184 | For information on defaulting, refer to "Finding the SDK". 185 | 186 | - SDKBINPATH 187 | On the iPhone and Linux, the path to look for command-line tools related to cross-compiling. 188 | For information on defaulting, refer to "Finding build tools". 189 | 190 | - SDKTARGET (not related to TARGET whatsoever) 191 | On the iPhone and Linux, defaulting to "arm-apple-darwin9", is used as a prefix for command-line tools specific to cross-compiling for the iPhone. It can be set to change that specific prefix. 192 | For more details and information on defaulting, refer to "Finding build tools". 193 | 194 | #### Architectures 195 | There are certain limitations when picking the architecture for building on the iPhone. It depends mostly on the deployment target it requires or SDK limitations. 196 | 197 | Relying on the deployment target defined within TARGET and assumed to be !!WHAT IS IT TO BE ASSUMED?!!, the following architectures are defined for building: 198 | - Builds for (armv7, armv7s) when targeting 6.0+ 199 | - Builds for (armv6, armv7) when targeting 3.0+ 200 | - Builds for (armv6) when targeting 2.0+ 201 | 202 | The following SDK limitation applies: 203 | - When building with SDK 6.0, deploying for 4.3- is forbidden and will have Theos throw an error. !! DOES THE SAME APPLY TO ARMV6? !! 204 | 205 | ### Building natively for Linux 206 | When building for Linux, the TARGET variable allows the following formation: 207 | 208 | TARGET = linux: 209 | whereas is the prefix for build tools such as cc and ld, placed there for cross-compiling purposes. 210 | 211 | Examples: 212 | TARGET = linux (sets Linux as Theos Target and build tools are looked for without prefixes) 213 | TARGET = linux:arm-none-eabi (sets Linux as Theos target and build tools are looked for with the "arm-none-eabi" prefix. When looking for gcc(1) for instance, "arm-none-eabi-gcc" shall be found. 214 | 215 | ### Building natively for OSX 216 | #### Targeting 217 | When building for OSX, the TARGET variable allows the following formation: 218 | 219 | TARGET = macosx: 220 | 221 | Examples: 222 | TARGET = macosx 223 | TARGET = macosx:10.5 (builds for OSX, and does not allow the program to be run on OSX versions < 10.5) 224 | 225 | #### Architectures 226 | To define the architectures to build for on OSX, define the ARCHS variable: 227 | 228 | ARCHS = i386 (build solely for i386) 229 | ARCHS = i386 x86_64 (build for i386 and x86_64) 230 | 231 | The default of this variable when building for OSX is always "i386 x86_64". 232 | 233 | -- This document was created by Daniel Ferreira (theiostream), alongside the awesome advice from Dustin Howett (DHowett) and, as always thanks to Max Shavrick (Maximus). 234 | It was composed by referencing Theos' source code, the former document on Theos at http://uv.howett.net/ipf.html and Dustin's awesome talks on IRC (:P). --------------------------------------------------------------------------------