Commit 2b1e8a36dbbe5083d41096fcc97abe353aec0f64
0 parents
Initial commit
Showing
27 changed files
with
2318 additions
and
0 deletions
certs/README.md
0 → 100644
1 | +++ a/certs/README.md | ||
1 | +# Demo Certificates | ||
2 | + | ||
3 | +This directory contains certificates used by the clients and servers in our | ||
4 | +sample programs. These certificates are for testing purposes only and should | ||
5 | +**never** be used in a production environment. | ||
6 | + | ||
7 | +As provided, the server certificates use `127.0.0.1` for the Common Name, the | ||
8 | +IP address and DNS name. This works fine when you run the client and server on | ||
9 | +the same host. However, if you want to run them on separate hosts, you may need | ||
10 | +to regenerate the certificates. (This is especially true for the JavaScript | ||
11 | +examples.) | ||
12 | + | ||
13 | +We've included the Python script `makedemocerts.py` to simplify this task. | ||
14 | + | ||
15 | +## Prerequisites | ||
16 | + | ||
17 | +You'll need Python to run the script. The script also depends on a utility | ||
18 | +package from a separate [ZeroC repository][1]. You can install this package as | ||
19 | +follows: | ||
20 | + | ||
21 | +``` | ||
22 | +pip install zeroc-icecertutils | ||
23 | +``` | ||
24 | + | ||
25 | +## Usage | ||
26 | + | ||
27 | +Running the script with `-h` displays the following usage information: | ||
28 | + | ||
29 | +``` | ||
30 | +Usage: certs/makedemocerts.py [options] | ||
31 | + | ||
32 | +Options: | ||
33 | +-h Show this message. | ||
34 | +-d | --debug Debugging output. | ||
35 | +--ip <ip> The IP address for the server certificate. | ||
36 | +--dns <dns> The DNS name for the server certificate. | ||
37 | +--use-dns Use the DNS name for the server certificate common | ||
38 | + name (default is to use the IP address). | ||
39 | +``` | ||
40 | + | ||
41 | +The `--ip`, `--dns`, and `--use-dns` options affect the generation of the server | ||
42 | +certificate. Without any arguments, the script prompts for the value of the IP | ||
43 | +address and DNS name. | ||
44 | + | ||
45 | +You can specify an alternate IP address using `--ip` and an alternate DNS name | ||
46 | +using `--dns`. The `--use-dns` flag forces the script to use the DNS name as | ||
47 | +the server's Common Name instead of the IP address. | ||
48 | + | ||
49 | +[1]: https://github.com/zeroc-ice/icecertutils |
certs/cacert.der
0 → 100644
No preview for this file type
certs/cacert.jks
0 → 100644
No preview for this file type
certs/cacert.pem
0 → 100644
1 | +++ a/certs/cacert.pem | ||
1 | +-----BEGIN CERTIFICATE----- | ||
2 | +MIIDyTCCArGgAwIBAgIIOxLJKzatOqwwDQYJKoZIhvcNAQELBQAwgYsxFTATBgNV | ||
3 | +BAMMDEljZSBEZW1vcyBDQTEMMAoGA1UECwwDSWNlMRQwEgYDVQQKDAtaZXJvQywg | ||
4 | +SW5jLjEQMA4GA1UEBwwHSnVwaXRlcjEQMA4GA1UECAwHRmxvcmlkYTELMAkGA1UE | ||
5 | +BhMCVVMxHTAbBgkqhkiG9w0BCQEWDmluZm9AemVyb2MuY29tMB4XDTE5MDMyNjE4 | ||
6 | +NDYyN1oXDTI0MDMyNDE4NDYyN1owgYsxFTATBgNVBAMMDEljZSBEZW1vcyBDQTEM | ||
7 | +MAoGA1UECwwDSWNlMRQwEgYDVQQKDAtaZXJvQywgSW5jLjEQMA4GA1UEBwwHSnVw | ||
8 | +aXRlcjEQMA4GA1UECAwHRmxvcmlkYTELMAkGA1UEBhMCVVMxHTAbBgkqhkiG9w0B | ||
9 | +CQEWDmluZm9AemVyb2MuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC | ||
10 | +AQEA4VlHZYQ5Qe4ke8depjjDQa7hXxWnPDI+gPa4Dn1PKfL5H6YDQ4gCaq9k1yTl | ||
11 | +mSHUbImF7Nd3VQAmm1egfhzEFEdj4sgSmvwcCgu0TB91fZmaE8bosJ+XEZ0kWw37 | ||
12 | +uB1L+6yTwTLWsv58E4/cf33enQeKCFECBHlz3r3cIaNQ3zj6JW4fETcswFZ3wZEa | ||
13 | +Nt+LDvhzD2LlXkkjknuy0ZAizWx5WAChF+LFniuT3gPxwz49Y2EMlXWtGu9p0Mzq | ||
14 | +t0L6d7tTPG3bCOZ0Cu+hjL0l7k7iqRPe6r8Zk7xzWi+4ibz4d6tXRnccTDcUboQz | ||
15 | +GO8KgssF5QIGaJoG9AxecwXCvQIDAQABoy8wLTAMBgNVHRMEBTADAQH/MB0GA1Ud | ||
16 | +DgQWBBSXJuFlY0dIR9r6/f4xEIeYkH/puTANBgkqhkiG9w0BAQsFAAOCAQEAxPnW | ||
17 | +KY6Etc4vKdr/7cd73fJ/wohmsHdQWDxxxy8TDLFlXFS0gTbwYF/U9VjWJNa7ro/q | ||
18 | +VbAgABUon2LRXK0cQfn63GppvSGjeNFuaXpGMiGoDuUnauE2xYQKrdtzW5Iig2j2 | ||
19 | +PivuKJ1LZlhGPUADyI8SewQW7kMbnyskKQ1yNTpfeX5I5jvlVRLfpfV65i9CIdNf | ||
20 | +2+x+Q3LGLAvdYAug2OdOYgHJYy+TZoUCMuETjmkVqA566Rz5tYshAQe5tX+VHeA1 | ||
21 | +1zzb9IzPR2be7OpU8K9MqhCOPbFONxGCTvO0cMhM8b5FZ+nswmPYctUfav4Vw0Hs | ||
22 | +3tyqLQKLfUVaPOR8qQ== | ||
23 | +-----END CERTIFICATE----- |
certs/client.jks
0 → 100644
No preview for this file type
certs/client.p12
0 → 100644
No preview for this file type
certs/makedemocerts.py
0 → 100755
1 | +++ a/certs/makedemocerts.py | ||
1 | +#!/usr/bin/env python | ||
2 | +# | ||
3 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
4 | +# | ||
5 | + | ||
6 | +import os, sys, socket, getopt | ||
7 | + | ||
8 | +try: | ||
9 | + import IceCertUtils | ||
10 | +except Exception as ex: | ||
11 | + print("couldn't load IceCertUtils, did you install the `zeroc-icecertutils'\n" | ||
12 | + "package from the Python package repository?\nerror: " + str(ex)) | ||
13 | + sys.exit(1) | ||
14 | + | ||
15 | +def usage(): | ||
16 | + print("Usage: " + sys.argv[0] + " [options]") | ||
17 | + print("") | ||
18 | + print("Options:") | ||
19 | + print("-h Show this message.") | ||
20 | + print("-d | --debug Debugging output.") | ||
21 | + print("--ip <ip> The IP address for the server certificate.") | ||
22 | + print("--dns <dns> The DNS name for the server certificate.") | ||
23 | + print("--use-dns Use the DNS name for the server certificate common") | ||
24 | + print(" name (default is to use the IP address)." ) | ||
25 | + sys.exit(1) | ||
26 | + | ||
27 | +# | ||
28 | +# Check arguments | ||
29 | +# | ||
30 | +debug = False | ||
31 | +ip = None | ||
32 | +dns = None | ||
33 | +usedns = False | ||
34 | +impl = "" | ||
35 | +try: | ||
36 | + opts, args = getopt.getopt(sys.argv[1:], "hd", ["help", "debug", "ip=", "dns=","use-dns","impl="]) | ||
37 | +except getopt.GetoptError as e: | ||
38 | + print("Error %s " % e) | ||
39 | + usage() | ||
40 | + sys.exit(1) | ||
41 | + | ||
42 | +for (o, a) in opts: | ||
43 | + if o == "-h" or o == "--help": | ||
44 | + usage() | ||
45 | + sys.exit(0) | ||
46 | + elif o == "-d" or o == "--debug": | ||
47 | + debug = True | ||
48 | + elif o == "--ip": | ||
49 | + ip = a | ||
50 | + elif o == "--dns": | ||
51 | + dns = a | ||
52 | + elif o == "--use-dns": | ||
53 | + usedns = True | ||
54 | + elif o == "--impl": | ||
55 | + impl = a | ||
56 | + | ||
57 | +def request(question, newvalue, value): | ||
58 | + while True: | ||
59 | + sys.stdout.write(question) | ||
60 | + sys.stdout.flush() | ||
61 | + input = sys.stdin.readline().strip() | ||
62 | + if input == 'n': | ||
63 | + sys.stdout.write(newvalue) | ||
64 | + sys.stdout.flush() | ||
65 | + return sys.stdin.readline().strip() | ||
66 | + else: | ||
67 | + return value | ||
68 | + | ||
69 | +# | ||
70 | +# Change to the directory where the certs files are stored | ||
71 | +# | ||
72 | +os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
73 | + | ||
74 | +if not ip: | ||
75 | + try: | ||
76 | + ip = socket.gethostbyname(socket.gethostname()) | ||
77 | + except: | ||
78 | + ip = "127.0.0.1" | ||
79 | + ip = request("The IP address used for the server certificate will be: " + ip + "\n" | ||
80 | + "Do you want to keep this IP address? (y/n) [y]", "IP : ", ip) | ||
81 | + | ||
82 | +if not dns: | ||
83 | + dns = "localhost" | ||
84 | + dns = request("The DNS name used for the server certificate will be: " + dns + "\n" | ||
85 | + "Do you want to keep this DNS name? (y/n) [y]", "DNS : ", dns) | ||
86 | + | ||
87 | +CertificateFactory = vars(IceCertUtils)[impl + "CertificateFactory"] | ||
88 | +factory = CertificateFactory(debug=debug, cn="Ice Demos CA") | ||
89 | + | ||
90 | +# | ||
91 | +# CA certificate | ||
92 | +# | ||
93 | +factory.getCA().save("cacert.pem").save("cacert.der") | ||
94 | + | ||
95 | +# Client certificate | ||
96 | +client = factory.create("client") | ||
97 | +client.save("client.p12") | ||
98 | + | ||
99 | +# Server certificate | ||
100 | +server = factory.create("server", cn = (dns if usedns else ip), ip=ip, dns=dns) | ||
101 | +server.save("server.p12") | ||
102 | + | ||
103 | +try: | ||
104 | + factory.getCA().save("cacert.pem").save("cacert.jks") # Used by the Database/library demo | ||
105 | + server.save("server.jks", caalias="cacert") | ||
106 | + client.save("client.jks", caalias="cacert") | ||
107 | + | ||
108 | + # Don't try to generate the BKS if the JKS generation fails | ||
109 | + try: | ||
110 | + server.save("server.bks", caalias="cacert") | ||
111 | + client.save("client.bks", caalias="cacert") | ||
112 | + except Exception as ex: | ||
113 | + for f in ["server.bks", "client.bks"]: | ||
114 | + if os.path.exists(f): os.remove(f) | ||
115 | + print("warning: couldn't generate BKS certificates for Android applications:\n" + str(ex)) | ||
116 | + print("Please fix this issue if you want to run the Android demos.") | ||
117 | + | ||
118 | +except Exception as ex: | ||
119 | + for f in ["server.jks", "client.jks"]: | ||
120 | + if os.path.exists(f): os.remove(f) | ||
121 | + print("warning: couldn't generate JKS certificates for Java applications:\n" + str(ex)) | ||
122 | + print("Please fix this issue if you want to run the Java demos.") | ||
123 | + | ||
124 | +factory.destroy() |
certs/server.jks
0 → 100644
No preview for this file type
certs/server.p12
0 → 100644
No preview for this file type
cpp11/Ice/auth/Client.cpp
0 → 100644
1 | +++ a/cpp11/Ice/auth/Client.cpp | ||
1 | +// | ||
2 | +// Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +// | ||
4 | + | ||
5 | +#include <Ice/Ice.h> | ||
6 | +#include <Context.h> | ||
7 | + | ||
8 | +using namespace std; | ||
9 | +using namespace Demo; | ||
10 | + | ||
11 | +int run(const shared_ptr<Ice::Communicator>&); | ||
12 | + | ||
13 | +int | ||
14 | +main(int argc, char* argv[]) | ||
15 | +{ | ||
16 | +#ifdef ICE_STATIC_LIBS | ||
17 | + Ice::registerIceSSL(); | ||
18 | +#endif | ||
19 | + | ||
20 | + int status = 0; | ||
21 | + | ||
22 | + try | ||
23 | + { | ||
24 | + // | ||
25 | + // CommunicatorHolder's ctor initializes an Ice communicator, | ||
26 | + // and its dtor destroys this communicator. | ||
27 | + // | ||
28 | + Ice::CommunicatorHolder ich(argc, argv, "config.client"); | ||
29 | + | ||
30 | + // | ||
31 | + // The communicator initialization removes all Ice-related arguments from argc/argv | ||
32 | + // | ||
33 | + if(argc > 1) | ||
34 | + { | ||
35 | + cerr << argv[0] << ": too many arguments" << endl; | ||
36 | + status = 1; | ||
37 | + } | ||
38 | + else | ||
39 | + { | ||
40 | + status = run(ich.communicator()); | ||
41 | + } | ||
42 | + } | ||
43 | + catch(const std::exception& ex) | ||
44 | + { | ||
45 | + cerr << argv[0] << ": " << ex.what() << endl; | ||
46 | + status = 1; | ||
47 | + } | ||
48 | + | ||
49 | + return status; | ||
50 | +} | ||
51 | + | ||
52 | +void menu(); | ||
53 | + | ||
54 | +int run(const shared_ptr<Ice::Communicator>& communicator) | ||
55 | +{ | ||
56 | + auto proxy = Ice::checkedCast<ContextPrx>(communicator->propertyToProxy("Context.Proxy")); | ||
57 | + if(!proxy) | ||
58 | + { | ||
59 | + cerr << "invalid proxy" << endl; | ||
60 | + return 1; | ||
61 | + } | ||
62 | + | ||
63 | + string token = proxy->login("user", "password"); | ||
64 | + | ||
65 | + Ice::Context ctx; | ||
66 | + ctx["token"] = token; | ||
67 | + auto proxy2 = proxy->ice_context(ctx); | ||
68 | + proxy2->function(); | ||
69 | + | ||
70 | + return 0; | ||
71 | +} |
cpp11/Ice/auth/Context.ice
0 → 100644
cpp11/Ice/auth/ContextI.cpp
0 → 100644
1 | +++ a/cpp11/Ice/auth/ContextI.cpp | ||
1 | +// | ||
2 | +// Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +// | ||
4 | + | ||
5 | +#include <Ice/Ice.h> | ||
6 | +#include <ContextI.h> | ||
7 | + | ||
8 | +using namespace std; | ||
9 | + | ||
10 | +std::string | ||
11 | +ContextI::login(std::string /* name */, std::string /* passwd */, const Ice::Current& /* c */) | ||
12 | +{ | ||
13 | + return "secretToken"; | ||
14 | +} | ||
15 | + | ||
16 | +void | ||
17 | +ContextI::function(const Ice::Current& c) | ||
18 | +{ | ||
19 | + // check token | ||
20 | + const auto p = c.ctx.find("token"); | ||
21 | + if (p != c.ctx.end() && p->second != "secretToken") | ||
22 | + return; | ||
23 | + cout << "function" << endl; | ||
24 | +} | ||
25 | + | ||
26 | +void | ||
27 | +ContextI::shutdown(const Ice::Current& c) | ||
28 | +{ | ||
29 | + cout << "Shutting down..." << endl; | ||
30 | + c.adapter->getCommunicator()->shutdown(); | ||
31 | +} |
cpp11/Ice/auth/ContextI.h
0 → 100644
1 | +++ a/cpp11/Ice/auth/ContextI.h | ||
1 | +// | ||
2 | +// Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +// | ||
4 | + | ||
5 | +#ifndef CONTEXT_I_H | ||
6 | +#define CONTEXT_I_H | ||
7 | + | ||
8 | +#include <Context.h> | ||
9 | + | ||
10 | +class ContextI : public Demo::Context | ||
11 | +{ | ||
12 | +public: | ||
13 | + | ||
14 | + std::string login(std::string name, std::string passwd, const Ice::Current& c) override; | ||
15 | + void function(const Ice::Current& c) override; | ||
16 | + virtual void shutdown(const Ice::Current&) override; | ||
17 | +}; | ||
18 | + | ||
19 | +#endif |
cpp11/Ice/auth/README.md
0 → 100644
1 | +++ a/cpp11/Ice/auth/README.md | ||
1 | +This demo illustrates how to use [request contexts][1]. | ||
2 | + | ||
3 | +To run the demo, first start the server: | ||
4 | + | ||
5 | +``` | ||
6 | +server | ||
7 | +``` | ||
8 | + | ||
9 | +In a separate window, start the client: | ||
10 | + | ||
11 | +``` | ||
12 | +client | ||
13 | +``` | ||
14 | + | ||
15 | +[1]: https://doc.zeroc.com/display/Ice37/Request+Contexts |
cpp11/Ice/auth/Server.cpp
0 → 100644
1 | +++ a/cpp11/Ice/auth/Server.cpp | ||
1 | +// | ||
2 | +// Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +// | ||
4 | + | ||
5 | +#include <Ice/Ice.h> | ||
6 | +#include <ContextI.h> | ||
7 | + | ||
8 | +using namespace std; | ||
9 | + | ||
10 | +int main(int argc, char* argv[]) | ||
11 | +{ | ||
12 | +#ifdef ICE_STATIC_LIBS | ||
13 | + Ice::registerIceSSL(); | ||
14 | +#endif | ||
15 | + | ||
16 | + int status = 0; | ||
17 | + | ||
18 | + try | ||
19 | + { | ||
20 | + // | ||
21 | + // CtrlCHandler must be created before the communicator or any other threads are started | ||
22 | + // | ||
23 | + Ice::CtrlCHandler ctrlCHandler; | ||
24 | + | ||
25 | + // | ||
26 | + // CommunicatorHolder's ctor initializes an Ice communicator, | ||
27 | + // and its dtor destroys this communicator. | ||
28 | + // | ||
29 | + Ice::CommunicatorHolder ich(argc, argv, "config.server"); | ||
30 | + auto communicator = ich.communicator(); | ||
31 | + | ||
32 | + ctrlCHandler.setCallback( | ||
33 | + [communicator](int) | ||
34 | + { | ||
35 | + communicator->shutdown(); | ||
36 | + }); | ||
37 | + | ||
38 | + // | ||
39 | + // The communicator initialization removes all Ice-related arguments from argc/argv | ||
40 | + // | ||
41 | + if(argc > 1) | ||
42 | + { | ||
43 | + cerr << argv[0] << ": too many arguments" << endl; | ||
44 | + status = 1; | ||
45 | + } | ||
46 | + else | ||
47 | + { | ||
48 | + auto adapter = communicator->createObjectAdapter("Context"); | ||
49 | + adapter->add(make_shared<ContextI>(), Ice::stringToIdentity("context")); | ||
50 | + adapter->activate(); | ||
51 | + | ||
52 | + communicator->waitForShutdown(); | ||
53 | + } | ||
54 | + } | ||
55 | + catch(const std::exception& ex) | ||
56 | + { | ||
57 | + cerr << ex.what() << endl; | ||
58 | + status = 1; | ||
59 | + } | ||
60 | + | ||
61 | + return status; | ||
62 | +} |
cpp11/Ice/auth/client
0 → 100755
No preview for this file type
cpp11/Ice/auth/config.client
0 → 100644
1 | +++ a/cpp11/Ice/auth/config.client | ||
1 | +Ice.Override.Secure=1 | ||
2 | + | ||
3 | +# | ||
4 | +# The client reads this property to create the reference to the | ||
5 | +# "hello" object in the server. | ||
6 | +# | ||
7 | +Context.Proxy=context:ssl -p 10000 | ||
8 | + | ||
9 | +# | ||
10 | +# Enable implicit context on the communicator | ||
11 | +# | ||
12 | +Ice.ImplicitContext=Shared | ||
13 | + | ||
14 | +# | ||
15 | +# Warn about connection exceptions | ||
16 | +# | ||
17 | +Ice.Warn.Connections=1 | ||
18 | + | ||
19 | +# | ||
20 | +# Network Tracing | ||
21 | +# | ||
22 | +# 0 = no network tracing | ||
23 | +# 1 = trace connection establishment and closure | ||
24 | +# 2 = like 1, but more detailed | ||
25 | +# 3 = like 2, but also trace data transfer | ||
26 | +# | ||
27 | +Ice.Trace.Network=1 | ||
28 | + | ||
29 | +# | ||
30 | +# Protocol Tracing | ||
31 | +# | ||
32 | +# 0 = no protocol tracing | ||
33 | +# 1 = trace protocol messages | ||
34 | +# | ||
35 | +Ice.Trace.Protocol=1 | ||
36 | + | ||
37 | +# | ||
38 | +# Security Tracing | ||
39 | +# | ||
40 | +# 0 = no security tracing | ||
41 | +# 1 = trace messages | ||
42 | +# | ||
43 | +IceSSL.Trace.Security=1 | ||
44 | + | ||
45 | +# | ||
46 | +# SSL Configuration | ||
47 | +# | ||
48 | +Ice.Plugin.IceSSL=IceSSL:createIceSSL | ||
49 | + | ||
50 | +IceSSL.DefaultDir=../../../certs | ||
51 | +IceSSL.CAs=cacert.pem | ||
52 | +#IceSSL.CertFile=client.p12 | ||
53 | +#IceSSL.Password=password | ||
54 | +#IceSSL.Keychain=../../../certs/client.keychain | ||
55 | +#IceSSL.KeychainPassword=password | ||
56 | + | ||
57 | +IceSSL.VerifyPeer=1 | ||
0 | \ No newline at end of file | 58 | \ No newline at end of file |
cpp11/Ice/auth/config.server
0 → 100644
1 | +++ a/cpp11/Ice/auth/config.server | ||
1 | +Ice.Override.Secure=1 | ||
2 | +# | ||
3 | +# The server creates one single object adapter with the name | ||
4 | +# "Context". The following line sets the endpoints for this | ||
5 | +# adapter. | ||
6 | +# | ||
7 | +Context.Endpoints=ssl -p 10000 | ||
8 | + | ||
9 | +# | ||
10 | +# Warn about connection exceptions | ||
11 | +# | ||
12 | +Ice.Warn.Connections=1 | ||
13 | + | ||
14 | +# | ||
15 | +# Network Tracing | ||
16 | +# | ||
17 | +# 0 = no network tracing | ||
18 | +# 1 = trace connection establishment and closure | ||
19 | +# 2 = like 1, but more detailed | ||
20 | +# 3 = like 2, but also trace data transfer | ||
21 | +# | ||
22 | +#Ice.Trace.Network=1 | ||
23 | + | ||
24 | +# | ||
25 | +# Protocol Tracing | ||
26 | +# | ||
27 | +# 0 = no protocol tracing | ||
28 | +# 1 = trace protocol messages | ||
29 | +# | ||
30 | +#Ice.Trace.Protocol=1 | ||
31 | + | ||
32 | +# | ||
33 | +# Security Tracing | ||
34 | +# | ||
35 | +# 0 = no security tracing | ||
36 | +# 1 = trace messages | ||
37 | +# | ||
38 | +IceSSL.Trace.Security=1 | ||
39 | + | ||
40 | +# | ||
41 | +# SSL Configuration | ||
42 | +# | ||
43 | +Ice.Plugin.IceSSL=IceSSL:createIceSSL | ||
44 | + | ||
45 | +IceSSL.DefaultDir=../../../certs | ||
46 | +IceSSL.CAs=cacert.pem | ||
47 | +IceSSL.CertFile=server.p12 | ||
48 | +IceSSL.Password=password | ||
49 | +IceSSL.Keychain=../../../certs/server.keychain | ||
50 | +IceSSL.KeychainPassword=password | ||
51 | + | ||
52 | +IceSSL.VerifyPeer=0 | ||
0 | \ No newline at end of file | 53 | \ No newline at end of file |
cpp11/Ice/auth/server
0 → 100755
No preview for this file type
cpp11/Makefile
0 → 100644
1 | +++ a/cpp11/Makefile | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +top_srcdir := .. | ||
6 | +lang_srcdir := $(top_srcdir)/cpp11 | ||
7 | + | ||
8 | +include $(top_srcdir)/make/Make.rules | ||
9 | +include $(lang_srcdir)/make/Make.rules | ||
10 | + | ||
11 | +exclude := Ice/qt | ||
12 | +demos := $(filter-out $(exclude),$(call demos-without-project-makefile,Client.cpp)) | ||
13 | +include $(shell find $(lang_srcdir) -name Makefile.mk) | ||
14 | +$(foreach t,$(demos),$(eval $(call create-cpp-demo-project,$(t)))) | ||
15 | +$(call make-projects,$(projects)) |
cpp11/make/Make.rules
0 → 100644
1 | +++ a/cpp11/make/Make.rules | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +# ---------------------------------------------------------------------- | ||
6 | +# Don't change anything below this line! | ||
7 | +# ---------------------------------------------------------------------- | ||
8 | + | ||
9 | +-include $(lang_srcdir)/config/Make.rules.$(os) | ||
10 | + | ||
11 | +# | ||
12 | +# Supported configurations | ||
13 | +# | ||
14 | +supported-configs = shared static | ||
15 | + | ||
16 | +# Validate platforms and configs | ||
17 | +$(eval $(call validate-config)) | ||
18 | + | ||
19 | +# | ||
20 | +# Support for Ice libraries | ||
21 | +# | ||
22 | +cpp-dependencies = Ice Glacier2 IceGrid IcePatch2 IceSSL IceDiscovery IceLocatorDiscovery IceStorm IceBox | ||
23 | +Ice_libs = bz2 | ||
24 | +Glacier2_dependencies = Ice | ||
25 | +IceGrid_dependencies = Glacier2 Ice | ||
26 | +IcePatch2_dependencies = Ice | ||
27 | +IcePatch2_libs = bz2 | ||
28 | +IceSSL_dependencies = Ice | ||
29 | +IceDiscovery_dependencies = Ice | ||
30 | +IceLocatorDiscovery_dependencies = Ice | ||
31 | +IceStorm_dependencies = Ice | ||
32 | +IceBox_dependencies = Ice | ||
33 | + | ||
34 | +ifneq ($(IceBT_system_libs),) | ||
35 | +cpp-dependencies += IceBT | ||
36 | +IceBT_dependencies := Ice | ||
37 | +endif | ||
38 | + | ||
39 | +# Append ++11 suffix to libraries | ||
40 | +shared_targetname = $(if $(filter-out $($1_target),program),++11) | ||
41 | +static_targetname = $(if $(filter-out $($1_target),program),++11) | ||
42 | + | ||
43 | +# Create component dependency variables | ||
44 | +$(eval $(call create-project-dependencies,ice,$(ICE_HOME),cpp,cpp,$(cpp-dependencies))) | ||
45 | + | ||
46 | +# | ||
47 | +# Don't set platform targetdir/targetname for demos. The executables are always produced | ||
48 | +# in the demo directory with the same name regardless of the config/platform. | ||
49 | +# | ||
50 | +$(foreach v,$(supported-platforms) platform config,$(eval $v_targetdir := ) $(eval $v_targetname := )) | ||
51 | + | ||
52 | +slice2cpp_targetext = cpp | ||
53 | +slice2cpp_path = $(or $(ice_bindir[$(build-platform)]),$(ice_bindir))/slice2cpp | ||
54 | + | ||
55 | +ifeq ($(wildcard $(slice2cpp_path)),) | ||
56 | +$(error Can't find Ice distribution, please set ICE_HOME to the Ice installation directory) | ||
57 | +endif | ||
58 | + | ||
59 | +# | ||
60 | +# $(create-cpp-demo-project $1=demo) | ||
61 | +# | ||
62 | +define create-cpp-demo-project | ||
63 | +$1_targetdir := $1 | ||
64 | +$1_srcext := cpp | ||
65 | +$1_dependencies := $$(or $$($1_dependencies),Ice) | ||
66 | +$1_slicecompiler := slice2cpp | ||
67 | +$1_sliceflags := -I$(ice_slicedir) -I$1 $$($1_sliceflags) | ||
68 | +$1_cppflags := -DICE_CPP11_MAPPING -std=c++11 -I$1 -I$1/generated $(ice_cppflags) $$($1_cppflags) | ||
69 | +$1_caninstall := no | ||
70 | + | ||
71 | +# Also link with IceSSL, IceDiscovery and IceLocatorDiscovery when compiling the project with the static configuration | ||
72 | +$1[static]_dependencies := $$(or $$($1_dependencies[static]),IceSSL IceDiscovery IceLocatorDiscovery) | ||
73 | + | ||
74 | +$(create-demo-project) | ||
75 | +endef |
make/Make.demos.rules
0 → 100644
1 | +++ a/make/Make.demos.rules | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +# | ||
6 | +# $(call demo,[$1]) | ||
7 | +# | ||
8 | +# Returns the demo project name (./demo/Ice/hello -> demo/Ice/hello) | ||
9 | +# | ||
10 | +demo = $(patsubst $(lang_srcdir)/%,%,$(if $1,$1,$(currentdir))) | ||
11 | + | ||
12 | +# | ||
13 | +# $(call demo-sources,$1=sources,$2=dir,$3=main-src extra-srcs) | ||
14 | +# | ||
15 | +# Returns sources if set, otherwise if main-src exists return main-src + extra-srcs, if it | ||
16 | +# doesn't exist, returns an empty value. | ||
17 | +# | ||
18 | +demo-sources = $(call unique,$(if $1,$(foreach f,$1,$(notdir $(wildcard $2/$f))),\ | ||
19 | + $(if $(wildcard $2/$(firstword $3)),$(foreach f,$3,$(notdir $(wildcard $2/$f)))))) | ||
20 | + | ||
21 | +# | ||
22 | +# The demo executables to try to build in each demo directory | ||
23 | +# | ||
24 | +demo-programs = client server publisher subscriber | ||
25 | + | ||
26 | +# | ||
27 | +# The default demo sources for each demo executable. | ||
28 | +# | ||
29 | +demo-client-sources = Client.$1 *.ice | ||
30 | +demo-server-sources = Server.$1 *.ice *I.$1 | ||
31 | +demo-publisher-sources = Publisher.$1 *.ice | ||
32 | +demo-subscriber-sources = Subscriber.$1 *.ice | ||
33 | + | ||
34 | +# | ||
35 | +# $(call create-demo-project,demo) | ||
36 | +# | ||
37 | +# Defines a project for the given demo. | ||
38 | +# | ||
39 | +# The following variables can be defined to customize the build of the demo: | ||
40 | +# | ||
41 | +# <name>_cleandirs | ||
42 | +# <name>_clean | ||
43 | +# <name>_bindir | ||
44 | +# <name>_libdir | ||
45 | +# <name>_sliceflags | ||
46 | +# <name>_cppflags | ||
47 | +# <name>_dependencies | ||
48 | +# <name>_programs | ||
49 | +# <name>_libraries | ||
50 | +# | ||
51 | +# The following variables allows to specify per-target (program or library) configuration | ||
52 | +# | ||
53 | +# <name>_<target>_sources | ||
54 | +# <name>_<target>_sources | ||
55 | +# | ||
56 | +define create-demo-project | ||
57 | + | ||
58 | +$1_srcdir := $1 | ||
59 | +$1_programs := $$(or $$($1_programs),$(demo-programs)) | ||
60 | +$1_noinstall := 1 | ||
61 | + | ||
62 | +$1_client_sources := $$(call demo-sources,$$(call $1_client_sources,$$($1_srcext)),$$($1_srcdir),\ | ||
63 | + $$(call demo-client-sources,$$($1_srcext))) | ||
64 | + | ||
65 | +$1_server_sources := $$(call demo-sources,$$(call $1_server_sources,$$($1_srcext)),$$($1_srcdir),\ | ||
66 | + $$(call demo-server-sources,$$($1_srcext))) | ||
67 | + | ||
68 | +$1_publisher_sources := $$(call demo-sources,$$(call $1_publisher_sources,$$($1_srcext)),$$($1_srcdir),\ | ||
69 | + $$(call demo-publisher-sources,$$($1_srcext))) | ||
70 | + | ||
71 | +$1_subscriber_sources := $$(call demo-sources,$$(call $1_subscriber_sources,$$($1_srcext)),$$($1_srcdir),\ | ||
72 | + $$(call demo-subscriber-sources,$$($1_srcext))) | ||
73 | + | ||
74 | +$1_programs := $$(foreach p,$$($1_programs),$$(if $$($1_$$(p)_sources),$1_$$(p))) | ||
75 | +$1_libraries := $$(foreach p,$$($1_libraries),$1_$$(p)) | ||
76 | + | ||
77 | +$$(foreach m,$$($1_programs) $$($1_libraries),$$(eval $$m_sources := $$(addprefix $$($1_srcdir)/,$$($$m_sources)))) | ||
78 | + | ||
79 | +projects += $(project) | ||
80 | + | ||
81 | +endef | ||
82 | + | ||
83 | +# | ||
84 | +# Returns the demos which don't have a Makefile.mk fragment specified | ||
85 | +# | ||
86 | +demos-without-project-makefile = $(call unique,$(foreach d,$(call dirname,$(shell find $(lang_srcdir) -name $1)),\ | ||
87 | + $(if $(wildcard $d/Makefile.mk),,$(call demo,$d)))) | ||
88 | + | ||
89 | +# | ||
90 | +# The demos variable is used to load demos in Makefile.mk fragments | ||
91 | +# | ||
92 | +demos := |
make/Make.project.rules
0 → 100644
1 | +++ a/make/Make.project.rules | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +# | ||
6 | +# $(call project,[$1]) | ||
7 | +# | ||
8 | +# Returns the project name, $(top_srcdir) is removed from the begining | ||
9 | +# of the path so for example ./src/Ice is transformed to src/Ice. | ||
10 | +# | ||
11 | +project = $(patsubst $(lang_srcdir)/%,%,$(if $1,$1,$(currentdir))) | ||
12 | + | ||
13 | +# | ||
14 | +# The platforms, configs and languages to build. | ||
15 | +# | ||
16 | +platforms = $(filter-out $(SKIP),$(if $(filter all,$(PLATFORMS)),$(supported-platforms),$(filter $(supported-platforms),$(PLATFORMS)))) | ||
17 | +configs = $(filter-out $(SKIP),$(if $(filter all,$(CONFIGS)),$(supported-configs),$(filter $(supported-configs),$(CONFIGS)))) | ||
18 | +languages = $(filter-out $(SKIP),$(if $(filter all,$(or $(LANGUAGES),all)),$(supported-languages),$(filter $(supported-languages),$(LANGUAGES)))) | ||
19 | +build-platform := $(or $(build-platform),$(firstword $(supported-platforms))) | ||
20 | + | ||
21 | +# | ||
22 | +# The list of platforms to build for the given component. We iterate over the platform | ||
23 | +# list (which is the value of PLATFORMS or the default platform) and check if the | ||
24 | +# component is either included/excluded for this platform based on the <platform>_excludes, | ||
25 | +# <platform>_components and <platform>_projects variables. | ||
26 | +# | ||
27 | +component-platforms = $(call unique,$(foreach p,$(platforms),\ | ||
28 | + $(if $(and $(if $(filter $($p_excludes),$1 $2),,true),\ | ||
29 | + $(or $(filter $($p_components),$2),\ | ||
30 | + $(filter $(or $($p_projects),$(if $($p_components),,%)),$1))),\ | ||
31 | + $(strip $p)))) | ||
32 | + | ||
33 | +# | ||
34 | +# Same as the above but for configurations | ||
35 | +# | ||
36 | +component-configs = $(call unique,$(foreach c,$(configs),\ | ||
37 | + $(if $(strip $(foreach s,$(subst -,$(space),$c),\ | ||
38 | + $(if $(and $(if $(filter $($s_excludes),$1 $2),,true),\ | ||
39 | + $(or $(filter $($s_components),$2),\ | ||
40 | + $(filter $($s_projects),$1))),,$s))),,\ | ||
41 | + $(strip $c)))) | ||
42 | + | ||
43 | +# | ||
44 | +# Some variables for utilities | ||
45 | +# | ||
46 | +INSTALL = install -p | ||
47 | +MV = mv -f | ||
48 | +RM = rm -f | ||
49 | +MKDIR = mkdir | ||
50 | +CHMOD = chmod | ||
51 | + | ||
52 | +Q := $(if $(V),,@) | ||
53 | +E := $(if $(V),@:,@echo) | ||
54 | + | ||
55 | +# $(call install-data,$1=filename,$2=srcdir,$3=destdist) | ||
56 | +install-data = $(INSTALL) -m 644 $2/$1 $(DESTDIR)$3/$1 | ||
57 | + | ||
58 | +# | ||
59 | +# $(call install-data-files,$1=files,$2=$srcdir,$3=$destdir,$4=target,$5=text-output) | ||
60 | +# | ||
61 | +define install-data-files | ||
62 | + | ||
63 | +$4:: $(patsubst $2/%,$(DESTDIR)$3/%,$1) | ||
64 | + $(if $5,$(E) $5) | ||
65 | + | ||
66 | +ifeq ($(filter $(or $(call files-to-dirs,$(patsubst $2/%,$3/%,$1)),$3),$(installdirs)),) | ||
67 | +$(or $(call files-to-dirs,$(patsubst $2/%,$(DESTDIR)$3/%,$1)),$(DESTDIR)$3): | ||
68 | + $(Q)$(MKDIR) -p $$@ | ||
69 | +installdirs += $(or $(call files-to-dirs,$(patsubst $2/%,$3/%,$1)),$3) | ||
70 | +endif | ||
71 | + | ||
72 | +$(patsubst $2/%,$(DESTDIR)$3/%,$1): $(DESTDIR)$3/%: $2/% | \ | ||
73 | + $(or $(call files-to-dirs,$(patsubst $2/%,$(DESTDIR)$3/%,$1)),$(DESTDIR)$3) | ||
74 | + $(Q)$(call install-data,$$(*),$2,$3) | ||
75 | + | ||
76 | +endef | ||
77 | + | ||
78 | +# | ||
79 | +# $(call make-objects,$1=srcdir,$2=generateddir,$3=objdir,$4=sources,$5=dependencies,$6=cppflags,$7=generatedext, | ||
80 | +# $8=platform,$9=config) | ||
81 | +# | ||
82 | +# Defines pattern rules to build object files into directory objdir. The sources | ||
83 | +# are specified by sources. The srcdir and generateddir specifies where the | ||
84 | +# sources and generated sources are located. | ||
85 | +# | ||
86 | +define make-objects | ||
87 | + | ||
88 | +# | ||
89 | +# If there's no dependency yet, ensure the objects depend on all the modules dependencies | ||
90 | +# and on the generated sources to ensure that all the Slice files from this module and | ||
91 | +# other modules are built first. | ||
92 | +# | ||
93 | +ifeq ($(wildcard $3/*.d),) | ||
94 | +$(addprefix $3/,$(call source-to-object,$4)): $(addprefix $2/,$(call generated-to-source,$4,$7)) \ | ||
95 | + $(foreach d,$5,$($d_targets)) | ||
96 | +endif | ||
97 | + | ||
98 | +# Add a dedependency on generated headers from dependencies. This will only work if dependency | ||
99 | +# Makefile.mk are loaded before this component Makefile.mk. | ||
100 | +$(addprefix $3/,$(call source-to-object,$4)): | $(foreach d,$5,$($($d_component)_generated_headers)) | ||
101 | + | ||
102 | +.PRECIOUS: $3/%.d | ||
103 | + | ||
104 | +ifeq ($(filter %clean print,$(MAKECMDGOALS)),) | ||
105 | + # Include the dependencies | ||
106 | + -include $(addprefix $3/,$(call source-to-dependency,$4)) | ||
107 | + -include $(addprefix $3/,$(call source-to-dependency,$(call generated-to-source,$4,$7))) | ||
108 | +endif | ||
109 | + | ||
110 | +ifneq ($(filter %.ice $2/%.$7,$4),) | ||
111 | +# Rules to build generated sources from <srcdir>/generated | ||
112 | +$3/%.o: $2/%.$7 | ||
113 | +$3/%.o: $2/%.$7 | ||
114 | + $(E) "Compiling [$8-$9] $$<" | ||
115 | + $(Q)$(or $($8_cxx),$(platform_cxx)) $(CXXFLAGS) $(call depend-cppflags,$3/$$*.Td,$$@)\ | ||
116 | + $(strip $6) $(CPPFLAGS) -c $$< -o $$@ | ||
117 | + $(Q)$(MV) $3/$$*.Td $3/$$*.$7.d | ||
118 | +endif | ||
119 | + | ||
120 | +ifneq ($(filter %.cpp,$4),) | ||
121 | +# Rules to build C++ sources from <srcdir> | ||
122 | +$3/%.o: $1/%.cpp | ||
123 | +$3/%.o: $1/%.cpp | ||
124 | + $(E) "Compiling [$8-$9] $$<" | ||
125 | + $(Q)$(or $($8_cxx),$(platform_cxx)) $(CXXFLAGS) $(call depend-cppflags,$3/$$*.Td,$$@)\ | ||
126 | + $(strip $6) $(CPPFLAGS) -c $$< -o $$@ | ||
127 | + $(Q)$(MV) $3/$$*.Td $3/$$*.cpp.d | ||
128 | +endif | ||
129 | + | ||
130 | +ifneq ($(filter %.mm,$4),) | ||
131 | +# Rules to build Objective-C++ sources from <srcdir> | ||
132 | +$3/%.o: $1/%.mm | ||
133 | +$3/%.o: $1/%.mm | ||
134 | + $(E) "Compiling [$8-$9] $$<" | ||
135 | + $(Q)$(or $($8_cxx),$(platform_cxx)) $(CXXFLAGS) $(call depend-cppflags,$3/$$*.Td,$$@)\ | ||
136 | + $(strip $6) $(CPPFLAGS) -c $$< -o $$@ | ||
137 | + $(Q)$(MV) $3/$$*.Td $3/$$*.mm.d | ||
138 | +endif | ||
139 | + | ||
140 | +ifneq ($(filter %.m,$4),) | ||
141 | +# Rules to build Objective-C sources from <srcdir> | ||
142 | +$3/%.o: $1/%.m | ||
143 | +$3/%.o: $1/%.m | ||
144 | + $(E) "Compiling [$8-$9] $$<" | ||
145 | + $(Q)$(or $($8_cxx),$(platform_cxx)) $(CXXFLAGS) $(call depend-cppflags,$3/$$*.Td,$$@)\ | ||
146 | + $(strip $6) $(CPPFLAGS) -c $$< -o $$@ | ||
147 | + $(Q)$(MV) $3/$$*.Td $3/$$*.m.d | ||
148 | +endif | ||
149 | + | ||
150 | +endef | ||
151 | + | ||
152 | +# | ||
153 | +# $(call make-slices,$1=slicedir,$2=generateddir,$3=includedir,$4=slices,$5=sliceflags,$6=slice_compiler) | ||
154 | +# | ||
155 | +# Defines a pattern rule for <includedir>/%.h <generateddir>/%.cpp: <slicedir>/%.ice | ||
156 | +# | ||
157 | +define make-slices | ||
158 | + | ||
159 | +.PRECIOUS: $2/%.ice.d | ||
160 | + | ||
161 | +ifeq ($(filter %clean print,$(MAKECMDGOALS)),) | ||
162 | + # Include the dependencies | ||
163 | + -include $(addprefix $2/,$(call source-to-dependency,$4)) | ||
164 | +endif | ||
165 | + | ||
166 | +$3/%.h $2/%.$($6_targetext): $1/%.ice $($6_path) | $3 | ||
167 | + $(E) "Compiling $$<" | ||
168 | + $(Q)$(RM) $3/$$*.h $2/$$*.$($6_targetext) | ||
169 | + $(Q)$($6_path) $(strip $5) --depend $$< | sed 's|\(.*:\)|$3/$$*.h $2/$$*.$($6_targetext):|' > $2/$$*.ice.d | ||
170 | + $(Q)$($6_path) $(strip $5) --output-dir $2 $$< | ||
171 | + $(if $(filter-out $2,$3),$(Q)$(MV) $2/$$*.h $3/) | ||
172 | + | ||
173 | +endef | ||
174 | + | ||
175 | +# | ||
176 | +# $(call make-bison,$1=srcdir,$2=flags) | ||
177 | +# | ||
178 | +define make-bison | ||
179 | +$1/%.h $1/%.cpp: $1/%.y | ||
180 | + @$(RM) $$*.h $$*.cpp | ||
181 | + bison -dvt $2 -o $1/$$*.cpp $$< | ||
182 | + @$(MV) $1/$$*.hpp $1/$$*.h | ||
183 | + @$(RM) $1/$$*.output | ||
184 | +endef | ||
185 | + | ||
186 | +# | ||
187 | +# $(call make-flex,$1=srcdir,$2=flags) | ||
188 | +# | ||
189 | +define make-flex | ||
190 | +$1/%.cpp: $1/%.l | ||
191 | + @$(RM) $$@ | ||
192 | + flex $2 -o $$@ $$< | ||
193 | + @$(MV) $$@ $$@.tail | ||
194 | + @echo '#include <IceUtil/ScannerConfig.h>' >> $$@ | ||
195 | + @cat $$@.tail >> $$@ | ||
196 | + @$(RM) $$@.tail | ||
197 | +endef | ||
198 | + | ||
199 | +# | ||
200 | +# $(call make-static-library,$1=libname,$2=libdir,$3=version,$4=soversion,$5=objects,$6=dependencies,$7=ldflags, | ||
201 | +# $8=platform,$9=config) | ||
202 | +# | ||
203 | +# Defines rules for building the static library <libname> in <libdir> with the objects <objects> | ||
204 | +# | ||
205 | +define make-static-library | ||
206 | +$2/$(call mklibname,$1,$3,$4): $5 | ||
207 | + $(E) "Linking [$8-$9] $$@" | ||
208 | + $(Q)$(MKDIR) -p $2 | ||
209 | + $(Q)$(call mklib,$2/$(call mklibname,$1,$3,$4),$(strip $5),$1,$3,$4,$(LDFLAGS) $(strip $7),$8) | ||
210 | +endef | ||
211 | + | ||
212 | +# $(call install-static-library,$1=libname,$2=libdir,$3=version,$4=soversion,$5=installdir,$6=devinstall) | ||
213 | +define install-static-library | ||
214 | +$(DESTDIR)$5/$(call mklibname,$1,$3,$4): $2/$(call mklibname,$1,$3,$4) | $(DESTDIR)$5 | ||
215 | + $(E) "Installing $$@" | ||
216 | + $(Q)$(INSTALL) $$< $(DESTDIR)$5 | ||
217 | +endef | ||
218 | + | ||
219 | +# $(call get-static-library-targets,$1=libname,$2=libdir,$3=version,$4=soversion,$5=devinstall) | ||
220 | +get-static-library-targets = $2/$(call mklibname,$1) | ||
221 | + | ||
222 | +# | ||
223 | +# $(call make-shared-library,$1=libname,$2=libdir,$3=version,$4=soversion,$5=objects,$6=dependencies,$7=ldflags, | ||
224 | +# $8=platform,$9=config) | ||
225 | +# | ||
226 | +# Defines rules for building the shared library <libname> in <libdir> with the objects <objects> | ||
227 | +# | ||
228 | +define make-shared-library | ||
229 | + | ||
230 | +$2/$(call mkshlibfilename,$1,$3,$4): $5 $(foreach d,$6,$($d_targets)) | ||
231 | + $(E) "Linking [$8-$9] $$@" | ||
232 | + $(Q)$(MKDIR) -p $2 | ||
233 | + $(Q)$(call mkshlib,$2/$(call mkshlibfilename,$1,$3,$4),$(strip $5),$1,$3,$4,$(LDFLAGS) $(strip $7),$8) | ||
234 | + | ||
235 | +ifneq ($(and $4,$(filter-out undefined,$(origin mksoname))),) | ||
236 | +$2/$(call mksoname,$1,$3,$4): $2/$(call mkshlibfilename,$1,$3,$4) | ||
237 | + @$(RM) $$@ ; ln -s $$(<F) $$@ | ||
238 | +endif | ||
239 | + | ||
240 | +ifneq ($(and $3,$(filter-out undefined,$(origin mkshlibname))),) | ||
241 | +$2/$(call mkshlibname,$1,$3,$4): $2/$(call mkshlibnametarget,$1,$3,$4) | ||
242 | + @$(RM) $$@ ; ln -s $$(<F) $$@ | ||
243 | +endif | ||
244 | + | ||
245 | +endef | ||
246 | + | ||
247 | +# $(call install-shared-library,$1=libname,$2=libdir,$3=version,$4=soversion,$5=installdir,$6=devinstall) | ||
248 | +define install-shared-library | ||
249 | + | ||
250 | +$(DESTDIR)$5/$(call mkshlibfilename,$1,$3,$4): $2/$(call mkshlibfilename,$1,$3,$4) | $(DESTDIR)$5 | ||
251 | + $(E) "Installing $$@" | ||
252 | + $(Q)$(INSTALL) $$< $(DESTDIR)$5 | ||
253 | + $(Q)$(CHMOD) a+rx $$@ | ||
254 | + | ||
255 | +ifneq ($(and $4,$(filter-out undefined,$(origin mksoname))),) | ||
256 | +$(DESTDIR)$5/$(call mksoname,$1,$3,$4): $(DESTDIR)$5/$(call mkshlibfilename,$1,$3,$4) \ | ||
257 | + $2/$(call mksoname,$1,$3,$4) | ||
258 | + @$(RM) $$@ ; ln -s $$(<F) $$@ | ||
259 | +endif | ||
260 | + | ||
261 | +ifneq ($(and $(filter yes,$6),$3,$(filter-out undefined,$(origin mkshlibname))),) | ||
262 | +$(DESTDIR)$5/$(call mkshlibname,$1,$3,$4): $(DESTDIR)$5/$(call mkshlibnametarget,$1,$3,$4) \ | ||
263 | + $2/$(call mkshlibname,$1,$3,$4) | ||
264 | + @$(RM) $$@ ; ln -s $$(<F) $$@ | ||
265 | +endif | ||
266 | + | ||
267 | +endef | ||
268 | + | ||
269 | +# $(call get-shared-library-targets,$1=libname,$2=libdir,$3=version,$4=soversion,$5=devinstall) | ||
270 | +get-shared-library-targets = $(addprefix $2/,\ | ||
271 | + $(call mkshlibfilename,$1,$3,$4) \ | ||
272 | + $(if $(and $4,$(filter-out undefined,$(origin mksoname))),$(call mksoname,$1,$3,$4)) \ | ||
273 | + $(if $(and $(filter yes,$5),$3,$(filter-out undefined,$(origin mkshlibname))),$(call mkshlibname,$1,$3,$4))) | ||
274 | + | ||
275 | +# | ||
276 | +# $(call make-shared-module,$1=libname,$2=libdir,$3=version,$4=soversion,$5=objects,$6=dependencies,$7=ldflags, | ||
277 | +# $8=platform,$9=config) | ||
278 | +# | ||
279 | +# Defines rules for building the shared module (this is used to build the Python/Ruby/PHP modules) | ||
280 | +# | ||
281 | +define make-shared-module | ||
282 | +$2/$1: $5 $(foreach d,$6,$($d_targets)) | ||
283 | + $(E) "Linking [$8-$9] $$@" | ||
284 | + $(Q)$(MKDIR) -p $2 | ||
285 | + $(Q)$(call mkshlib,$2/$1,$(strip $5),$1,$3,,$(LDFLAGS) $(strip $7),$8) | ||
286 | +endef | ||
287 | + | ||
288 | +# $(call install-shared-module,$1=libname,$2=libdir,$3=version,$4=soversion,$5=installdir,$6=devinstall) | ||
289 | +define install-shared-module | ||
290 | +$(DESTDIR)$5/$1: $2/$1 | $(DESTDIR)$5 | ||
291 | + $(E) "Installing $$@" | ||
292 | + $(Q)$(INSTALL) $$< $(DESTDIR)$5 | ||
293 | + $(Q)$(CHMOD) a+rx $$@ | ||
294 | +endef | ||
295 | + | ||
296 | +# $(call get-shared-module-targets,$1=libname,$2=libdir,$3=version,$4=soversion,$5=devinstall) | ||
297 | +get-shared-module-targets = $2/$1 | ||
298 | + | ||
299 | +# | ||
300 | +# $(call make-program,$1=exename,$2=bindir,$3=version,$4=soversion,$5=objects,$6=dependencies,$7=ldflags,\ | ||
301 | + $8=platform,$9=config) | ||
302 | +# | ||
303 | +# Defines a rule for building the program <exename> in <bindir> with the objects <objects> | ||
304 | +# | ||
305 | +define make-program | ||
306 | +$2/$1$(EXE_EXT): $5 $(foreach d,$6,$($d_targets)) | ||
307 | + $(E) "Linking [$8-$9] $$@" | ||
308 | + $(Q)$(MKDIR) -p $2 | ||
309 | + @$(RM) $$@ | ||
310 | + $(Q)$(or $($8_cxx),$(platform_cxx)) $(LDFLAGS) -o $$@ $5 $(strip $7) | ||
311 | +endef | ||
312 | + | ||
313 | +# $(call install-program,$1=exename,$2=bindir,$3=version,$4=soversion,$5=installdir,$6=devinstall) | ||
314 | +define install-program | ||
315 | +$(DESTDIR)$5/$1$(EXE_EXT): $2/$1$(EXE_EXT) | $(DESTDIR)$5 | ||
316 | + $(E) "Installing $$@" | ||
317 | + $(Q)$(INSTALL) $$< $(DESTDIR)$5 | ||
318 | + $(Q)$(CHMOD) a+rx $$@ | ||
319 | +endef | ||
320 | + | ||
321 | +# $(call get-program-targets,$1=exename,$2=bindir,$3=version,$4=soversion,$5=devinstall) | ||
322 | +get-program-targets = $2/$1$(EXE_EXT) | ||
323 | + | ||
324 | +# | ||
325 | +# $(call create-component-with-config-targets,$1=project,$2=component,$3=platform,$4=config,$5=comp[platform-config], | ||
326 | +# $6=nobuild) | ||
327 | +# | ||
328 | +# Defines target variables for the given component/paltform/configuration | ||
329 | +# | ||
330 | +define create-component-with-config-targets | ||
331 | + | ||
332 | +$5_component := $2 | ||
333 | +$5_platform := $3 | ||
334 | +$5_config := $4 | ||
335 | +$2_components := $5 | ||
336 | + | ||
337 | +# | ||
338 | +# Compute the target and installation directories. | ||
339 | +# | ||
340 | +$5_targetdir := $$(call var-value,targetdir,$1,$2,$3,$4,make-dirwsuffix) | ||
341 | +$5_installdir := $$(call var-value,installdir,$1,$2,$3,$4,make-dirwsuffix) | ||
342 | + | ||
343 | +# | ||
344 | +# Compute the target rule and name for this platform/configuration combination. | ||
345 | +# | ||
346 | +$5_targetrule := $$(call var-value,target,$1,$2,$3,$4,make-targetrule) | ||
347 | +$5_targetname := $$(call var-value,targetname,$1,$2,$3,$4,make-targetname) | ||
348 | +$5_version := $$(call var-value,version,$1,$2,$3,$4) | ||
349 | +$5_soversion := $$(call var-value,soversion,$1,$2,$3,$4) | ||
350 | + | ||
351 | +# | ||
352 | +# Transform the dependencies to [platform-configuration] specific dependencies. | ||
353 | +# | ||
354 | +$5_dependencies := $$(call var-rcompound,dependencies,$1,$2,$3,$4,make-deps) | ||
355 | +$5_libs := $$(call var-compound,libs,$1,$2,$3,$4,make-unique) | ||
356 | +$5_system_libs := $$(call var-compound,system_libs,$1,$2,$3,$4) | ||
357 | + | ||
358 | +# | ||
359 | +# The targets to build. | ||
360 | +# | ||
361 | +ifeq ($6,) | ||
362 | +$5_targets := $$(call get-$$($5_targetrule)-targets,$$($5_targetname),$$($5_targetdir),$$($5_version),$$($5_soversion),yes) | ||
363 | +$5_install_targets := $$(call get-$$($5_targetrule)-targets,$$($5_targetname),$(DESTDIR)$$($5_installdir),$$($5_version),$$($5_soversion),$$($2_devinstall)) | ||
364 | +endif | ||
365 | + | ||
366 | +# | ||
367 | +# We define a secondary target for component[platform-config]. This is necessary | ||
368 | +# to allow dependencies to be used as prerequesties. For example, objects for | ||
369 | +# IceSSL[osx-shared] depend on Ice[osx-shared], see make-objects. | ||
370 | +# | ||
371 | +.PHONY: $5 | ||
372 | +$5:: $$($5_targets) | ||
373 | + | ||
374 | +endef | ||
375 | + | ||
376 | +# | ||
377 | +# $(call create-component-targets,$1=project,$2=component,$3=type,$4=nobuild) | ||
378 | +# | ||
379 | +# Create the target variables for the given component. | ||
380 | +# | ||
381 | +define create-component-targets | ||
382 | + | ||
383 | +$2_project := $1 | ||
384 | + | ||
385 | +$2_target := $$(call var-with-default,$2_target,$3) | ||
386 | +$2_targetname := $$(call var-with-default,$2_targetname,$(patsubst $1_%,%,$2)) | ||
387 | + | ||
388 | +$2_platforms := $$(filter $(platforms) $$($2_always_enable_platforms),$$(call unique,$$($2_always_enable_platforms) $$(or $$($2_platforms),$$($1_platforms),$(call component-platforms,$1,$2)))) | ||
389 | +$2_configs := $$(filter $(configs) $$($2_always_enable_configs),$$(call unique,$$($2_always_enable_configs) $$(or $$($2_configs),$$($1_configs),$(call component-configs,$1,$2)))) | ||
390 | + | ||
391 | +# Install files necessary for development. | ||
392 | +$2_devinstall := $$(call var-with-default,$2_devinstall,yes) | ||
393 | + | ||
394 | +# Set default target directory if we're not building the component, this is used | ||
395 | +# when building against the component binary distribution. | ||
396 | +ifneq ($4,) | ||
397 | +$2_targetdir := $$(call var-with-default,$2_targetdir,$$(if $$(filter program,$$($2_target)),$$($1_bindir),$$($1_libdir))) | ||
398 | +endif | ||
399 | + | ||
400 | +# | ||
401 | +# The installation directory (install_bindir if program, install_libdir otherwise) | ||
402 | +# | ||
403 | +$2_installdir := $$(call var-with-default,$2_installdir,$$(if $$(filter program,$$($2_target)),$$($1_install_bindir),$$($1_install_libdir))) | ||
404 | + | ||
405 | +$$(foreach p,$$($2_platforms),\ | ||
406 | + $$(foreach c,$$(filter $$(or $$($$p_configs),%),$$($2_configs)),\ | ||
407 | + $$(if $$(filter $(SKIP),$2[$$p-$$c]),,\ | ||
408 | + $$(eval $$(call create-component-with-config-targets,$1,$2,$$p,$$c,$2[$$p-$$c],$4))))) | ||
409 | + | ||
410 | +endef | ||
411 | + | ||
412 | +# | ||
413 | +# $(call create-project-targets,$1=project,$2=nobuild) | ||
414 | +# | ||
415 | +# Creates all the target variables which are necessary to depend on the components | ||
416 | +# from the given project. This is used by various language mappings to depend on C++ | ||
417 | +# components such as the translators or the C++ IceUtil or Ice libraries. | ||
418 | +# | ||
419 | +define create-project-targets | ||
420 | +ifeq ($(filter $(SKIP),$1),) | ||
421 | +$1_targetdir := $$(call var-with-default,$1_targetdir,$1/build) | ||
422 | +$1_bindir := $$(call var-with-default,$1_bindir,$$($1_targetdir)) | ||
423 | +$1_libdir := $$(call var-with-default,$1_libdir,$$($1_targetdir)) | ||
424 | +$1_install_bindir := $$(call var-with-default,$1_install_bindir,$(install_bindir)) | ||
425 | +$1_install_libdir := $$(call var-with-default,$1_install_libdir,$(install_libdir)) | ||
426 | +$1_version := $$(call var-with-default,$1_version,$(version)) | ||
427 | +$1_soversion := $$(call var-with-default,$1_soversion,$(soversion)) | ||
428 | +$1_caninstall := $$(call var-with-default,$1_caninstall,yes) | ||
429 | +$$(foreach p,$$($1_programs),$$(if $$(filter $(SKIP),$$p),,$$(eval $$(call create-component-targets,$1,$$p,program,$2)))) | ||
430 | +$$(foreach l,$$($1_libraries),$$(if $$(filter $(SKIP),$$l),,$$(eval $$(call create-component-targets,$1,$$l,library,$2)))) | ||
431 | +endif | ||
432 | +endef | ||
433 | + | ||
434 | +# | ||
435 | +# $(call make-component-with-config,$1=project,$2=component,$3=platform,$4=config,$5=component[platform-config]) | ||
436 | +# | ||
437 | +# Defines rules to build the given component with the given platform/configuration | ||
438 | +# | ||
439 | +define make-component-with-config | ||
440 | + | ||
441 | +# | ||
442 | +# Compute the compiler/linker flags. | ||
443 | +# | ||
444 | +$5_cppflags := $$(call var-compound,cppflags,$1,$2,$3,$4,make-flags) | ||
445 | +$5_ldflags := $$(call var-compound,ldflags,$1,$2,$3,$4,make-flags) | ||
446 | + | ||
447 | +# | ||
448 | +# If component specific cppflags are set and multiple components are configured for | ||
449 | +# the project, we build the component objects in a component specific directory. | ||
450 | +# | ||
451 | +# Compute the path of the object directory and add it to the project's | ||
452 | +# list of object directories. | ||
453 | +# | ||
454 | +$5_objdir := $$(call var-value,objdir,$1,$2,$3,$4,make-dirwsuffix) | ||
455 | +$5_objdir := $$($5_objdir)$$(if $$(and $$($1_multicomp),\ | ||
456 | + $$(filter-out $$(call var-compound,cppflags,$1,,$3,$4,make-flags),$$($5_cppflags))),/$$($2_targetname)) | ||
457 | +$1_objdirs += $$($5_objdir) | ||
458 | + | ||
459 | +$5_sources := $$(patsubst $(lang_srcdir)/%,%,$$(call unique,$$(call var-compound,extra_sources,$1,$2,$3,$4) \ | ||
460 | + $$(call var-compound,sources,$1,$2,$3,$4))) | ||
461 | +$5_sources := $$(filter-out $$(patsubst $(lang_srcdir)/%,%,$$(call var-compound,excludes,$1,$2,$3,$4)),$$($5_sources)) | ||
462 | + | ||
463 | +# | ||
464 | +# Computes the list of objects to build based on the sources. | ||
465 | +# | ||
466 | +$5_objects := $$(call unique,$$(addprefix $$($5_objdir)/,$$(call source-to-object,$$($5_sources)))) | ||
467 | + | ||
468 | +ifneq ($$($1_component_with_config_extensions),) | ||
469 | +$$(foreach e,$$($1_component_with_config_extensions),$$(eval $$(call $$e,$1,$2,$3,$4,$5))) | ||
470 | +endif | ||
471 | + | ||
472 | +# | ||
473 | +# Order only prerequisties to ensure the object directory is created | ||
474 | +# before we start building the objects | ||
475 | +# | ||
476 | +$$($5_objdir)/$$(call source-to-dependency,$$($5_sources)): | $$($5_objdir) | ||
477 | + | ||
478 | +# | ||
479 | +# Object rules | ||
480 | +# | ||
481 | +$$(foreach d,$$(call files-to-dirs,$$($5_sources)),$$(eval $$(call make-objects,$$d,$$($1_generated_srcdir),\ | ||
482 | + $$($5_objdir),$$($5_sources),$$($5_dependencies),$$($5_cppflags),$$($$($1_slicecompiler)_targetext),$3,$4))) | ||
483 | + | ||
484 | +# | ||
485 | +# Target rule | ||
486 | +# | ||
487 | +$$(eval $$(call make-$$($5_targetrule),$$($5_targetname),$$($5_targetdir),$$($5_version),$$($5_soversion),\ | ||
488 | + $$($5_objects),$$($5_dependencies),$$($5_ldflags),$3,$4)) | ||
489 | + | ||
490 | +# | ||
491 | +# component[platform-config]_* specific targets | ||
492 | +# | ||
493 | +# NOTE: The component[platform-config] target is specified in create-component-with-config-targets | ||
494 | +# | ||
495 | +.PHONY: $5_clean $5_distclean $5_install | ||
496 | + | ||
497 | +$2:: $5 | ||
498 | + | ||
499 | +$5_clean:: | ||
500 | + $(Q)$(RM) -r $$($5_objdir) | ||
501 | + $(Q)$(RM) $$($5_targets) | ||
502 | + | ||
503 | +# Only clean if platform/configuration matches (this prevents slice2cpp from being cleaned) | ||
504 | +ifneq ($(and $(filter $3,$(platforms)),$(filter $4,$(configs))),) | ||
505 | +$2_clean:: $5_clean | ||
506 | +endif | ||
507 | + | ||
508 | +$5_distclean: | ||
509 | + $(Q)$(RM) $$($5_targets) | ||
510 | + | ||
511 | +$2_distclean:: $5_distclean | ||
512 | + | ||
513 | +ifeq ($$($1_caninstall),yes) | ||
514 | + | ||
515 | +ifeq ($$(filter $$($5_installdir),$$(installdirs)),) | ||
516 | +installdirs += $$($5_installdir) | ||
517 | +$(DESTDIR)$$($5_installdir): | ||
518 | + $(Q)$(MKDIR) -p $$@ | ||
519 | +endif | ||
520 | + | ||
521 | +$5_install:: $$($5_install_targets) | ||
522 | + | ||
523 | +$$(eval $$(call install-$$($5_targetrule),$$($5_targetname),$$($5_targetdir),$$($5_version),$$($5_soversion),$$($5_installdir),$$($2_devinstall))) | ||
524 | + | ||
525 | +ifneq ($$(and $$(filter $3,$$($2_install_platforms)),$$(filter $4,$$($2_install_configs))),) | ||
526 | +$2_install:: $5_install | ||
527 | +endif | ||
528 | + | ||
529 | +endif | ||
530 | + | ||
531 | +endef | ||
532 | + | ||
533 | +# | ||
534 | +# $(call make-component,$1=project,$2=component,$3=type) | ||
535 | +# | ||
536 | +define make-component | ||
537 | + | ||
538 | +# | ||
539 | +# Slice files for a given project are generated in a common generated directory. We | ||
540 | +# don't support generating Slice files with different compiler options for different | ||
541 | +# components in the same project. | ||
542 | +# | ||
543 | +# For single-component projects we allow setting the sliceflags and the component, | ||
544 | +# the flags are moved to the project level in this case. | ||
545 | +# | ||
546 | +ifneq ($$(and $$($2_sliceflags),$$($1_multicomp)),) | ||
547 | +$$(error sliceflags are not supported for $2 component in multi-component project $1) | ||
548 | +else ifneq ($$($2_sliceflags),) | ||
549 | +$1_sliceflags := $$($1_sliceflags) $$($2_sliceflags) | ||
550 | +$2_sliceflags := | ||
551 | +endif | ||
552 | + | ||
553 | +$2_install_platforms := $$(or $$($2_install_platforms),$$($1_install_platforms),$$($2_platforms)) | ||
554 | +$2_install_configs := $$(or $$($2_install_configs),$$($1_install_configs),$$($2_configs)) | ||
555 | + | ||
556 | +# | ||
557 | +# The source directory can be set at the component or project level. | ||
558 | +# | ||
559 | +$2_srcdir := $$(or $$($2_srcdir),$$($1_srcdir)) | ||
560 | + | ||
561 | +# | ||
562 | +# Combine settings set at the project and component levels. | ||
563 | +# | ||
564 | +$2_sliceflags := $$($2_sliceflags) $$($1_sliceflags) | ||
565 | +$2_bisonflags := $$($2_bisonflags) $$($1_bisonflags) | ||
566 | +$2_flexflags := $$($2_flexflags) $$($1_flexflags) | ||
567 | + | ||
568 | +# | ||
569 | +# If we're compiling a library, we check for a ../slice/<component> directory. | ||
570 | +# If it exists, we assume the Slice files from this directory are public and we | ||
571 | +# generate the headers in include/<component>. | ||
572 | +# | ||
573 | +ifeq ($3,library) | ||
574 | +$2_slicedir := $$(or $$($2_slicedir),$$(if $$(wildcard $(slicedir)/$2/*.ice),$(slicedir)/$2)) | ||
575 | +$2_includedir := $$(or $$($2_includedir),$$(if $$(wildcard $(includedir)/$2/*.h),$(includedir)/$2)) | ||
576 | + | ||
577 | +ifneq ($$(filter $(includedir)/%,$$($2_includedir)),) | ||
578 | +# Generate headers in include/generated sub-directory instead of the include directory | ||
579 | +$2_generated_includedir := $$(patsubst $(includedir)/%,$(includedir)/generated/%,$$($2_includedir)) | ||
580 | +else | ||
581 | +$2_generated_includedir := $$(or $$($2_generated_includedir),$$($1_generated_includedir)) | ||
582 | +endif | ||
583 | + | ||
584 | +endif | ||
585 | + | ||
586 | +# | ||
587 | +# If sources are not specified for the component, we search for them in | ||
588 | +# the source directory and eventualy the slice directory if set. | ||
589 | +# | ||
590 | +ifeq ($$($2_sources),) | ||
591 | +$2_sources := $$(foreach e,$(source-extensions),$$(wildcard $$($2_srcdir)/*.$$(e))) | ||
592 | +ifneq ($$($2_slicedir),) | ||
593 | + $2_sources += $$(wildcard $$($2_slicedir)/*.ice) | ||
594 | +endif | ||
595 | +endif | ||
596 | +$2_sources := $$(filter-out $$(patsubst $(lang_srcdir)/%,%,$$($2_excludes)),$$($2_sources)) | ||
597 | + | ||
598 | +# | ||
599 | +# Compute the list of slice files from the sources and gather the location | ||
600 | +# of the slice files. | ||
601 | +# | ||
602 | +$2_slices := $$(filter %.ice,$$($2_sources)) | ||
603 | +$2_slicedirs := $$(call files-to-dirs,$$($2_slices),ice) | ||
604 | + | ||
605 | +# | ||
606 | +# Append the slice directories and slice files which are not in the | ||
607 | +# slice/<component> directory to the project slice directories and | ||
608 | +# list of slice files. | ||
609 | +# | ||
610 | +$1_slicedirs += $$(filter-out $$($2_slicedir),$$($2_slicedirs)) | ||
611 | +$1_slices += $$(filter-out $$($2_slicedir)/%,$$($2_slices)) | ||
612 | + | ||
613 | +# | ||
614 | +# Define slice rules for the component Slice files from $(slicedir)/<component> | ||
615 | +# if it exists. Rules for other slice files are specified at the project level. | ||
616 | +# | ||
617 | +ifneq ($$(and $$($2_components),$$($2_slicedir)),) | ||
618 | + | ||
619 | +# Add an order-only prerequisities on the directory to trigger its creation if it doesn't exist. | ||
620 | +$$($1_generated_srcdir)/$$(call source-to-dependency,$$($2_slices)): | $$($1_generated_srcdir) | ||
621 | + | ||
622 | +ifneq ($$($1_generated_includedir),$$($2_generated_includedir)) | ||
623 | +$$($2_generated_includedir): | ||
624 | + $(Q)$(MKDIR) -p $$@ | ||
625 | +endif | ||
626 | + | ||
627 | +$$(eval $$(call make-slices,$$($2_slicedir),$$($1_generated_srcdir),$$($2_generated_includedir),$$($2_slices),\ | ||
628 | + $$($2_sliceflags),$$($1_slicecompiler))) | ||
629 | + | ||
630 | +$2_generated_headers := $$(call generated-to-header,$$(filter $$($2_slicedir)/%,$$($2_sources))) | ||
631 | +$2_generated_headers := $$(addprefix $$($2_generated_includedir)/,$$($2_generated_headers)) | ||
632 | +$1_generated += $$($2_generated_headers) | ||
633 | + | ||
634 | +endif | ||
635 | + | ||
636 | +ifeq ($(BISON_FLEX),yes) | ||
637 | +$$(eval $$(call make-bison,$$($2_srcdir),$$($2_bisonflags))) | ||
638 | +$$(eval $$(call make-flex,$$($2_srcdir),$$($2_flexflags))) | ||
639 | +endif | ||
640 | + | ||
641 | +ifneq ($$($1_component_extensions),) | ||
642 | +$$(foreach e,$$($1_component_extensions),$$(eval $$(call $$e,$1,$2,$3))) | ||
643 | +endif | ||
644 | + | ||
645 | +# | ||
646 | +# Define per-<platform-config> rules for this component. | ||
647 | +# | ||
648 | +$$(foreach p,$$($2_platforms),\ | ||
649 | + $$(foreach c,$$(filter $$(or $$($$p_configs),%),$$($2_configs)),\ | ||
650 | + $$(if $$(filter $(SKIP),$2[$$p-$$c]),,\ | ||
651 | + $$(eval $$(call make-component-with-config,$1,$2,$$p,$$c,$2[$$p-$$c]))))) | ||
652 | + | ||
653 | +# | ||
654 | +# Component targets to build the component with the specified platforms/configurations | ||
655 | +# | ||
656 | +.PHONY: $2 $2_clean $2_distclean $2_install | ||
657 | + | ||
658 | +$2:: | ||
659 | +$2_clean:: | ||
660 | +$2_install:: | ||
661 | +$2_distclean:: | ||
662 | + | ||
663 | +# | ||
664 | +# Install public header files if building a library | ||
665 | +# | ||
666 | +ifeq ($$($2_devinstall),yes) | ||
667 | +ifneq ($$(and $$($2_components),$(filter library,$3),$$(filter $(includedir)/%,$$($2_includedir))),) | ||
668 | +$$(eval $$(call install-data-files,$$(wildcard $$($2_includedir)/*.h),$(includedir),$(install_includedir),$2_install)) | ||
669 | +ifneq ($$($2_generated_headers),) | ||
670 | +$$(eval $$(call install-data-files,$$($2_generated_headers),$(includedir)/generated,$(install_includedir),$2_install)) | ||
671 | +endif | ||
672 | +endif | ||
673 | +endif | ||
674 | + | ||
675 | +ifneq ($(filter program,$3),) | ||
676 | +$$(eval $$(call install-data-files,$$(wildcard $(top_srcdir)/man/man1/$2.1),$(top_srcdir)/man,$(install_mandir),$2_install)) | ||
677 | +endif | ||
678 | + | ||
679 | +$1:: $2 | ||
680 | +$1_clean:: $2_clean | ||
681 | +$1_install:: $2_install | ||
682 | +$1_distclean:: $2_distclean | ||
683 | + | ||
684 | +endef | ||
685 | + | ||
686 | +# | ||
687 | +# $(call make-project,$1=project) | ||
688 | +# | ||
689 | +define make-project | ||
690 | + | ||
691 | +ifeq ($(filter $(SKIP),$1),) | ||
692 | +$1_objdir := $$(or $$($1_objdir),$1/build) | ||
693 | +$1_srcdir := $$(or $$($1_srcdir),$1) | ||
694 | +$1_generated_srcdir := $$(or $$($1_generated_srcdir),$1/generated) | ||
695 | +$1_generated_includedir := $$(or $$($1_generated_includedir),$1/generated) | ||
696 | + | ||
697 | +# Is this a multi-component project? | ||
698 | +$1_multicomp := $(word 2,$($1_programs) $($1_libraries)) | ||
699 | + | ||
700 | +$1_extensions := $$($1_extensions) $(project_extensions) | ||
701 | +$1_component_extensions := $$($1_component_extensions) $(component_extensions) | ||
702 | +$1_component_with_config_extensions := $$($1_component_with_config_extensions) $(component_with_config_extensions) | ||
703 | + | ||
704 | +# | ||
705 | +# Components add slice and object directories, slice files, generated | ||
706 | +# header files to these variables. This is used to collect the slice | ||
707 | +# directories for which to generate Slice rules. The list of generated | ||
708 | +# header files is used to clean them. | ||
709 | +# | ||
710 | +$1_slicedirs := | ||
711 | +$1_slices := | ||
712 | +$1_generated := | ||
713 | +$1_objdirs := | ||
714 | + | ||
715 | +ifneq ($$($1_extensions),) | ||
716 | +$$(foreach e,$$($1_extensions),$$(eval $$(call $$e,$1))) | ||
717 | +endif | ||
718 | + | ||
719 | +$$(foreach p,$$($1_programs),$$(if $$(filter $(SKIP),$$p),,$$(eval $$(call make-component,$1,$$p,program)))) | ||
720 | +$$(foreach l,$$($1_libraries),$$(if $$(filter $(SKIP),$$l),,$$(eval $$(call make-component,$1,$$l,library)))) | ||
721 | + | ||
722 | +$1_slicedirs := $$(call unique,$$($1_slicedirs)) | ||
723 | +$1_slices := $$(call unique,$$($1_slices)) | ||
724 | +$1_generated := $$(call unique,$$($1_generated)) | ||
725 | +$1_objdirs := $$(call unique,$$($1_objdirs)) | ||
726 | + | ||
727 | +# | ||
728 | +# Create object directories and generated directory if we're not cleaning. | ||
729 | +# | ||
730 | +ifeq ($(filter %clean print,$(MAKECMDGOALS)),) | ||
731 | + | ||
732 | +ifneq ($$($1_objdirs),) | ||
733 | +$$($1_objdirs): | ||
734 | + $(Q)$(MKDIR) -p $$@ | ||
735 | +endif | ||
736 | + | ||
737 | +$$($1_generated_srcdir): | ||
738 | + $(Q)$(MKDIR) -p $$@ | ||
739 | + | ||
740 | +endif | ||
741 | +endif | ||
742 | + | ||
743 | +# | ||
744 | +# Rules for slice files for each of the directories where Slice files are | ||
745 | +# located for this project. | ||
746 | +# | ||
747 | +ifneq ($$($1_slicedirs),) | ||
748 | + | ||
749 | +# Add an order-only prerequisities on the directory to trigger its creation if it doesn't exist. | ||
750 | +$$($1_generated_srcdir)/$$(call source-to-dependency,$$($1_slices)): | $$($1_generated_srcdir) | ||
751 | + | ||
752 | +# Create generated include directory if different from generated source directory | ||
753 | +ifneq ($$($1_generated_includedir),$$($1_generated_srcdir)) | ||
754 | +$$($1_generated_includedir): | ||
755 | + $(Q)$(MKDIR) -p $$@ | ||
756 | +endif | ||
757 | + | ||
758 | +$$(foreach d,$$($1_slicedirs),$$(eval $$(call make-slices,\ | ||
759 | + $$(d),$$($1_generated_srcdir),$$($1_generated_includedir),$$($1_slices),$$($1_sliceflags),$$($1_slicecompiler)))) | ||
760 | + | ||
761 | +$1_generated += $$(addprefix $$($1_generated_includedir)/,$$(call generated-to-header,$$($1_slices))) | ||
762 | + | ||
763 | +endif | ||
764 | + | ||
765 | +# | ||
766 | +# Project targets | ||
767 | +# | ||
768 | +.PHONY: $1 $1_clean $1_install $1_distclean | ||
769 | + | ||
770 | +$1:: | ||
771 | + | ||
772 | +$(abspath $1): $1 | ||
773 | + | ||
774 | +$1_clean:: | ||
775 | + $(E) "Cleaning $1" | ||
776 | + $$(if $$($1_cleanfiles),$(Q)$(RM) $$(addprefix $$($1_srcdir)/,$$($1_cleanfiles))) | ||
777 | + $$(if $$($1_cleandirs),$(Q)$(RM) -r $$(addprefix $$($1_srcdir)/,$$($1_cleandirs))) | ||
778 | + | ||
779 | +$1_install:: | ||
780 | + | ||
781 | +$1_distclean:: | ||
782 | + $(E) "Cleaning $1" | ||
783 | + $(Q)$(RM) -r $$($1_objdir) $$($1_generated_srcdir) | ||
784 | + $$(if $$($1_generated),$(Q)$(RM) $$($1_generated)) | ||
785 | + $$(if $$($1_cleanfiles),$(Q)$(RM) $$($1_cleanfiles)) | ||
786 | + $$(if $$($1_cleandirs),$(Q)$(RM) -r $$($1_cleandirs)) | ||
787 | + | ||
788 | +# | ||
789 | +# Global targets | ||
790 | +# | ||
791 | +all:: $1 | ||
792 | +clean:: $1_clean | ||
793 | +install:: $1_install | ||
794 | +distclean:: $1_distclean | ||
795 | +generate-srcs:: $$($1_generated) | ||
796 | + | ||
797 | +endef | ||
798 | + | ||
799 | +# | ||
800 | +# $(call load-dependencies,$1=projects) | ||
801 | +# | ||
802 | +# Load the given projects and create the project targets | ||
803 | +# | ||
804 | +define load-dependencies | ||
805 | +tmp_projects := $$(projects) | ||
806 | +projects := | ||
807 | + | ||
808 | +include $(addsuffix /Makefile.mk,$1) | ||
809 | + | ||
810 | +$$(foreach p,$$(projects),$$(eval $$(call create-project-targets,$$p))) | ||
811 | + | ||
812 | +projects := $$(tmp_projects) | ||
813 | +endef | ||
814 | + | ||
815 | +# | ||
816 | +# $(call create-project-dependencies,$1=project,$2=home,$3=srcbinsubdir,$4=srcmappingsubdir,$5=libs,$6=programs) | ||
817 | +# | ||
818 | +define create-project-dependencies | ||
819 | +$1_home := $(or $2,$(system-install-dir)) | ||
820 | +$1_system_install := $$(call is-system-install,$$($1_home)) | ||
821 | +$1_src_dist := $$(wildcard $$($1_home)/$3) | ||
822 | +$1_bindir := $$($1_home)$$(if $$($1_src_dist),/$3)/bin | ||
823 | +$1_slicedir := $$($1_home)$$(if $$(or $$($1_system_install),$$(wildcard $$($1_home)/share/ice)),/share/ice)/slice | ||
824 | +$1_libdir := $$(if $$($1_system_install),,$$($1_home)$$(if $$($1_src_dist),/$(or $4,$3))/lib) | ||
825 | +$1_includedir := $$(if $$($1_system_install),,$$($1_home)$$(if $$($1_src_dist),/$(or $4,$3))/include) | ||
826 | +$1_install_bindir := $$($1_bindir) | ||
827 | +$1_install_libdir := $$($1_libdir) | ||
828 | +$1_targetdir := $$($1_home) | ||
829 | +$1_cppflags := $$(if $$($1_includedir),-I$$($1_includedir) $$(if $$($1_src_dist),-I$$($1_includedir)/generated)) | ||
830 | +$1_libraries := $5 | ||
831 | +$1_programs := $6 | ||
832 | +$$(eval $$(call create-project-targets,$1,nobuild)) | ||
833 | +endef | ||
834 | + | ||
835 | +# | ||
836 | +# $(call create-translator-project,$1=project) | ||
837 | +# | ||
838 | +# Defines a project for the given translator | ||
839 | +# | ||
840 | +define create-translator-project | ||
841 | +$1_programs := $(notdir $1) | ||
842 | +$1_dependencies := Slice IceUtil | ||
843 | +$1_cppflags := -I$1 | ||
844 | +$1_targetdir := $(call bindir,$1) | ||
845 | + | ||
846 | +# | ||
847 | +# Only build the translator with the static configuration | ||
848 | +# | ||
849 | +$1_configs := static | ||
850 | + | ||
851 | +# Make sure the static/$(build-platform) are always enabled, the native translators | ||
852 | +# are required to build the sources for foreign architectures | ||
853 | +$(notdir $1)_always_enable_configs := static | ||
854 | +$(notdir $1)_always_enable_platforms := $(build-platform) | ||
855 | + | ||
856 | +# However, don't always install the translator for the $(build-platforms) if it's | ||
857 | +# not explicitly listed in $(PLATFORMS) | ||
858 | +$1_install_platforms := $(call component-platforms,$1,$(notdir $1)) | ||
859 | + | ||
860 | +# | ||
861 | +# Defines the target extension and path of the slice translator | ||
862 | +# component. This is used by make-slices to create a dependency | ||
863 | +# on the translator for slice files. | ||
864 | +# | ||
865 | +$(notdir $1)_targetext := $$(or $$($(notdir $1)_targetext),$(patsubst slice2%,%,$(or $2,$(notdir $1)))) | ||
866 | + | ||
867 | +ifeq ($$(ice_bindir[$(build-platform)]),) | ||
868 | +$(notdir $1)_path = $$($(notdir $1)[$(build-platform)-static]_targetdir)/$(notdir $1) | ||
869 | +else | ||
870 | +$(notdir $1)_path = $$(ice_bindir[$(build-platform)])/$(notdir $1) | ||
871 | +endif | ||
872 | + | ||
873 | +projects += $(project) | ||
874 | +endef | ||
875 | + | ||
876 | +# | ||
877 | +# $(call load-translator-dependencies,$1=project) | ||
878 | +# | ||
879 | +# Define the translator project and create the project targets. | ||
880 | +# | ||
881 | +define load-translator-dependencies | ||
882 | +tmp_projects := $$(projects) | ||
883 | +projects := | ||
884 | +$(call create-translator-project,$1) | ||
885 | +$(call create-project-targets,$1) | ||
886 | +projects := $$(tmp_projects) | ||
887 | +endef | ||
888 | + | ||
889 | +# | ||
890 | +# Validate configs and platforms | ||
891 | +# | ||
892 | +define validate-config | ||
893 | +ifeq ($$(platforms),) | ||
894 | +$$(error invalid platforms $$(PLATFORMS)) | ||
895 | +endif | ||
896 | +ifeq ($$(configs),) | ||
897 | +$$(error invalid configs $$(CONFIGS)) | ||
898 | +endif | ||
899 | +endef | ||
900 | + | ||
901 | +# | ||
902 | +# Create the targets for the given projects and then make the project rules. | ||
903 | +# | ||
904 | +make-projects = $(foreach p,$1,$(eval $(call $(or $(if $($p_type),create-$($p_type)-project-targets),$3,create-project-targets),$p,$4)))\ | ||
905 | + $(if $4,,$(foreach p,$1,$(eval $(call $(or $(if $($p_type),make-$($p_type)-project),$2,make-project),$p)))) | ||
906 | + | ||
907 | +# | ||
908 | +# $(call depend_cppflags,$1=dependencyfile,$2=targetfile) | ||
909 | +# | ||
910 | +depend-cppflags ?= -MT $2 -MMD -MP -MF $1 | ||
911 | + | ||
912 | +# | ||
913 | +# $(call rpath-ldflag,$1=rpath) | ||
914 | +# | ||
915 | +rpath-ldflag ?= -Wl,-rpath,$1 | ||
916 | + | ||
917 | +# | ||
918 | +# $(call mkxxx,$1=libname,$2=version,$3=soversion) | ||
919 | +# | ||
920 | +# Defaults, suitable for most systems | ||
921 | +# | ||
922 | +mklibname ?= lib$(1).a | ||
923 | +mkshlibnametarget ?= $(if $3,$(mksoname),$(mkshlibfilename)) | ||
924 | + | ||
925 | +# | ||
926 | +# Check for system install | ||
927 | +# | ||
928 | +system-install-dir ?= /usr | ||
929 | +is-system-install ?= $(filter $(system-install-dir),$1) | ||
930 | + | ||
931 | +# | ||
932 | +# Helper functions | ||
933 | +# | ||
934 | +dirname = $(patsubst %/,%,$(if $(findstring /,$1),$(dir $1))) | ||
935 | +currentdir = $(call dirname,$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) | ||
936 | +unique = $(strip $(if $1,$(firstword $1) $(call unique,$(filter-out $(firstword $1),$1)))) | ||
937 | +runique = $(strip $(if $1,$(lastword $1) $(call runique,$(filter-out $(lastword $1),$1)))) | ||
938 | +files-to-dirs = $(call unique,$(call dirname,$(filter $(if $2,$(addprefix %.,$2),%),$1))) | ||
939 | + | ||
940 | +empty := | ||
941 | +space := $(empty) $(empty) | ||
942 | +comma := , | ||
943 | + | ||
944 | +escape-ldflags ?= $1 | ||
945 | +unescape-ldflags ?= $1 | ||
946 | + | ||
947 | +mappings = cpp objective-c python ruby php | ||
948 | +mappingdir3 = $(if $(filter $(mappings),$(notdir $1)),$1,$(if $1,$(call mappingdir3,$(call dirname,$1)))) | ||
949 | +mappingdir2 = $(if $(filter ../%,$1),$(call mappingdir2,$(patsubst ../%,%,$1)),$(call mappingdir3,$1)) | ||
950 | +mappingdir = $(patsubst $(lang_srcdir)/%,%,$(if $(filter-out ../%,$1),$2,$(top_srcdir)/$(call mappingdir2,$1)/$2)) | ||
951 | + | ||
952 | +# $(call subconfigs,$1=config) | ||
953 | +subconfigs = $(subst -,$(space),$1) | ||
954 | + | ||
955 | +# $(call var-names,$1=varname,$2=project-or-comp,$3=platform,$4=config) | ||
956 | +var-names = $(if $2,$2[$3-$4]_$1 $2[$3]_$1 $(foreach c,$(call subconfigs,$4),$2[$c]_$1) $2_$1) | ||
957 | + | ||
958 | +# | ||
959 | +# $(call var-value,$1=varname,$2=project,$3=component,$4=platform,$5=config,$6=fn) | ||
960 | +# | ||
961 | +# Returns the value of the given varible name for the given project/component/platform/configuration. | ||
962 | +# It returns the first defined variable from the set of variables returned by var-names defined above. | ||
963 | +# This checks first for component[platform-config]_varname, next for component[platform]_varname, | ||
964 | +# component[subconfig]_varname, ... | ||
965 | +# | ||
966 | +var-valu1 = $(if $(and $1,$(filter undefined,$(origin $(firstword $1)))),$(call var-valu1,$(wordlist 2,$(words $1),$1)),$($(firstword $1))) | ||
967 | +var-valu2 = $6 | ||
968 | +var-value-names = $(call var-names,$1,$3,$4,$5) $(call var-names,$1,$2,$4,$5) $1 | ||
969 | +var-value = $(call $(or $6,var-valu2),$1,$3,$4,$5,$3[$4-$5],$(call var-valu1,$(var-value-names))) | ||
970 | + | ||
971 | +# | ||
972 | +# $(call var-compound,$1=varname,$2=project,$3=component,$4=platform,$5=config,$6=fn) | ||
973 | +# Returns the combination of all the values for the given variable name defined at the | ||
974 | +# project/component/platform/configuration level. | ||
975 | +# | ||
976 | +var-comp-names = $1 $(call var-names,$1,$2,$4,$5) $(call var-names,$1,$3,$4,$5) | ||
977 | +var-rcomp-names = $(call var-names,$1,$3,$4,$5) $(call var-names,$1,$2,$4,$5) $1 | ||
978 | +var-compound = $(call $(or $6,var-valu2),$1,$3,$4,$5,$3[$4-$5],$(strip $(foreach v,$(var-comp-names),$($v)))) | ||
979 | +var-rcompound = $(call $(or $6,var-valu2),$1,$3,$4,$5,$3[$4-$5],$(strip $(foreach v,$(var-rcomp-names),$($v)))) | ||
980 | + | ||
981 | +# | ||
982 | +# Return the given value after applying platform/configuration customization. | ||
983 | +# | ||
984 | +# $(call make-xxx,$1=varname,$2=component,$3=platform,$4=config,$5=$2[$3-$4],$6=value) | ||
985 | +# | ||
986 | +make-dirwsuffix = $(if $6,$(patsubst %/,%,$6$(platform-var)/$(subst $(space),-,$(config-var)))) | ||
987 | +make-targetrule = $(patsubst -%,%,$(subst $(space),-,$(call platform-and-config-var,targetrule,$2,$3,$4,$5,$6))-$6) | ||
988 | +make-targetname = $6$(subst $(space),,$(platform-and-config-var)) | ||
989 | +make-unique = $(call unique,$6) | ||
990 | +make-flags = $6 $(platform-and-config-var) | ||
991 | +make-deps = $(foreach d,$(call unique,$6),$d[$(subst $(space),-,$(call platform-and-config-var,dependency,$2,$3,$4,$5))]) | ||
992 | + | ||
993 | +# | ||
994 | +# $(call var-with-default,varname,defaultvarname) | ||
995 | +# | ||
996 | +# Return the variable value or the default if the variable is not defined | ||
997 | +# | ||
998 | +var-with-default = $(if $(filter undefined,$(origin $1)),$2,$($1)) | ||
999 | + | ||
1000 | +# | ||
1001 | +# $(call get-all-deps,$1=component[platform-config]) | ||
1002 | +# | ||
1003 | +# Get direct and transitive dependencies of the given component | ||
1004 | +# | ||
1005 | +get-all-deps = $(call runique,$($1_dependencies) $(foreach d,$($1_dependencies),$d $(call get-all-deps,$d)),$1) | ||
1006 | + | ||
1007 | +# | ||
1008 | +# Helpers to compute cppflags/ldflags for dependencies, libraries and system libraries | ||
1009 | +# | ||
1010 | +ifeq ($(embedded_runpath),yes) | ||
1011 | +ifeq ($(embedded_runpath_prefix),) | ||
1012 | +# Add rpath relative to the path of the loader if linking with library from different directory. | ||
1013 | +make-rpath-ldflag = $(if $(filter-out $1,$2),\ | ||
1014 | + $(if $(filter /%,$1),\ | ||
1015 | + $(call rpath-ldflag,$1),\ | ||
1016 | + $(call rpath-ldflag,$(loader_path)/$(call relpathfromdir,$(patsubst $(lang_srcdir)/%,%,$2))/$1)),\ | ||
1017 | + $(call rpath-ldflag,$(loader_path))) | ||
1018 | +make-shared-dep-ldflags = $(if $($1_targetdir),$(call make-rpath-ldflag,$($1_targetdir),$($2_targetdir)) -L$($1_targetdir)) -l$($1_targetname) | ||
1019 | +else | ||
1020 | +# Add rpath with $(embedded_runpath_prefix) if linking with library installed in different directory. | ||
1021 | +make-rpath-ldflag = $(if $(filter-out $1,$2),\ | ||
1022 | + $(if $(filter $(prefix)/%,$1),\ | ||
1023 | + $(call rpath-ldflag,$(patsubst $(prefix)/%,$(embedded_runpath_prefix)/%,$1)),\ | ||
1024 | + $(call rpath-ldflag,$1))) | ||
1025 | +make-shared-dep-ldflags = $(call make-rpath-ldflag,$($1_installdir),$($2_installdir)) $(if $($1_targetdir),-L$($1_targetdir)) -l$($1_targetname) | ||
1026 | +endif | ||
1027 | +else | ||
1028 | +make-shared-dep-ldflags = $(if $($1_targetdir),-L$($1_targetdir)) -l$($1_targetname) | ||
1029 | +endif | ||
1030 | + | ||
1031 | +make-static-dep-ldflags = $(if $($1_targetdir),\ | ||
1032 | + $($1_targetdir)/$(call mklibname,$($1_targetname)),\ | ||
1033 | + $(system-install-dir)/lib$(call platform-var,installdir,$1,$($2_platform),$($2_config),$2)/$(call mklibname,$($1_targetname))) | ||
1034 | + | ||
1035 | +make-system-lib-ldflags = $(call escape-ldflags,$($1_system_libs)) | ||
1036 | + | ||
1037 | +make-lib-cppflags = $(foreach l,$($1_libs),$(if $($l_includedir),-I$(call $l_includedir,$l,$1)) $($l_cppflags)) | ||
1038 | +make-lib-ldflags = $(foreach l,$($1_libs),$(if $($l_libdir),-L$(call $l_libdir,$l,$1)) $($l_ldflags)) | ||
1039 | + | ||
1040 | +# | ||
1041 | +# Helper to define third-party library flags | ||
1042 | +# | ||
1043 | +# $(call make-lib,$1=libname) | ||
1044 | +# | ||
1045 | +define make-lib | ||
1046 | +ifneq ($($1_home),) | ||
1047 | +# Check for 3rd party libraries either in home/lib<platform specific subdir> or home/lib | ||
1048 | +$1_installdir = $$($1_home)/lib$$(call platform-var,installdir,$1,$$($$2_platform),$$($$2_config),$$2) | ||
1049 | +$1_libdir ?= $$(strip $$(if $$(wildcard $$($1_installdir)),$$($1_installdir),$$($1_home)/lib)) | ||
1050 | +$1_includedir ?= $$($1_home)/include | ||
1051 | +endif | ||
1052 | +$1_ldflags ?= -l$1 | ||
1053 | +endef | ||
1054 | + | ||
1055 | +# | ||
1056 | +# $(call repathfromdir,path) | ||
1057 | +# | ||
1058 | +# Returns reversed relative path for directory (e.g.: test/Ice/operations | ||
1059 | +# is transformed to ../../..). This is used for rpath computations. | ||
1060 | +# | ||
1061 | +relpathfromdir = $(if $(findstring /,$1),$(call relpathfromdir,$(call dirname,$1))/..,..) | ||
1062 | + | ||
1063 | +# | ||
1064 | +# $(call platform-and-config-var,$1=varname,$2=component,$3=platform,$4=config,$5=comp[platform-config],$6=value) | ||
1065 | +# | ||
1066 | +# Check for platform and configuration specific variable. For example, if variable | ||
1067 | +# is `objdir', for the configuration `cpp11-static' and the `osx' platform, the | ||
1068 | +# resulting value will be: $(osx_objdir) $(cpp11_objdir) $(static_objdir). | ||
1069 | +# | ||
1070 | +# The configuration value is decomposed based on the dash character and the value | ||
1071 | +# of each individual configurations is recomposed with a dash (so for the config | ||
1072 | +# cfg1-cfg2-...-cfgN, we return the value $(cfg1_VAR) $(cfg2_VAR) ... $(cfgN_VAR) | ||
1073 | +# for the variable VAR). | ||
1074 | +# | ||
1075 | +# This also supports default value for platform/configuration variables. So if | ||
1076 | +# osx_objdir isn't defined, we'll use the default value platform_objdir. | ||
1077 | +# | ||
1078 | +var-or-dflt = $(call $(if $(filter-out undefined,$(origin $1_$3[$4])),$1_$3[$4],\ | ||
1079 | + $(if $(filter-out undefined,$(origin $2_$3[$4])),$2_$3[$4],\ | ||
1080 | + $(if $(filter-out undefined,$(origin $1_$3[$($4_project)])),$1_$3[$($4_project)],\ | ||
1081 | + $(if $(filter-out undefined,$(origin $2_$3[$($4_project)])),$2_$3[$($4_project)],\ | ||
1082 | + $(if $(filter-out undefined,$(origin $1_$3)),$1_$3,\ | ||
1083 | + $2_$3))))),$4,$5,$6,$7,$8,$9) | ||
1084 | +platform-var = $(strip $(call var-or-dflt,$3,platform,$1,$2,$3,$4,$5,$6)) | ||
1085 | +config-var = $(strip $(foreach c,$(call subconfigs,$4),$(call var-or-dflt,$c,config,$1,$2,$3,$4,$5,$6,$c))) | ||
1086 | +platform-and-config-var = $(strip $(platform-var) $(config-var)) | ||
1087 | + | ||
1088 | +# | ||
1089 | +# Functions to transform a list of source filenames to generated source/header, object or dependency filenames. | ||
1090 | +# | ||
1091 | +generated-extensions := ice | ||
1092 | +source-extensions := ice y l cpp m mm | ||
1093 | + | ||
1094 | +generated-to-source = $(notdir $(foreach ext,$(generated-extensions),$(patsubst %.$(ext),%.$2,$(filter %.$(ext),$1)))) | ||
1095 | +generated-to-header = $(notdir $(foreach ext,$(generated-extensions),$(patsubst %.$(ext),%.h,$(filter %.$(ext),$1)))) | ||
1096 | +source-to-object = $(notdir $(foreach ext,$(source-extensions),$(patsubst %.$(ext),%.o,$(filter %.$(ext),$1)))) | ||
1097 | +source-to-dependency = $(patsubst %,%.d,$(notdir $1)) | ||
1098 | + | ||
1099 | +# | ||
1100 | +# Configuration variables | ||
1101 | +# | ||
1102 | +# The variables defined below are called with ($1=component,$2=platform,$3=config,$4=$1[$2-$3],$5=value[,$6=subconfig]) | ||
1103 | +# | ||
1104 | + | ||
1105 | +# Defaults for configurations which don't override the specified variable | ||
1106 | +config_targetdir = $(if $(filter %/build,$5),$6) | ||
1107 | +config_objdir = $6 | ||
1108 | +config_dependency = $6 | ||
1109 | + | ||
1110 | +# Static configuration for static builds | ||
1111 | +static_targetrule = $(if $(filter-out program,$($1_target)),static) | ||
1112 | +static_cppflags += $(strip $(call make-lib-cppflags,$4)) -DICE_STATIC_LIBS | ||
1113 | +static_ldflags += $$(call make-ldflags,$$(call get-all-deps,$4),make-static-dep-ldflags,$4,runique)\ | ||
1114 | + $$(call make-ldflags,$4,make-lib-ldflags,$4,unique)\ | ||
1115 | + $$(call make-ldflags,$4,make-system-lib-ldflags,$4,unique)\ | ||
1116 | + $$(call make-ldflags,$$(call get-all-deps,$4),make-lib-ldflags,$4,unique)\ | ||
1117 | + $$(call make-ldflags,$$(call get-all-deps,$4),make-system-lib-ldflags,$4,unique) | ||
1118 | + | ||
1119 | +# Shared configuration for shared builds | ||
1120 | +shared_projects = % | ||
1121 | +shared_objdir = $(if $(filter-out program,$($1_target)),shared/pic,shared/pie) | ||
1122 | +shared_targetrule = $(if $(filter-out program,$($1_target)),shared) | ||
1123 | +shared_cppflags += $(strip $(call make-lib-cppflags,$4)) | ||
1124 | +shared_ldflags += $$(call make-ldflags,$($4_dependencies),make-shared-dep-ldflags,$4,unique)\ | ||
1125 | + $$(call make-ldflags,$4,make-lib-ldflags,$4,unique)\ | ||
1126 | + $$(call make-ldflags,$4,make-system-lib-ldflags,$4,unique) | ||
1127 | + | ||
1128 | +make-ldflags = $(call unescape-ldflags,$(call $4,$(foreach d,$1,$(call $2,$d,$3)))) | ||
1129 | + | ||
1130 | +# | ||
1131 | +# Platform variables | ||
1132 | +# | ||
1133 | +# The variables defined below are called with ($1=component,$2=platform,$3=config,$4=$1[$2-$3]) | ||
1134 | +# | ||
1135 | + | ||
1136 | +# Defaults for platforms which don't override the specified variable | ||
1137 | +platform_cc ?= $(CC) | ||
1138 | +platform_cxx ?= $(CXX) | ||
1139 | +platform_ld ?= $(CXX) | ||
1140 | +platform_ar ?= $(AR) | ||
1141 | +platform_objdir ?= /$2 | ||
1142 | +platform_targetdir ?= /$2 | ||
1143 | +platform_installdir ?= | ||
1144 | +platform_dependency ?= $2 | ||
1145 | + | ||
1146 | +# | ||
1147 | +# The projects variable is used to load projects in Makefile.mk fragments | ||
1148 | +# | ||
1149 | +projects := | ||
1150 | + | ||
1151 | +# | ||
1152 | +# Global targets | ||
1153 | +# | ||
1154 | +.PHONY: all | ||
1155 | +all:: | ||
1156 | + | ||
1157 | +.PHONY: clean | ||
1158 | +clean:: | ||
1159 | + | ||
1160 | +.PHONY: distclean | ||
1161 | +distclean:: | ||
1162 | + | ||
1163 | +.PHONY: install | ||
1164 | +install:: | ||
1165 | + | ||
1166 | +# | ||
1167 | +# Rule to view the value of a variable (e.g.: make debug V=Ice_sources to print out the variable Ice_sources). | ||
1168 | +# | ||
1169 | +print: | ||
1170 | + $(foreach v,$(filter $(V),$(.VARIABLES)),$(warning $v = $($v))) |
make/Make.rules
0 → 100644
1 | +++ a/make/Make.rules | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +# | ||
6 | +# Define ICE_HOME if Ice is not installed in /usr (Linux) or | ||
7 | +# /usr/local (macOS) | ||
8 | +# | ||
9 | +#ICE_HOME ?= /opt/Ice-3.7.2 | ||
10 | + | ||
11 | +# | ||
12 | +# Define OPTIMIZE as yes if you want to build with optimization. | ||
13 | +# The default for the demos is to build with debug information and no | ||
14 | +# optimization. | ||
15 | +# | ||
16 | +#OPTIMIZE = yes | ||
17 | + | ||
18 | +# | ||
19 | +# Define PLATFORMS to the list of platforms to build. This defaults | ||
20 | +# to the first supported platform for this system. | ||
21 | +# | ||
22 | +# Run `make print V=supported-platforms' to see the list of supported | ||
23 | +# platforms on this system. For example, set PLATFORMS to x86 to build | ||
24 | +# for the x86 platform (assuming it's among the supported plaftorms | ||
25 | +# on this system). | ||
26 | +# | ||
27 | +PLATFORMS ?= $(firstword $(supported-platforms)) | ||
28 | + | ||
29 | +# | ||
30 | +# Configurations to build. This defaults to the first supported | ||
31 | +# configuration. | ||
32 | +# | ||
33 | +# Run `make print V=supported-configs` to see the list of supported | ||
34 | +# configurations. | ||
35 | +# | ||
36 | +CONFIGS ?= $(firstword $(supported-configs)) | ||
37 | + | ||
38 | +# ---------------------------------------------------------------------- | ||
39 | +# Don't change anything below this line! | ||
40 | +# ---------------------------------------------------------------------- | ||
41 | + | ||
42 | +os ?= $(shell uname) | ||
43 | +embedded_runpath := yes | ||
44 | + | ||
45 | +include $(top_srcdir)/make/Make.rules.$(os) | ||
46 | +include $(top_srcdir)/make/Make.project.rules | ||
47 | +include $(top_srcdir)/make/Make.demos.rules | ||
48 | + | ||
49 | +# | ||
50 | +# The version/soversion variables are used for versionning plugins built with the demos. | ||
51 | +# | ||
52 | +version = 3.7.2 | ||
53 | +soversion = 37 | ||
54 | +compatversion = $(version) | ||
55 | + | ||
56 | +static_projects = % | ||
57 | + | ||
58 | +# | ||
59 | +# Support for 3rd party libraries | ||
60 | +# | ||
61 | +thirdparties := bz2 | ||
62 | +bz2_home := $(BZ2_HOME) | ||
63 | + | ||
64 | +$(foreach l,$(thirdparties),$(eval $(call make-lib,$l))) |
make/Make.rules.AIX
0 → 100644
1 | +++ a/make/Make.rules.AIX | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +supported-platforms = ppc ppc64 | ||
6 | + | ||
7 | +ppc_cppflags = -q32 -D_LARGE_FILES | ||
8 | +ppc_ldflags = $(ppc_cppflags) | ||
9 | +ppc_targetdir = $(if $(filter %/build,$5),/ppc) | ||
10 | + | ||
11 | +ppc64_cppflags = -q64 | ||
12 | +ppc64_ldflags = $(ppc64_cppflags) | ||
13 | +ppc64_targetdir = $(if $(filter %/build,$5),/ppc64,$(if $(filter-out $($1_target),program),64)) | ||
14 | +ppc64_targetname = $(if $(and $(filter $(bindir)%,$($4_targetdir)),$(filter $($1_target),program)),_64) | ||
15 | + | ||
16 | +shared_cppflags = -brtl | ||
17 | +static_targetdir = $(if $(and $(filter-out %/build,$5),$(filter $($1_target),program)),,static) | ||
18 | + | ||
19 | +platform_cxx = xlC_r | ||
20 | +platform_ld = xlC_r | ||
21 | + | ||
22 | +xlc_compiler = yes | ||
23 | + | ||
24 | +cppflags = -qrtti=all -qstaticinline -qhalt=i $(if $(filter yes,$(OPTIMIZE)),-O2 -DNDEBUG,-g) | ||
25 | +ifeq ($(OPTIMIZE),yes) | ||
26 | + cppflags += -O2 -DNDEBUG | ||
27 | +else | ||
28 | + cppflags += -g | ||
29 | +endif | ||
30 | + | ||
31 | +ifeq ($(embedded_runpath),yes) | ||
32 | + # | ||
33 | + # Our default for embedded runpath prefix on AIX is $(prefix) | ||
34 | + # | ||
35 | + ifeq ($(embedded_runpath_prefix),) | ||
36 | + embedded_runpath_prefix = $(prefix) | ||
37 | + endif | ||
38 | +endif | ||
39 | + | ||
40 | +depend-cppflags = -qmakedep=gcc -MF $1 | ||
41 | +rpath-ldflag = -Wl,-blibpath:$1:/usr/lib | ||
42 | + | ||
43 | +# $(call mklib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform) | ||
44 | +mklib = $(or $($7_ar),$(AR)) -X32_64 cr $1 $2 | ||
45 | + | ||
46 | +# $(call mkshlib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform) | ||
47 | +tmpsofile = $(dir $1)lib$2.so$(if $3,.$3) | ||
48 | +mkshlib ?= $(or $($7_cxx),$(CXX)) -qmkshrobj -o $(call tmpsofile,$1,$3,$5) $2 $6 && \ | ||
49 | + $(or $($7_ar),$(AR)) -X32_64 cr $1 $(call tmpsofile,$1,$3,$5) && \ | ||
50 | + rm $(call tmpsofile,$1,$3,$5) | ||
51 | + | ||
52 | +# | ||
53 | +# $(call mkxxx,$1=libname,$2=version,$3=soversion) | ||
54 | +# | ||
55 | +mkshlibfilename = lib$(1).a | ||
56 | + | ||
57 | +mkpymodulename = $(1).so | ||
58 | + | ||
59 | +Ice_system_libs = -lcrypto | ||
60 | +IceSSL_system_libs = -lssl -lcrypto | ||
61 | +Glacier2CryptPermissionsVerifier_system_libs = -lcrypt |
make/Make.rules.Darwin
0 → 100644
1 | +++ a/make/Make.rules.Darwin | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +supported-platforms = macosx iphoneos iphonesimulator | ||
6 | + | ||
7 | +macosx_ar = libtool | ||
8 | +macosx_cppflags = -mmacosx-version-min=10.9 -arch x86_64 | ||
9 | +macosx_ldflags = $(macosx_cppflags) | ||
10 | +macosx_targetdir = $(if $(filter %/build,$5),/macosx) | ||
11 | + | ||
12 | +iphoneos_ar = libtool | ||
13 | +iphoneos_cc = xcrun -sdk iphoneos clang | ||
14 | +iphoneos_cxx = xcrun -sdk iphoneos clang++ | ||
15 | +iphoneos_cppflags = -miphoneos-version-min=7.1 -arch armv7 -arch arm64 -fembed-bitcode | ||
16 | +iphoneos_ldflags = -miphoneos-version-min=7.1 -arch armv7 -arch arm64 | ||
17 | +iphoneos_configs = %xcodesdk | ||
18 | +iphoneos_targetdir = $(if $(filter %/build,$5),/iphoneos) | ||
19 | + | ||
20 | +iphonesimulator_ar = libtool | ||
21 | +iphonesimulator_cc = xcrun -sdk iphonesimulator clang | ||
22 | +iphonesimulator_cxx = xcrun -sdk iphonesimulator clang++ | ||
23 | +iphonesimulator_cppflags = -mios-simulator-version-min=7.1 -arch i386 -arch x86_64 | ||
24 | +iphonesimulator_ldflags = $(iphonesimulator_cppflags) | ||
25 | +iphonesimulator_configs = %xcodesdk | ||
26 | +iphonesimulator_targetdir = $(if $(filter %/build,$5),/iphonesimulator) | ||
27 | + | ||
28 | +# If building objects for a shared library, enable fPIC | ||
29 | +shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC) -fvisibility=hidden | ||
30 | + | ||
31 | +cppflags = -Wall -Wextra -Wshadow -Wshadow-all -Wredundant-decls \ | ||
32 | + -Wdeprecated -Wstrict-prototypes -Werror -pthread \ | ||
33 | + $(if $(filter yes,$(OPTIMIZE)),-O2 -DNDEBUG,-g) | ||
34 | + | ||
35 | +ifeq ($(MAXWARN),yes) | ||
36 | + cppflags += -Wweak-vtables | ||
37 | +endif | ||
38 | + | ||
39 | +# -Wshadow issues false warnings with clang 3.x (Apple LLVM 9.0) | ||
40 | +ifeq ($(shell clang -v 2>&1 | sed -ne 's/.*version \([0-9]*\)\.\([0-9]*\).*/\1\2/p'),90) | ||
41 | + cppflags := $(filter-out -Wshadow -Wshadow-all,$(cppflags)) | ||
42 | +endif | ||
43 | + | ||
44 | +nodeprecatedwarnings-cppflags := -Wno-deprecated-declarations | ||
45 | +nounusedparameter-cppflags := -Wno-unused-parameter | ||
46 | + | ||
47 | +loader_path = @loader_path | ||
48 | + | ||
49 | +# $(call machoversion,$1=version) | ||
50 | +machoversion = $(subst b,.6,$(subst a,.5,$1)) | ||
51 | + | ||
52 | +# $(call mklib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform) | ||
53 | +mklib = $(or $($7_ar),$(AR)) -static -no_warning_for_no_symbols -o $1 $2 | ||
54 | + | ||
55 | +# $(call mkshlib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform) | ||
56 | +mkshlib = $(or $($7_cxx),$(CXX)) -dynamiclib $(if $5,-install_name @rpath/$(call mkshlibfilename,$3,$4,$5))\ | ||
57 | + $(if $4,-current_version $(call machoversion,$4) -compatibility_version \ | ||
58 | + $(call machoversion,$(if $(filter $4,$(version)),$(compatversion),$4))) \ | ||
59 | + -o $1 $2 $6 | ||
60 | + | ||
61 | +# system install directory | ||
62 | +system-install-dir = /usr/local | ||
63 | + | ||
64 | +# | ||
65 | +# $(call mkxxx,$1=libname,$2=version,$3=soversion) | ||
66 | +# | ||
67 | +mkshlibfilename = lib$1$(if $3,.$3).dylib | ||
68 | +mkshlibname = lib$1.dylib | ||
69 | +mkshlibnametarget = $(mkshlibfilename) | ||
70 | + | ||
71 | +mkpymodulename = $1.so | ||
72 | +mkrbmodulename = $1.bundle | ||
73 | +mkphpmodulename = $1.so | ||
74 | + | ||
75 | +escape-ldflags = $(subst -framework$(space),-framework+,$1) | ||
76 | +unescape-ldflags = $(subst -framework+,-framework$(space),$1) | ||
77 | + | ||
78 | +# | ||
79 | +# System libraries | ||
80 | +# | ||
81 | +Ice_system_libs := -ldl | ||
82 | + | ||
83 | +# Frameworks for macos | ||
84 | +IceSSL[macosx]_system_libs := -framework Security -framework CoreFoundation | ||
85 | + | ||
86 | +# Frameworks requires for iphoneos | ||
87 | +Ice[iphoneos]_system_libs := -framework CFNetwork -framework UIKit -framework Foundation | ||
88 | +IceSSL[iphoneos]_system_libs := -framework Security | ||
89 | +IceIAP[iphoneos]_system_libs := -framework ExternalAccessory | ||
90 | + | ||
91 | +# Same frameworks as iphoneos for iphonesimulator | ||
92 | +Ice[iphonesimulator]_system_libs := $(Ice[iphoneos]_system_libs) | ||
93 | +IceSSL[iphonesimulator]_system_libs := $(IceSSL[iphoneos]_system_libs) | ||
94 | +IceIAP[iphonesimulator]_system_libs := $(IceIAP[iphoneos]_system_libs) | ||
95 | + | ||
96 | +Glacier2CryptPermissionsVerifier[macosx]_system_libs := $(IceSSL[macosx]_system_libs) | ||
97 | +Glacier2CryptPermissionsVerifier[iphoneos]_system_libs := $(IceSSL[iphoneos]_system_libs) | ||
98 | +Glacier2CryptPermissionsVerifier[iphonesimulator]_system_libs := $(IceSSL[iphonesimulator]_system_libs) |
make/Make.rules.Linux
0 → 100644
1 | +++ a/make/Make.rules.Linux | ||
1 | +# | ||
2 | +# Copyright (c) ZeroC, Inc. All rights reserved. | ||
3 | +# | ||
4 | + | ||
5 | +known_distributions := centos rhel fedora debian ubuntu amzn sles | ||
6 | +linux_ids := $(if $(wildcard /etc/os-release),$(shell . /etc/os-release && echo $${ID} $${ID_LIKE}),) | ||
7 | +linux_id := $(word 1,$(or $(filter $(known_distributions),$(linux_ids)),$(linux_ids))) | ||
8 | +is-bin-program = $(and $(filter $(bindir)%,$($4_targetdir)),$(filter $($1_target),program)) | ||
9 | + | ||
10 | +ifneq ($(OECORE_SDK_VERSION),) | ||
11 | + | ||
12 | +build-platform = $(shell uname -m)-build | ||
13 | +target-platform = $(shell echo $(CXX) | sed -r 's/^([a-z0-9_]+)-.*/\1/') | ||
14 | +supported-platforms = $(target-platform) $(build-platform) | ||
15 | +linux_id = yocto | ||
16 | + | ||
17 | +$(build-platform)_cxx := g++ | ||
18 | +$(build-platform)_ld := g++ | ||
19 | +$(build-platform)_ar := ar | ||
20 | +$(build-platform)_ldflags := $($(build-platform)_cppflags) | ||
21 | +$(build-platform)_targetdir = /$(build-platform) | ||
22 | +$(build-platform)_installdir = /$(build-platform) | ||
23 | + | ||
24 | +$(target-platform)_cc = $(CC) | ||
25 | +$(target-platform)_cxx = $(CXX) | ||
26 | +$(target-platform)_libtool = $(AR) | ||
27 | +$(target-platform)_targetdir = $(if $(filter %/build,$5),/$(target-platform)) | ||
28 | +$(target-platform)_installdir = | ||
29 | +$(target-platform)_objdir = /$(target-platform) | ||
30 | + | ||
31 | +# system install directory | ||
32 | +system-install-dir := $(OECORE_TARGET_SYSROOT)/usr | ||
33 | + | ||
34 | +# The Slice translators are under OECORE_NATIVE_SYSTEM tree when building against an Ice | ||
35 | +# distribution from $(OECORE_TARGET_SYSROOT) on the build platform. | ||
36 | +ice_bindir[$(build-platform)] = $(if $(ice_system_install),$(OECORE_NATIVE_SYSROOT)/usr/bin) | ||
37 | + | ||
38 | +else ifneq ($(and $(filter centos rhel fedora,$(linux_id)),$(filter x86_64 i%86,$(shell uname -m))),) | ||
39 | + | ||
40 | +# | ||
41 | +# MultiLib Linux (x64 libraries go in the lib64 directory, x86 executable names are suffixed with 32) | ||
42 | +# | ||
43 | +supported-platforms = x64 x86 | ||
44 | +multilib-platform = yes | ||
45 | + | ||
46 | +ifeq ($(OPTIMIZE),yes) | ||
47 | +# Use default system packaging flags if building with OPTIMIZE and CXXFLAGS/LDFLAGS aren't defined. | ||
48 | +# NOTE: We remove the -m32/-m64 flags since we'll add them below. | ||
49 | +opt-cppflags = $(if $(CXXFLAGS),,$(filter-out -m32 -m64,$(shell setarch $1 rpm --eval %optflags))) | ||
50 | +opt-ldflags = $(if $(LDFLAGS),,$(shell setarch $1 rpm --eval %?__global_ldflags)) | ||
51 | +endif | ||
52 | + | ||
53 | +x64_cppflags := $(call opt-cppflags,x86_64) -m64 | ||
54 | +x64_ldflags := $(call opt-ldflags,x86_64) -m64 | ||
55 | +x64_targetdir = $(if $(filter %/build,$5),/x64,$(if $(filter-out $($1_target),program),64)) | ||
56 | +x64_installdir = $(if $(and $(filter-out $($1_target),program),$(if $5,$(filter-out %64,$5),true)),64) | ||
57 | + | ||
58 | +x86_cppflags := $(call opt-cppflags,i386) -m32 | ||
59 | +x86_ldflags := $(call opt-ldflags,i386) -m32 | ||
60 | +x86_targetdir = $(if $(filter %/build,$5),/x86) | ||
61 | +x86_targetname = $(if $(is-bin-program),32) | ||
62 | + | ||
63 | +# No Slice translators for x86 | ||
64 | +x86_excludes = slice2% | ||
65 | + | ||
66 | +else ifneq ($(filter debian ubuntu,$(linux_id)),) | ||
67 | + | ||
68 | +# | ||
69 | +# MultiArch Linux (libraries are installed in lib/<arch>, executables are installed in bin/<arch> | ||
70 | +# except for the build architecture where executables are installed in bin/). | ||
71 | +# | ||
72 | +build-platform ?= $(shell dpkg --print-architecture) | ||
73 | +foreign-platforms ?= $(shell dpkg --print-foreign-architectures) | ||
74 | + | ||
75 | +supported-platforms = $(build-platform) $(foreign-platforms) | ||
76 | + | ||
77 | +dpkg-arch = $(shell dpkg-architecture -f -a$1 -q$2 2> /dev/null) | ||
78 | + | ||
79 | +ifeq ($(OPTIMIZE),yes) | ||
80 | +# Use default system packaging flags if building with OPTIMIZE and CXXFLAGS/LDFLAGS aren't defined. | ||
81 | +opt-cppflags = $(if $(CXXFLAGS),,$(shell dpkg-buildflags --get CXXFLAGS)) | ||
82 | +opt-ldflags = $(if $(LDFLAGS),,$(shell DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow dpkg-buildflags --get LDFLAGS)) | ||
83 | +endif | ||
84 | + | ||
85 | +# $(call make-platform-config,$1=platform) | ||
86 | +define make-platform-config | ||
87 | +$1_gnu_type = $(call dpkg-arch,$1,DEB_HOST_GNU_TYPE) | ||
88 | +$1_multiarch = $(call dpkg-arch,$1,DEB_HOST_MULTIARCH) | ||
89 | + | ||
90 | +$1_cc = $$($1_gnu_type)-$(CC) | ||
91 | +$1_cxx = $$($1_gnu_type)-$(CXX) | ||
92 | +$1_libtool = $$($1_gnu_type)-$(AR) | ||
93 | +$1_targetdir = /$$($1_multiarch) | ||
94 | +$1_objdir = /$$($1_multiarch) | ||
95 | +$1_installdir = $$(if $$(and $(is-bin-program),$(usr_dir_install)),,/$$($1_multiarch)) | ||
96 | + | ||
97 | +# | ||
98 | +# Disable ABI compatibility warnings for armhf using -Wno-psabi | ||
99 | +# | ||
100 | +$1_cppflags = $(opt-cppflags) $(if $(filter $1,armhf),-Wno-psabi) | ||
101 | +$1_ldflags = $(opt-ldflags) | ||
102 | +endef | ||
103 | + | ||
104 | +$(foreach p,$(supported-platforms),$(eval $(call make-platform-config,$p))) | ||
105 | + | ||
106 | +# For the build platform architecture, build and install executables in bin, libraries in lib/<arch> | ||
107 | +$(build-platform)_targetdir = $(if $(or $(filter %/build,$5),$(filter-out $($1_target),program)),/$($2_multiarch)) | ||
108 | +$(build-platform)_installdir = $(if $(is-bin-program),,/$($2_multiarch)) | ||
109 | + | ||
110 | +else | ||
111 | + | ||
112 | +# | ||
113 | +# Single architecture Linux | ||
114 | +# | ||
115 | +ifeq ($(OPTIMIZE),yes) | ||
116 | + # Use default system packaging flags if building with OPTIMIZE and CXXFLAGS/LDFLAGS aren't defined. | ||
117 | + ifneq ($(filter amzn sles,$(linux_id)),) | ||
118 | + opt-cppflags = $(if $(CXXFLAGS),,$(shell setarch $1 rpm --eval %optflags)) | ||
119 | + opt-ldflags = $(if $(LDFLAGS),,$(shell setarch $1 rpm --eval %?__global_ldflags)) | ||
120 | + else | ||
121 | + opt-cppflags = $(if $(CXXFLAGS),,-O2) | ||
122 | + endif | ||
123 | +endif | ||
124 | + | ||
125 | +build-platform = $(if $(filter arm%,$(shell uname -m)),arm,$(shell uname -m)) | ||
126 | +supported-platforms = $(build-platform) | ||
127 | +lib-suffix = $(if $(filter %64,$(build-platform)),64,) | ||
128 | + | ||
129 | +$(build-platform)_cppflags := $(call opt-cppflags,$(build-platform)) | ||
130 | +$(build-platform)_ldflags := $(call opt-ldflags,$(build-platform)) | ||
131 | +$(build-platform)_targetdir = $(if $(filter %/build,$5),/$(build-platform),$(if $(filter-out $($1_target),program),$(lib-suffix))) | ||
132 | +$(build-platform)_installdir = $(if $(and $(filter-out $($1_target),program),$(if $5,$(filter-out %$(lib-suffix),$5),true)),$(lib-suffix)) | ||
133 | + | ||
134 | +endif | ||
135 | + | ||
136 | +rpath-link-ldflag = -Wl,-rpath-link,$1 | ||
137 | +make-rpath-link-ldflags = $(foreach d,$(filter-out $2,$(call get-all-deps,$1)),$(call rpath-link-ldflag,$($d_targetdir))) | ||
138 | + | ||
139 | +# If building objects for a shared library build, enable PIC or PIE: | ||
140 | +shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC,-fPIE) -fvisibility=hidden | ||
141 | + | ||
142 | +# If we are linking a program, add -rpath-link to locate secondary libraries that aren't linked with the executable. | ||
143 | +shared_ldflags = $(if $(filter-out program,$($1_target)),\ | ||
144 | + $(if $(filter yes,$(allow-undefined-symbols)),,-Wl$(comma)--no-undefined),\ | ||
145 | + -pie $(if $(filter yes,$(new_dtags)),-Wl$(comma)--enable-new-dtags,-Wl$(comma)--disable-new-dtags) \ | ||
146 | + $$(call unique,$$(foreach d,$($4_dependencies),$$(call make-rpath-link-ldflags,$$d,$($4_dependencies))))) | ||
147 | + | ||
148 | +cppflags = -Wall -Wextra -Wredundant-decls -Wshadow -Wdeprecated -Werror -pthread $(if $(filter yes,$(OPTIMIZE)),-DNDEBUG,-g) | ||
149 | +ldflags = -pthread | ||
150 | + | ||
151 | +# -Wshadow is too strict with gcc 4 | ||
152 | +ifeq ($(shell $(CXX) -dumpversion | cut -f1 -d\.),4) | ||
153 | + cppflags := $(filter-out -Wshadow,$(cppflags)) | ||
154 | +endif | ||
155 | + | ||
156 | +nodeprecatedwarnings-cppflags := -Wno-deprecated-declarations | ||
157 | +nounusedparameter-cppflags := -Wno-unused-parameter | ||
158 | + | ||
159 | +loader_path = \$$ORIGIN | ||
160 | + | ||
161 | +# $(call mklib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform) | ||
162 | +mklib = $(or $($7_ar),$(AR)) cr $1 $2 | ||
163 | + | ||
164 | +# $(call mkshlib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform) | ||
165 | +mkshlib = $(or $($7_cxx),$(CXX)) -shared $(if $5,-Wl$(comma)-h$(comma)$(call mksoname,$3,$4,$5)) -o $1 $2 $6 | ||
166 | + | ||
167 | +# | ||
168 | +# $(call mkxxx,$1=libname,$2=version,$3=soversion) | ||
169 | +# | ||
170 | +mksoname = lib$(1).so$(if $3,.$3) | ||
171 | +mkshlibfilename = lib$(1).so$(if $2,.$2) | ||
172 | +mkshlibname = lib$(1).so | ||
173 | + | ||
174 | +# Clear the iconv ldflags, iconv is part of libc on Linux | ||
175 | +iconv_ldflags := | ||
176 | + | ||
177 | +# | ||
178 | +# With GCC < 6.1, libbacktrace crash with a SEGV for -pie exes linked with debug-stripped libs | ||
179 | +# See https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00132.html | ||
180 | +# Here we assume only release builds occasionally get -g and later get stripped | ||
181 | +# TODO: enable libbacktrace for release builds with GCC >= 6.1 | ||
182 | +ifneq ($(OPTIMIZE),yes) | ||
183 | +libbacktrace_fullpath := $(shell $(CXX) --print-file-name=libbacktrace.a) | ||
184 | +ifneq ($(libbacktrace_fullpath),libbacktrace.a) | ||
185 | + libbacktrace = yes | ||
186 | +endif | ||
187 | +endif | ||
188 | + | ||
189 | +IceUtil_system_libs = -lrt $(if $(filter yes,$(libbacktrace)),-lbacktrace) | ||
190 | +Ice_system_libs = -ldl -lcrypto $(IceUtil_system_libs) | ||
191 | +ifeq ($(shell pkg-config --exists libsystemd 2> /dev/null && echo yes),yes) | ||
192 | +Ice_system_libs += $(shell pkg-config --libs libsystemd) | ||
193 | +endif | ||
194 | +IceSSL_system_libs = -lssl -lcrypto | ||
195 | +Glacier2CryptPermissionsVerifier_system_libs = -lcrypt | ||
196 | + | ||
197 | +# | ||
198 | +# On supported platforms and if Bluez and DBus are installed, we set the IceBT | ||
199 | +# system libraries. The build system checks for this variable to build or not | ||
200 | +# the IceBT plugin, demos, ... | ||
201 | +# | ||
202 | +ifneq ($(filter debian ubuntu yocto poky,$(linux_id)),) | ||
203 | +ifeq ($(shell pkg-config --exists bluez dbus-1 2> /dev/null && echo yes),yes) | ||
204 | +IceBT_system_libs = $(IceSSL_system_libs) $(shell pkg-config --libs dbus-1) | ||
205 | +endif | ||
206 | +endif |