├── .gitignore
├── .travis.yml
├── Common.mk
├── Demo
├── Build
│ ├── Debug
│ │ ├── Intermediates
│ │ │ └── .gitignore
│ │ └── Products
│ │ │ └── .gitignore
│ └── Release
│ │ ├── Intermediates
│ │ └── .gitignore
│ │ └── Products
│ │ └── .gitignore
├── Foo
│ ├── Info.plist
│ ├── include
│ │ ├── Foo.h
│ │ └── Foo
│ │ │ └── Hello.h
│ └── source
│ │ └── Hello.c
└── Makefile
├── Platform
├── Linux.mk
└── OSX.mk
├── README.md
└── Targets.mk
/.gitignore:
--------------------------------------------------------------------------------
1 | # Mac Finder
2 | .DS_Store
3 | .Trashes
4 | Icon?
5 |
6 | # Thumbnails
7 | ._*
8 |
9 | # Files that might appear on external disk
10 | .Spotlight-V100
11 | .Trashes
12 |
13 | # Xcode
14 | *.pbxuser
15 | *.mode1v3
16 | *.mode2v3
17 | *.perspectivev3
18 | *.xccheckout
19 | !default.pbxuser
20 | !default.mode1v3
21 | !default.mode2v3
22 | !default.perspectivev3
23 | xcuserdata
24 | default.profraw
25 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: c
2 | compiler: clang
3 | script: cd Demo && make
4 |
--------------------------------------------------------------------------------
/Common.mk:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # The MIT License (MIT)
3 | #
4 | # Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #-------------------------------------------------------------------------------
24 |
25 | # Default target
26 | .DEFAULT_GOAL := all
27 |
28 | #-------------------------------------------------------------------------------
29 | # Build type
30 | #-------------------------------------------------------------------------------
31 |
32 | # Checks if we're on OS-X to determine the build type
33 | ifeq ($(findstring Darwin, $(shell uname)),)
34 | BUILD_TYPE := linux
35 | else
36 | BUILD_TYPE := os-x
37 | endif
38 |
39 | # Host architecture
40 | HOST_ARCH := $(shell uname -m)
41 |
42 | #-------------------------------------------------------------------------------
43 | # Commands
44 | #-------------------------------------------------------------------------------
45 |
46 | MAKE := make -s
47 | SHELL := /bin/bash
48 | _CC = $(CC) $(FLAGS_WARN) -fPIC -$(FLAGS_OPTIM) $(FLAGS_OTHER) -I$(DIR_INC)
49 |
50 | # C compiler - Debug mode
51 | ifneq ($(findstring 1,$(DEBUG)),)
52 | _CC += -DDEBUG=1
53 | _CC += -g
54 | endif
55 |
56 | #-------------------------------------------------------------------------------
57 | # Tools
58 | #-------------------------------------------------------------------------------
59 |
60 | # Make version (version 4 allows parallel builds with output sync)
61 | MAKE_VERSION_MAJOR := $(shell echo $(MAKE_VERSION) | cut -f1 -d.)
62 | MAKE_4 := $(shell [ $(MAKE_VERSION_MAJOR) -ge 4 ] && echo true)
63 |
64 | # Check for the xctool utility
65 | XCTOOL := $(shell which xctool 2>/dev/null)
66 | HAS_XCTOOL := $(shell if [ -f "$(XCTOOL)" ]; then echo true; else echo false; fi )
67 |
68 | # Check for the xcodebuild utility
69 | XCBUILD := $(shell which xcodebuild 2>/dev/null)
70 | HAS_XCBUILD := $(shell if [ -f "$(XCBUILD)" ]; then echo true; else echo false; fi )
71 |
72 | ifeq ($(HAS_XCBUILD),true)
73 | MAC_TARGET := $(shell $(XCBUILD) -showsdks | grep macosx | tail -1 | perl -pe 's/[^-]+-sdk [^0-9]+(.*)/\1/g')
74 | IOS_SDK := $(shell $(XCBUILD) -showsdks | grep iphoneos | tail -1 | perl -pe 's/[^-]+-sdk [^0-9]+(.*)/\1/g')
75 | IOS_SDK_PATH := /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(IOS_SDK).sdk
76 | XCODE_SDK_VALUE := "$(shell /usr/libexec/PlistBuddy -c "Print $(1)" /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist)"
77 | endif
78 |
79 | #-------------------------------------------------------------------------------
80 | # Paths
81 | #-------------------------------------------------------------------------------
82 |
83 | # Root build directory (debug or release)
84 | ifeq ($(findstring 1,$(DEBUG)),)
85 | DIR_BUILD := Build/Release/
86 | else
87 | DIR_BUILD := Build/Debug/
88 | endif
89 |
90 | # Relative build directories
91 | DIR_BUILD_PRODUCTS := $(DIR_BUILD)Products/
92 | DIR_BUILD_TEMP := $(DIR_BUILD)Intermediates/
93 | DIR_BUILD_TESTS := $(DIR)Build/Tests/
94 |
95 | # Erases implicit rules
96 | .SUFFIXES:
97 |
98 | #-------------------------------------------------------------------------------
99 | # Display
100 | #-------------------------------------------------------------------------------
101 |
102 | # Terminal colors
103 | COLOR_NONE := "\x1b[0m"
104 | COLOR_GRAY := "\x1b[30;01m"
105 | COLOR_RED := "\x1b[31;01m"
106 | COLOR_GREEN := "\x1b[32;01m"
107 | COLOR_YELLOW := "\x1b[33;01m"
108 | COLOR_BLUE := "\x1b[34;01m"
109 | COLOR_PURPLE := "\x1b[35;01m"
110 | COLOR_CYAN := "\x1b[36;01m"
111 |
112 | #-------------------------------------------------------------------------------
113 | # Functions
114 | #-------------------------------------------------------------------------------
115 |
116 | # Gets every C file in a specific source directory
117 | #
118 | # @1: The directory with the source files
119 | GET_C_FILES = $(foreach _DIR,$(1), $(wildcard $(_DIR)*$(EXT_C)))
120 |
121 | # Gets every C++ file in a specific source directory
122 | #
123 | # @1: The directory with the source files
124 | GET_CPP_FILES = $(foreach _DIR,$(1), $(wildcard $(_DIR)*$(EXT_CPP)))
125 |
126 | # Gets every Objective-C file in a specific source directory
127 | #
128 | # @1: The directory with the source files
129 | GET_M_FILES = $(foreach _DIR,$(1), $(wildcard $(_DIR)*$(EXT_M)))
130 |
131 | # Gets every Objective-C++ file in a specific source directory
132 | #
133 | # @1: The directory with the source files
134 | GET_MM_FILES = $(foreach _DIR,$(1), $(wildcard $(_DIR)*$(EXT_MM)))
135 |
136 | # Gets an SDK value from Xcode
137 | #
138 | # @1: The key for which to get the SDK value
139 | XCODE_SDK_VALUE = "$(shell /usr/libexec/PlistBuddy -c "Print $(1)" /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist)"
140 |
141 | # Prints a message about a file
142 | #
143 | # @1: The first message part
144 | # @2: The architecture
145 | # @3: The file
146 | PRINT_FILE = $(call PRINT,$(1),$(2),$(subst /,.,$(subst ./,,$(dir $(3))))"$(COLOR_GRAY)"$(notdir $(3))"$(COLOR_NONE)")
147 |
148 | # Prints a message
149 | #
150 | # @1: The first message part# @2: The architecture
151 | # @3: The second message part
152 | ifeq ($(findstring 1,$(DEBUG)),)
153 | PRINT = "["$(COLOR_GREEN)" $(PRODUCT) "$(COLOR_NONE)"]> $(1) [ "$(COLOR_CYAN)"Release - $(2)"$(COLOR_NONE)" ]: "$(COLOR_YELLOW)"$(3)"$(COLOR_NONE)
154 | else
155 | PRINT = "["$(COLOR_GREEN)" $(PRODUCT) "$(COLOR_NONE)"]> $(1) [ "$(COLOR_CYAN)"Debug - $(2)"$(COLOR_NONE)" ]: "$(COLOR_YELLOW)"$(3)"$(COLOR_NONE)
156 | endif
157 |
158 | #-------------------------------------------------------------------------------
159 | # Includes
160 | #-------------------------------------------------------------------------------
161 |
162 | __DIR__ := $(dir $(lastword $(MAKEFILE_LIST)))
163 |
164 | ifeq ($(BUILD_TYPE),os-x)
165 | include $(__DIR__)/Platform/OSX.mk
166 | else
167 | include $(__DIR__)/Platform/Linux.mk
168 | endif
169 |
--------------------------------------------------------------------------------
/Demo/Build/Debug/Intermediates/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/Demo/Build/Debug/Products/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/Demo/Build/Release/Intermediates/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/Demo/Build/Release/Products/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/Demo/Foo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.xs-labs.Foo
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | NSHumanReadableCopyright
26 | Copyright © 2015 XS-Labs. All rights reserved.
27 | NSPrincipalClass
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Demo/Foo/include/Foo.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | ******************************************************************************/
24 |
25 | #ifndef __FOO_H__
26 | #define __FOO_H__
27 |
28 | #include
29 |
30 | #endif /* __FOO_H__ */
31 |
--------------------------------------------------------------------------------
/Demo/Foo/include/Foo/Hello.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | ******************************************************************************/
24 |
25 | #ifndef __FOO_HELLO_H__
26 | #define __FOO_HELLO_H__
27 |
28 | void Foo_Hello( void );
29 |
30 | #endif /* __FOO_HELLO_H__ */
31 |
--------------------------------------------------------------------------------
/Demo/Foo/source/Hello.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | ******************************************************************************/
24 |
25 | #include
26 | #include
27 |
28 | void Foo_Hello( void )
29 | {
30 | printf( "hello, world\n" );
31 | }
32 |
--------------------------------------------------------------------------------
/Demo/Makefile:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # The MIT License (MIT)
3 | #
4 | # Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #-------------------------------------------------------------------------------
24 |
25 | include ../Common.mk
26 |
27 | PRODUCT := Foo
28 | PRODUCT_LIB := libFoo
29 | PRODUCT_DYLIB := libFoo
30 | PRODUCT_FRAMEWORK := Foo
31 | PREFIX_DYLIB := /usr/local/lib/
32 | PREFIX_FRAMEWORK := /Library/Frameworks/
33 | DIR_INC := Foo/include/
34 | DIR_SRC := Foo/source/
35 | DIR_RES := Foo/
36 | DIR_TESTS :=
37 | EXT_C := .c
38 | EXT_CPP := .cpp
39 | EXT_M := .m
40 | EXT_MM := .mm
41 | EXT_H := .h
42 | FILES := $(call GET_C_FILES, $(DIR_SRC))
43 | FILES_TESTS := $(call GET_C_FILES, $(DIR_TESTS))
44 | CC := clang
45 | LIBS :=
46 | FLAGS_OPTIM := Os
47 | FLAGS_WARN := -Werror -Wall
48 | FLAGS_STD_C := c99
49 | FLAGS_STD_CPP := c++11
50 | FLAGS_OTHER :=
51 |
52 | include ../Targets.mk
53 |
--------------------------------------------------------------------------------
/Platform/Linux.mk:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # The MIT License (MIT)
3 | #
4 | # Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #-------------------------------------------------------------------------------
24 |
25 | #-------------------------------------------------------------------------------
26 | # File suffixes
27 | #-------------------------------------------------------------------------------
28 |
29 | # File extensions
30 | EXT_O := .o
31 | EXT_LIB := .a
32 | EXT_DYLIB := .so
33 |
34 | #-------------------------------------------------------------------------------
35 | # Products and architectures to build
36 | #-------------------------------------------------------------------------------
37 |
38 | PRODUCTS = $(PRODUCT_LIB)$(EXT_LIB)|$(HOST_ARCH) \
39 | $(PRODUCT_DYLIB)$(EXT_DYLIB)|$(HOST_ARCH)
40 |
41 | #-------------------------------------------------------------------------------
42 | # Tools
43 | #-------------------------------------------------------------------------------
44 |
45 | LD := ld
46 | AR := ar
47 |
48 | #-------------------------------------------------------------------------------
49 | # Commands configuration
50 | #-------------------------------------------------------------------------------
51 |
52 | # Architecture specific flags for ld
53 | LD_FLAGS_$(HOST_ARCH) := -m elf_$(HOST_ARCH)
54 |
55 | # Architecture specific flags for ar
56 | AR_FLAGS_$(HOST_ARCH) := rcs
57 |
58 | # Architecture specific flags for the C compiler
59 | CC_FLAGS_$(HOST_ARCH) :=
60 |
61 | # Architecture specific flags for the C compiler when creating a dynamic library
62 | CC_FLAGS_DYLIB_$(HOST_ARCH) = -shared -Wl,-soname,$(PRODUCT_DYLIB)$(EXT_DYLIB)
63 |
--------------------------------------------------------------------------------
/Platform/OSX.mk:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # The MIT License (MIT)
3 | #
4 | # Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #-------------------------------------------------------------------------------
24 |
25 | #-------------------------------------------------------------------------------
26 | # File suffixes
27 | #-------------------------------------------------------------------------------
28 |
29 | # File extensions
30 | EXT_O := .o
31 | EXT_LIB := .a
32 | EXT_DYLIB := .dylib
33 | EXT_FRAMEWORK := .framework
34 |
35 | #-------------------------------------------------------------------------------
36 | # Products and architectures to build
37 | #-------------------------------------------------------------------------------
38 |
39 | ifeq ($(BUILD_LEGACY_ARCHS),1)
40 |
41 | PRODUCTS = $(PRODUCT_LIB)$(EXT_LIB)|i386|x86_64|armv7|armv7s|arm64 \
42 | $(PRODUCT_DYLIB)$(EXT_DYLIB)|i386|x86_64 \
43 | $(PRODUCT_FRAMEWORK)$(EXT_FRAMEWORK)|i386|x86_64
44 |
45 | else
46 |
47 | PRODUCTS = $(PRODUCT_LIB)$(EXT_LIB)|x86_64|armv7|armv7s|arm64 \
48 | $(PRODUCT_DYLIB)$(EXT_DYLIB)|x86_64 \
49 | $(PRODUCT_FRAMEWORK)$(EXT_FRAMEWORK)|x86_64
50 |
51 | endif
52 |
53 |
54 |
55 | #-------------------------------------------------------------------------------
56 | # Tools
57 | #-------------------------------------------------------------------------------
58 |
59 | LD := ld
60 | AR := ar
61 |
62 | #-------------------------------------------------------------------------------
63 | # Commands configuration
64 | #-------------------------------------------------------------------------------
65 |
66 | # Architecture specific flags for ld
67 | LD_FLAGS_i386 :=
68 | LD_FLAGS_x86_64 :=
69 | LD_FLAGS_armv7 :=
70 | LD_FLAGS_armv7s :=
71 | LD_FLAGS_arm64 :=
72 |
73 | # Architecture specific flags for ar
74 | AR_FLAGS_i386 := rcs
75 | AR_FLAGS_x86_64 := rcs
76 | AR_FLAGS_armv7 := rcs
77 | AR_FLAGS_armv7s := rcs
78 | AR_FLAGS_arm64 := rcs
79 |
80 | # Architecture specific flags for the C compiler
81 | CC_FLAGS_i386 := -arch i386
82 | CC_FLAGS_x86_64 := -arch x86_64
83 | CC_FLAGS_armv7 := -arch armv7 -isysroot $(IOS_SDK_PATH)
84 | CC_FLAGS_armv7s := -arch armv7s -isysroot $(IOS_SDK_PATH)
85 | CC_FLAGS_arm64 := -arch arm64 -isysroot $(IOS_SDK_PATH)
86 |
87 | # Architecture specific flags for the C compiler when creating a dynamic library
88 | CC_FLAGS_DYLIB_i386 = -dynamiclib -install_name $(PREFIX_DYLIB)$(PRODUCT_DYLIB)$(EXT_DYLIB)
89 | CC_FLAGS_DYLIB_x86_64 = -dynamiclib -install_name $(PREFIX_DYLIB)$(PRODUCT_DYLIB)$(EXT_DYLIB)
90 |
91 | # Architecture specific flags for the C compiler when creating a Mac OS X framework
92 | CC_FLAGS_FRAMEWORK_i386 = -dynamiclib -install_name $(PREFIX_FRAMEWORK)$(PRODUCT_FRAMEWORK)$(EXT_FRAMEWORK) -single_module -compatibility_version 1 -current_version 1
93 | CC_FLAGS_FRAMEWORK_x86_64 = -dynamiclib -install_name $(PREFIX_FRAMEWORK)$(PRODUCT_FRAMEWORK)$(EXT_FRAMEWORK) -single_module -compatibility_version 1 -current_version 1
94 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | makelib
2 | =======
3 |
4 | [](https://travis-ci.org/macmade/makelib)
5 | [](https://github.com/macmade/makelib/issues)
6 | 
7 | 
8 | [](https://twitter.com/macmade)
9 | [](https://patreon.com/macmade)
10 | [](https://www.gratipay.com/macmade)
11 | [](https://paypal.me/xslabs)
12 |
13 | About
14 | -----
15 |
16 | makelib is a generic cross-platform makefile for building C/C++/Objective-C libraries.
17 | Its purpose is to ease the build process of libraries for cross-platform projects.
18 |
19 | ### Available targets by system
20 |
21 | Building on **OSX**, the following files will be produced:
22 |
23 | - **Static library** (`.a`): `i386` `x86_64` `armv7` `armv7s` `arm64`
24 | - **Dynamic library** (`.dylib`): `i386` `x86_64`
25 | - **Mac framework** (`.framework`): `i386` `x86_64`
26 |
27 | On **Linux**:
28 |
29 | - **Static library** (`.a`): host architecture
30 | - **Dynamic library** (`.so`): host architecture
31 |
32 | Note that on OS X builds, ARM libraries are obviously targeted for iOS.
33 |
34 | Configuration
35 | -------------
36 |
37 | ### Recommended project structure
38 |
39 | You may use `makelib` as a submodule of your project.
40 |
41 | You'll need a **build** directory with a specific structure, a directory with **sources**, a directory with **includes** and finally a **Makefile** with configuration options.
42 |
43 | Here's an example project structure:
44 |
45 | Build/ (Build directory)
46 | Debug/ (Files produced by "debug" builds)
47 | Intermediates/ (Debug intermediate object files by architecture)
48 | Products/ (Debug products by architecture)
49 | Release/ (Files produced by "release" builds)
50 | Intermediates/ (Release intermediate object files by architecture)
51 | Products/ (Release products by architecture)
52 | Makefile (Makefile with makelib configuration values)
53 | makelib/ (makelib submodule)
54 | MyProject/ (Project directory)
55 | include/ (Directory with include files)
56 | Info.plist (Info.plist file - Required for building a Mac framework)
57 | source/ (Directory with source files)
58 | tests/ (Directory with unit test files, if any)
59 |
60 | ### Configuration Makefile
61 |
62 | A makefile containing configuration values for makelib is required.
63 | Assuming the previous project structure and a C++ project, this makefile may look like:
64 |
65 | BUILD_LEGACY_ARCHS := 0
66 |
67 | include makelib/Common.mk
68 |
69 | PRODUCT := MyProject
70 | PRODUCT_LIB := libMyProject
71 | PRODUCT_DYLIB := libMyProject
72 | PRODUCT_FRAMEWORK := MyProject
73 | PREFIX_DYLIB := /usr/local/lib/
74 | PREFIX_FRAMEWORK := /Library/Frameworks/
75 | DIR_INC := MyProject/include/
76 | DIR_SRC := MyProject/source/
77 | DIR_RES := MyProject/
78 | DIR_TESTS := MyProject/tests
79 | EXT_C := .c
80 | EXT_CPP := .cpp
81 | EXT_M := .m
82 | EXT_MM := .mm
83 | EXT_H := .h
84 | FILES := $(call GET_CPP_FILES, $(DIR_SRC))
85 | FILES_TESTS := $(call GET_CPP_FILES, $(DIR_TESTS))
86 | CC := clang
87 | LIBS :=
88 | FLAGS_OPTIM := -Os
89 | FLAGS_WARN := -Wall -Werror
90 | FLAGS_STD_C := c99
91 | FLAGS_STD_CPP := c++11
92 | FLAGS_OTHER :=
93 | FLAGS_C :=
94 | FLAGS_CPP :=
95 | FLAGS_M := -fobjc-arc
96 | FLAGS_MM := -fobjc-arc
97 |
98 | include makelib/Targets.mk
99 |
100 | Please read the section below for details about each configuration value.
101 |
102 | #### Configuration values
103 |
104 | **PRODUCT**
105 | The name of your product/project.
106 |
107 | **PRODUCT_LIB**
108 | The name for the generated static library.
109 | Note: always use a `lib` prefix.
110 |
111 | **PRODUCT_DYLIB**
112 | The name for the generated dynamic library.
113 | Note: always use a `lib` prefix.
114 |
115 | **PRODUCT_FRAMEWORK**
116 | The name for the generated Mac framework package.
117 |
118 | **PREFIX_DYLIB**
119 | The directory in which the dynamic library is intended to be installed.
120 |
121 | **PREFIX_FRAMEWORK**
122 | The directory in which the Mac framework is intended to be installed.
123 |
124 | **DIR_INC**
125 | The directory with include files.
126 |
127 | **DIR_SRC**
128 | The directory with source files.
129 |
130 | **DIR_RES**
131 | The directory with resource files, link `Info.plist`.
132 |
133 | **DIR_TESTS**
134 | The directory with unit test files, if any.
135 |
136 | **EXT_C**
137 | The file extension for your C source files (typically `.c`).
138 |
139 | **EXT_CPP**
140 | The file extension for your C++ source files (typically `.cpp`).
141 |
142 | **EXT_M**
143 | The file extension for your Objective-C source files (typically `.m`).
144 |
145 | **EXT_MM**
146 | The file extension for your Objective-C++ source files (typically `.mm`).
147 |
148 | **EXT_H**
149 | The file extension for your header files (`.h`, `.hpp`, etc).
150 |
151 | **FILES**
152 | The project files to compile.
153 | Note that you can use the `GET_C_FILES` function for convenience:
154 |
155 | FILES := $(call GET_C_FILES, some/dir/) $(call GET_C_FILES, some/other/dir/)
156 |
157 | **FILES_TESTS**
158 | The unit test files to compile.
159 | Note that you can use the `GET_C_FILES` function for convenience:
160 |
161 | FILES := $(call GET_C_FILES, some/dir/) $(call GET_C_FILES, some/other/dir/)
162 |
163 | **CC**
164 | The compiler to use (`clang`, `gcc`, `g++`, etc).
165 |
166 | **LIBS**
167 | Any libraries to link with when building the project.
168 | Eg: `-lpthread -lz -lc++`
169 |
170 | **FLAGS_OPTIM**
171 | Optimisation flags for the compiler (`Os`, `O3`, etc).
172 |
173 | **FLAGS_WARN**
174 | Warning flags for the compiler.
175 | Eg: `-Wall -Werror -Wpedantic`
176 |
177 | **FLAGS_STD_C**
178 | The C language standard to use (`c99`, `c11`, etc).
179 |
180 | **FLAGS_STD_CPP**
181 | The C++ language standard to use (`c++11`, `c++14`, etc).
182 |
183 | **FLAGS_OTHER**
184 | Any other flags to pass to the compiler.
185 |
186 | **FLAGS_C**
187 | Specific flags for the C compiler.
188 |
189 | **FLAGS_CPP**
190 | Specific flags for the C++ compiler.
191 |
192 | **FLAGS_M**
193 | Specific flags for the Objective-C compiler.
194 |
195 | **FLAGS_MM**
196 | Specific flags for the Objective-C++ compiler.
197 |
198 | **BUILD_LEGACY_ARCHS**
199 | Builds legacy architectures (eg. i386 on macOS).
200 | Note: define it before including `Common.mk`
201 |
202 | Demo / Example
203 | --------------
204 |
205 | You'll find a working example C project in the `Demo` subdirectory.
206 |
207 | License
208 | -------
209 |
210 | makelib is released under the terms of the MIT license.
211 |
212 | Repository Infos
213 | ----------------
214 |
215 | Owner: Jean-David Gadina - XS-Labs
216 | Web: www.xs-labs.com
217 | Blog: www.noxeos.com
218 | Twitter: @macmade
219 | GitHub: github.com/macmade
220 | LinkedIn: ch.linkedin.com/in/macmade/
221 | StackOverflow: stackoverflow.com/users/182676/macmade
222 |
--------------------------------------------------------------------------------
/Targets.mk:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # The MIT License (MIT)
3 | #
4 | # Copyright (c) 2015 Jean-David Gadina - www-xs-labs.com
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #-------------------------------------------------------------------------------
24 |
25 | #-------------------------------------------------------------------------------
26 | # Search paths
27 | #-------------------------------------------------------------------------------
28 |
29 | # Define the search paths for source files
30 | vpath %$(EXT_C) $(DIR_TESTS)
31 | vpath %$(EXT_CPP) $(DIR_TESTS)
32 | vpath %$(EXT_M) $(DIR_TESTS)
33 | vpath %$(EXT_MM) $(DIR_TESTS)
34 | vpath %$(EXT_C) $(DIR_SRC)
35 | vpath %$(EXT_CPP) $(DIR_SRC)
36 | vpath %$(EXT_M) $(DIR_SRC)
37 | vpath %$(EXT_MM) $(DIR_SRC)
38 |
39 | #-------------------------------------------------------------------------------
40 | # Built-in targets
41 | #-------------------------------------------------------------------------------
42 |
43 | # Declaration for phony targets, to avoid problems with local files
44 | .PHONY: all \
45 | clean \
46 | debug \
47 | release \
48 | products \
49 | test \
50 | test-debug \
51 | _test
52 |
53 | # Declaration for precious targets, to avoid cleaning of intermediate files
54 | .PRECIOUS: $(DIR_BUILD_TEMP)%$(PRODUCT)$(EXT_O) $(DIR_BUILD_TEMP)%$(EXT_C)$(EXT_O) $(DIR_BUILD_TEMP)%$(EXT_CPP)$(EXT_O) $(DIR_BUILD_TEMP)%$(EXT_M)$(EXT_O) $(DIR_BUILD_TEMP)%$(EXT_MM)$(EXT_O)
55 |
56 | #-------------------------------------------------------------------------------
57 | # Common targets
58 | #-------------------------------------------------------------------------------
59 |
60 | # Main Target
61 | all: release debug
62 |
63 | @:
64 |
65 | # Release build (parallel if available)
66 | release:
67 |
68 | ifeq ($(MAKE_4),true)
69 | @$(MAKE) -j 50 --output-sync products
70 | else
71 | @$(MAKE) products
72 | endif
73 |
74 | # Debug build (parallel if available)
75 | debug:
76 |
77 | ifeq ($(MAKE_4),true)
78 | @$(MAKE) -j 50 --output-sync products DEBUG=1
79 | else
80 | @$(MAKE) products DEBUG=1
81 | endif
82 |
83 | # Cleans all build files
84 | clean: _ARCHS = $(foreach _PRODUCT,$(PRODUCTS),$(subst $(firstword $(subst |, ,$(_PRODUCT))),,$(subst |, ,$(_PRODUCT))))
85 | clean: _CLEAN_ARCHS = $(foreach _ARCH,$(_ARCHS),$(addprefix _clean_,$(_ARCH)))
86 | clean:
87 |
88 | @$(MAKE) $(_CLEAN_ARCHS)
89 | @$(MAKE) $(_CLEAN_ARCHS) DEBUG=1
90 |
91 | # Cleans architecture specific files
92 | _clean_%:
93 |
94 | @echo -e $(call PRINT,Cleaning,$*,Cleaning all intermediate files)
95 | @rm -rf $(DIR_BUILD_TEMP)$*
96 |
97 | @echo -e $(call PRINT,Cleaning,$*,Cleaning all product files)
98 | @rm -rf $(DIR_BUILD_PRODUCTS)$*
99 |
100 | # Release test target
101 | test: release
102 |
103 | @$(MAKE) -s _test
104 |
105 | # Debug test target
106 | test-debug: debug
107 |
108 | @$(MAKE) -s _test DEBUG=1
109 |
110 | # Test target
111 | ifeq ($(HAS_XCTOOL),true)
112 |
113 | _test:
114 | @echo -e $(call PRINT,Testing,n/a,Building and running unit tests)
115 | @$(XCTOOL) -project $(XCODE_PROJECT) -scheme "$(XCODE_TEST_SCHEME)" test
116 |
117 | else
118 | ifeq ($(HAS_XCBUILD),true)
119 |
120 | _test:
121 | @echo -e $(call PRINT,Testing,n/a,Building and running unit tests)
122 | @$(XCBUILD) -project $(XCODE_PROJECT) -scheme "$(XCODE_TEST_SCHEME)" test
123 |
124 | else
125 |
126 | _test:
127 |
128 | @:
129 |
130 | endif
131 | endif
132 |
133 | #-------------------------------------------------------------------------------
134 | # Targets with second expansion
135 | #-------------------------------------------------------------------------------
136 |
137 | .SECONDEXPANSION:
138 |
139 | # Products target
140 | products: _PRODUCTS = $(foreach _PRODUCT,$(PRODUCTS),$(foreach _ARCH,$(subst $(firstword $(subst |, ,$(_PRODUCT))),,$(subst |, ,$(_PRODUCT))),$(_ARCH)/$(firstword $(subst |, ,$(_PRODUCT)))))
141 | products: _PRODUCTS_BUILD = $(foreach _PRODUCT,$(_PRODUCTS),$(addprefix $(DIR_BUILD_PRODUCTS),$(_PRODUCT)))
142 | products: $$(_PRODUCTS_BUILD)
143 |
144 | @:
145 |
146 | # Static library target
147 | $(DIR_BUILD_PRODUCTS)%$(EXT_LIB): _ARCH = $(firstword $(subst /, ,$*))
148 | $(DIR_BUILD_PRODUCTS)%$(EXT_LIB): $$(shell mkdir -p $$(dir $$@)) $(DIR_BUILD_TEMP)$$(_ARCH)/$(PRODUCT)$(EXT_O)
149 |
150 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Linking the $(_ARCH) binary)
151 | @$(AR) $(AR_FLAGS_$(_ARCH)) $@ $<
152 |
153 | # Dynamic library target
154 | $(DIR_BUILD_PRODUCTS)%$(EXT_DYLIB): _ARCH = $(firstword $(subst /, ,$*))
155 | $(DIR_BUILD_PRODUCTS)%$(EXT_DYLIB): $$(shell mkdir -p $$(dir $$@)) $(DIR_BUILD_TEMP)$$(_ARCH)/$(PRODUCT)$(EXT_O)
156 |
157 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Linking the $(_ARCH) binary)
158 | @$(CC) $(LIBS) $(CC_FLAGS_DYLIB_$(_ARCH)) $(CC_FLAGS_$(_ARCH)) -o $@ $<
159 |
160 | # Framework target
161 | $(DIR_BUILD_PRODUCTS)%$(EXT_FRAMEWORK): _ARCH = $(firstword $(subst /, ,$*))
162 | $(DIR_BUILD_PRODUCTS)%$(EXT_FRAMEWORK): $$(shell mkdir -p $$(dir $$@)) $(DIR_BUILD_TEMP)$$(_ARCH)/$(PRODUCT)$(EXT_O)
163 |
164 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Creating the directory structure)
165 | @rm -rf $@
166 | @mkdir -p $@/Versions/A/Headers/
167 | @mkdir -p $@/Versions/A/Resources/
168 |
169 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Creating the symbolic links)
170 | @ln -s A/ $@/Versions/Current
171 | @ln -s Versions/A/Headers/ $@/Headers
172 | @ln -s Versions/A/Resources/ $@/Resources
173 | @ln -s Versions/A/$(notdir $(basename $@)) $@/$(notdir $(basename $@))
174 |
175 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Copying the public header files)
176 | @cp -rf $(DIR_INC)$(PRODUCT)$(EXT_H) $@/Versions/A/Headers/
177 | @cp -rf $(DIR_INC)$(PRODUCT)/* $@/Versions/A/Headers/
178 |
179 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Copying the bundle resources)
180 | @:
181 |
182 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Creating the Info.plist file)
183 | @cp -rf $(DIR_RES)Info.plist $@/Versions/A/Resources/Info.plist
184 | plutil -insert BuildMachineOSBuild -string $(shell sw_vers -buildVersion) $@/Versions/A/Resources/Info.plist
185 | plutil -insert DTSDKName -string macosx$(MAC_TARGET) $@/Versions/A/Resources/Info.plist
186 | plutil -insert DTCompiler -string $(call XCODE_SDK_VALUE,DTCompiler) $@/Versions/A/Resources/Info.plist
187 | plutil -insert DTPlatformBuild -string $(call XCODE_SDK_VALUE,DTPlatformBuild) $@/Versions/A/Resources/Info.plist
188 | plutil -insert DTPlatformVersion -string $(call XCODE_SDK_VALUE,DTPlatformVersion) $@/Versions/A/Resources/Info.plist
189 | plutil -insert DTSDKBuild -string $(call XCODE_SDK_VALUE,DTSDKBuild) $@/Versions/A/Resources/Info.plist
190 | plutil -insert DTXcode -string $(call XCODE_SDK_VALUE,DTXcode) $@/Versions/A/Resources/Info.plist
191 | plutil -insert DTXcodeBuild -string $(call XCODE_SDK_VALUE,DTXcodeBuild) $@/Versions/A/Resources/Info.plist
192 |
193 | @echo -e $(call PRINT,$(notdir $@),$(_ARCH),Linking the $(_ARCH) binary)
194 | @$(CC) $(LIBS) $(CC_FLAGS_FRAMEWORK_$(_ARCH)) $(CC_FLAGS_$(_ARCH)) -o $@/Versions/A/$(notdir $(basename $@)) $<
195 |
196 | # Project object file target
197 | $(DIR_BUILD_TEMP)%$(PRODUCT)$(EXT_O): _ARCH = $(subst /,,$*)
198 | $(DIR_BUILD_TEMP)%$(PRODUCT)$(EXT_O): _FILES = $(foreach _FILE,$(FILES),$(patsubst $(DIR_SRC)%,%,$(_FILE)))
199 | $(DIR_BUILD_TEMP)%$(PRODUCT)$(EXT_O): _FILES_OBJ = $(addprefix $*,$(patsubst %$(EXT_C),%$(EXT_C)$(EXT_O),$(patsubst %$(EXT_CPP),%$(EXT_CPP)$(EXT_O),$(patsubst %$(EXT_M),%$(EXT_M)$(EXT_O),$(patsubst %$(EXT_MM),%$(EXT_MM)$(EXT_O),$(_FILES))))))
200 | $(DIR_BUILD_TEMP)%$(PRODUCT)$(EXT_O): _FILES_BUILD = $(addprefix $(DIR_BUILD_TEMP),$(_FILES_OBJ))
201 | $(DIR_BUILD_TEMP)%$(PRODUCT)$(EXT_O): $$(shell mkdir -p $$(dir $$@)) $$(_FILES_BUILD)
202 |
203 | @echo -e $(call PRINT,Linking object files,$(_ARCH),$(notdir $@))
204 | @$(LD) -r $(LD_FLAGS_$(_ARCH)) $(_FILES_BUILD) -o $@
205 |
206 | # Object file target / C
207 | $(DIR_BUILD_TEMP)%$(EXT_C)$(EXT_O): _ARCH = $(firstword $(subst /, ,$(subst $(DIR_BUILD_TEMP),,$@)))
208 | $(DIR_BUILD_TEMP)%$(EXT_C)$(EXT_O): _FILE = $(subst $(_ARCH)/,,$*)$(EXT_C)
209 | $(DIR_BUILD_TEMP)%$(EXT_C)$(EXT_O): $$(shell mkdir -p $$(dir $$@)) $$(_FILE)
210 |
211 | @echo -e $(call PRINT_FILE,"Compiling C file",$(_ARCH),$(_FILE))
212 | @$(_CC) $(CC_FLAGS_$(_ARCH)) -std=$(FLAGS_STD_C) $(FLAGS_C) -o $@ -c $(addprefix $(DIR_SRC),$(_FILE))
213 |
214 | # Object file target / C++
215 | $(DIR_BUILD_TEMP)%$(EXT_CPP)$(EXT_O): _ARCH = $(firstword $(subst /, ,$(subst $(DIR_BUILD_TEMP),,$@)))
216 | $(DIR_BUILD_TEMP)%$(EXT_CPP)$(EXT_O): _FILE = $(subst $(_ARCH)/,,$*)$(EXT_CPP)
217 | $(DIR_BUILD_TEMP)%$(EXT_CPP)$(EXT_O): $$(shell mkdir -p $$(dir $$@)) $$(_FILE)
218 |
219 | @echo -e $(call PRINT_FILE,"Compiling C++ file",$(_ARCH),$(_FILE))
220 | @$(_CC) $(CC_FLAGS_$(_ARCH)) -std=$(FLAGS_STD_CPP) $(FLAGS_CPP) -o $@ -c $(addprefix $(DIR_SRC),$(_FILE))
221 |
222 | # Object file target / Objective-C
223 | $(DIR_BUILD_TEMP)%$(EXT_M)$(EXT_O): _ARCH = $(firstword $(subst /, ,$(subst $(DIR_BUILD_TEMP),,$@)))
224 | $(DIR_BUILD_TEMP)%$(EXT_M)$(EXT_O): _FILE = $(subst $(_ARCH)/,,$*)$(EXT_M)
225 | $(DIR_BUILD_TEMP)%$(EXT_M)$(EXT_O): $$(shell mkdir -p $$(dir $$@)) $$(_FILE)
226 |
227 | @echo -e $(call PRINT_FILE,"Compiling Objective-C file",$(_ARCH),$(_FILE))
228 | @$(_CC) $(CC_FLAGS_$(_ARCH)) -std=$(FLAGS_STD_C) $(FLAGS_M) -o $@ -c $(addprefix $(DIR_SRC),$(_FILE))
229 |
230 | # Object file target / Objective-C++
231 | $(DIR_BUILD_TEMP)%$(EXT_MM)$(EXT_O): _ARCH = $(firstword $(subst /, ,$(subst $(DIR_BUILD_TEMP),,$@)))
232 | $(DIR_BUILD_TEMP)%$(EXT_MM)$(EXT_O): _FILE = $(subst $(_ARCH)/,,$*)$(EXT_MM)
233 | $(DIR_BUILD_TEMP)%$(EXT_MM)$(EXT_O): $$(shell mkdir -p $$(dir $$@)) $$(_FILE)
234 |
235 | @echo -e $(call PRINT_FILE,"Compiling Objective-C++ file",$(_ARCH),$(_FILE))
236 | @$(_CC) $(CC_FLAGS_$(_ARCH)) -std=$(FLAGS_STD_CPP) $(FLAGS_MM) -o $@ -c $(addprefix $(DIR_SRC),$(_FILE))
237 |
--------------------------------------------------------------------------------