The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

701 lines
28KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. class MakefileProjectExporter : public ProjectExporter
  18. {
  19. protected:
  20. //==============================================================================
  21. class MakeBuildConfiguration : public BuildConfiguration
  22. {
  23. public:
  24. MakeBuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e)
  25. : BuildConfiguration (p, settings, e)
  26. {
  27. }
  28. Value getArchitectureType() { return getValue (Ids::linuxArchitecture); }
  29. var getArchitectureTypeVar() const { return config [Ids::linuxArchitecture]; }
  30. var getDefaultOptimisationLevel() const override { return var ((int) (isDebug() ? gccO0 : gccO3)); }
  31. void createConfigProperties (PropertyListBuilder& props) override
  32. {
  33. addGCCOptimisationProperty (props);
  34. static const char* const archNames[] = { "(Default)", "<None>", "32-bit (-m32)", "64-bit (-m64)", "ARM v6", "ARM v7" };
  35. const var archFlags[] = { var(), var (String()), "-m32", "-m64", "-march=armv6", "-march=armv7" };
  36. props.add (new ChoicePropertyComponent (getArchitectureType(), "Architecture",
  37. StringArray (archNames, numElementsInArray (archNames)),
  38. Array<var> (archFlags, numElementsInArray (archFlags))));
  39. }
  40. String getLibrarySubdirPath () const override
  41. {
  42. const String archFlag = getArchitectureTypeVar();
  43. const auto prefix = String ("-march=");
  44. if (archFlag.startsWith (prefix))
  45. return archFlag.substring (prefix.length());
  46. else if (archFlag == "-m64")
  47. return "x86_64";
  48. else if (archFlag == "-m32")
  49. return "i386";
  50. else
  51. return "$(shell uname -m)";
  52. }
  53. };
  54. BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override
  55. {
  56. return new MakeBuildConfiguration (project, tree, *this);
  57. }
  58. public:
  59. //==============================================================================
  60. class MakefileTarget : public ProjectType::Target
  61. {
  62. public:
  63. MakefileTarget (ProjectType::Target::Type targetType, const MakefileProjectExporter& exporter)
  64. : ProjectType::Target (targetType), owner (exporter)
  65. {}
  66. StringArray getTargetSettings (const BuildConfiguration& config) const
  67. {
  68. if (type == AggregateTarget)
  69. // the aggregate target should not specify any settings at all!
  70. // it just defines dependencies on the other targets.
  71. return StringArray();
  72. StringPairArray commonOptions = owner.getAllPreprocessorDefs (config, ProjectType::Target::unspecified);
  73. StringPairArray targetSpecific = owner.getAllPreprocessorDefs (config, type);
  74. StringArray defs;
  75. // remove any defines that have already been added by the configuration
  76. const int n = targetSpecific.size();
  77. for (int i = 0 ; i < n; ++i)
  78. {
  79. const String& key = targetSpecific.getAllKeys()[i];
  80. if (! commonOptions.getAllKeys().contains (key))
  81. defs.add (String ("-D") + key + String ("=") + targetSpecific.getAllValues()[i]);
  82. }
  83. StringArray s;
  84. const String cppflagsVarName = String ("JUCE_CPPFLAGS_") + getTargetVarName();
  85. s.add (cppflagsVarName + String (" := ") + defs.joinIntoString (" "));
  86. if (getTargetFileType() == sharedLibraryOrDLL || getTargetFileType() == pluginBundle)
  87. {
  88. s.add (String ("JUCE_CFLAGS_") + getTargetVarName() + String (" := -fPIC"));
  89. const String ldflagsVarName = String ("JUCE_LDFLAGS_") + getTargetVarName();
  90. String targetLinkOptions = ldflagsVarName + String (" := -shared");
  91. if (getTargetFileType() == pluginBundle)
  92. targetLinkOptions += " -Wl,--no-undefined";
  93. s.add (targetLinkOptions);
  94. }
  95. String targetName (owner.replacePreprocessorTokens (config, config.getTargetBinaryNameString()));
  96. if (owner.projectType.isStaticLibrary() || owner.projectType.isDynamicLibrary())
  97. targetName = getLibbedFilename (targetName);
  98. else
  99. targetName = targetName.upToLastOccurrenceOf (".", false, false) + getTargetFileSuffix();
  100. s.add (String ("JUCE_TARGET_") + getTargetVarName() + String (" := ") + escapeSpaces (targetName));
  101. return s;
  102. }
  103. String getTargetFileSuffix() const
  104. {
  105. switch (type)
  106. {
  107. case VSTPlugIn:
  108. return ".so";
  109. case VST3PlugIn:
  110. return ".vst3";
  111. case SharedCodeTarget:
  112. return ".a";
  113. default:
  114. break;
  115. }
  116. return String();
  117. }
  118. String getTargetVarName() const
  119. {
  120. return String (getName()).toUpperCase().replaceCharacter (L' ', L'_');
  121. }
  122. void writeObjects (OutputStream& out) const
  123. {
  124. Array<RelativePath> targetFiles;
  125. for (int i = 0; i < owner.getAllGroups().size(); ++i)
  126. findAllFilesToCompile (owner.getAllGroups().getReference(i), targetFiles);
  127. out << "OBJECTS_" + getTargetVarName() + String (" := \\") << newLine;
  128. for (int i = 0; i < targetFiles.size(); ++i)
  129. out << " $(JUCE_OBJDIR)/" << escapeSpaces (owner.getObjectFileFor (targetFiles.getReference(i))) << " \\" << newLine;
  130. out << newLine;
  131. }
  132. void findAllFilesToCompile (const Project::Item& projectItem, Array<RelativePath>& results) const
  133. {
  134. if (projectItem.isGroup())
  135. {
  136. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  137. findAllFilesToCompile (projectItem.getChild(i), results);
  138. }
  139. else
  140. {
  141. if (projectItem.shouldBeCompiled())
  142. {
  143. const Type targetType = (owner.getProject().getProjectType().isAudioPlugin() ? type : SharedCodeTarget);
  144. const File f = projectItem.getFile();
  145. RelativePath relativePath (f, owner.getTargetFolder(), RelativePath::buildTargetFolder);
  146. if (owner.shouldFileBeCompiledByDefault (relativePath)
  147. && owner.getProject().getTargetTypeFromFilePath (f, true) == targetType)
  148. results.add (relativePath);
  149. }
  150. }
  151. }
  152. void addFiles (OutputStream& out)
  153. {
  154. Array<RelativePath> targetFiles;
  155. for (int i = 0; i < owner.getAllGroups().size(); ++i)
  156. findAllFilesToCompile (owner.getAllGroups().getReference(i), targetFiles);
  157. const String cppflagsVarName = String ("JUCE_CPPFLAGS_") + getTargetVarName();
  158. const String cflagsVarName = String ("JUCE_CFLAGS_") + getTargetVarName();
  159. for (int i = 0; i < targetFiles.size(); ++i)
  160. {
  161. jassert (targetFiles.getReference(i).getRoot() == RelativePath::buildTargetFolder);
  162. out << "$(JUCE_OBJDIR)/" << escapeSpaces (owner.getObjectFileFor (targetFiles.getReference(i)))
  163. << ": " << escapeSpaces (targetFiles.getReference(i).toUnixStyle()) << newLine
  164. << "\t-$(V_AT)mkdir -p $(JUCE_OBJDIR)" << newLine
  165. << "\t@echo \"Compiling " << targetFiles.getReference(i).getFileName() << "\"" << newLine
  166. << (targetFiles.getReference(i).hasFileExtension ("c;s;S") ? "\t$(V_AT)$(CC) $(JUCE_CFLAGS)" : "\t$(V_AT)$(CXX) $(JUCE_CXXFLAGS) ")
  167. << "$(" << cppflagsVarName << ") $(" << cflagsVarName << ") -o \"$@\" -c \"$<\""
  168. << newLine << newLine;
  169. }
  170. }
  171. String getBuildProduct() const
  172. {
  173. return String ("$(JUCE_OUTDIR)/$(JUCE_TARGET_") + getTargetVarName() + String (")");
  174. }
  175. void writeTargetLine (OutputStream& out, const bool useLinuxPackages)
  176. {
  177. jassert (type != AggregateTarget);
  178. out << getBuildProduct() << " : "
  179. << ((useLinuxPackages) ? "check-pkg-config " : "")
  180. << "$(OBJECTS_" << getTargetVarName() << ") $(RESOURCES)";
  181. if (type != SharedCodeTarget && owner.shouldBuildTargetType (SharedCodeTarget))
  182. out << " $(JUCE_OUTDIR)/$(JUCE_TARGET_SHARED_CODE)";
  183. out << newLine << "\t@echo Linking \"" << owner.projectName << " (" << getName() << ")\"" << newLine
  184. << "\t-$(V_AT)mkdir -p $(JUCE_BINDIR)" << newLine
  185. << "\t-$(V_AT)mkdir -p $(JUCE_LIBDIR)" << newLine
  186. << "\t-$(V_AT)mkdir -p $(JUCE_OUTDIR)" << newLine;
  187. if (owner.projectType.isStaticLibrary() || type == SharedCodeTarget)
  188. out << "\t$(V_AT)$(AR) -rcs " << getBuildProduct()
  189. << " $(OBJECTS_" << getTargetVarName() << ")" << newLine;
  190. else
  191. {
  192. out << "\t$(V_AT)$(CXX) -o " << getBuildProduct()
  193. << " $(OBJECTS_" << getTargetVarName() << ") ";
  194. if (owner.shouldBuildTargetType (SharedCodeTarget))
  195. out << "$(JUCE_OUTDIR)/$(JUCE_TARGET_SHARED_CODE) ";
  196. out << "$(JUCE_LDFLAGS) ";
  197. if (getTargetFileType() == sharedLibraryOrDLL || getTargetFileType() == pluginBundle)
  198. out << "$(JUCE_LDFLAGS_" << getTargetVarName() << ") ";
  199. out << "$(RESOURCES) $(TARGET_ARCH)" << newLine;
  200. }
  201. out << newLine;
  202. }
  203. const MakefileProjectExporter& owner;
  204. };
  205. //==============================================================================
  206. static const char* getNameLinux() { return "Linux Makefile"; }
  207. static const char* getValueTreeTypeName() { return "LINUX_MAKE"; }
  208. Value getExtraPkgConfig() { return getSetting (Ids::linuxExtraPkgConfig); }
  209. String getExtraPkgConfigString() const { return getSettingString (Ids::linuxExtraPkgConfig); }
  210. static MakefileProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  211. {
  212. if (settings.hasType (getValueTreeTypeName()))
  213. return new MakefileProjectExporter (project, settings);
  214. return nullptr;
  215. }
  216. //==============================================================================
  217. MakefileProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t)
  218. {
  219. name = getNameLinux();
  220. if (getTargetLocationString().isEmpty())
  221. getTargetLocationValue() = getDefaultBuildsRootFolder() + "LinuxMakefile";
  222. initialiseDependencyPathValues();
  223. }
  224. //==============================================================================
  225. bool canLaunchProject() override { return false; }
  226. bool launchProject() override { return false; }
  227. bool usesMMFiles() const override { return false; }
  228. bool canCopeWithDuplicateFiles() override { return false; }
  229. bool supportsUserDefinedConfigurations() const override { return true; }
  230. bool isXcode() const override { return false; }
  231. bool isVisualStudio() const override { return false; }
  232. bool isCodeBlocks() const override { return false; }
  233. bool isMakefile() const override { return true; }
  234. bool isAndroidStudio() const override { return false; }
  235. bool isAndroidAnt() const override { return false; }
  236. bool isAndroid() const override { return false; }
  237. bool isWindows() const override { return false; }
  238. bool isLinux() const override { return true; }
  239. bool isOSX() const override { return false; }
  240. bool isiOS() const override { return false; }
  241. bool supportsTargetType (ProjectType::Target::Type type) const override
  242. {
  243. switch (type)
  244. {
  245. case ProjectType::Target::GUIApp:
  246. case ProjectType::Target::ConsoleApp:
  247. case ProjectType::Target::StaticLibrary:
  248. case ProjectType::Target::SharedCodeTarget:
  249. case ProjectType::Target::AggregateTarget:
  250. case ProjectType::Target::VSTPlugIn:
  251. case ProjectType::Target::StandalonePlugIn:
  252. case ProjectType::Target::DynamicLibrary:
  253. return true;
  254. default:
  255. break;
  256. }
  257. return false;
  258. }
  259. Value getCppStandardValue() { return getSetting (Ids::cppLanguageStandard); }
  260. String getCppStandardString() const { return settings[Ids::cppLanguageStandard]; }
  261. void createExporterProperties (PropertyListBuilder& properties) override
  262. {
  263. static const char* cppStandardNames[] = { "C++03", "C++11", "C++14", nullptr };
  264. static const char* cppStandardValues[] = { "-std=c++03", "-std=c++11", "-std=c++14", nullptr };
  265. properties.add (new ChoicePropertyComponent (getCppStandardValue(),
  266. "C++ standard to use",
  267. StringArray (cppStandardNames),
  268. Array<var> (cppStandardValues)),
  269. "The C++ standard to specify in the makefile");
  270. properties.add (new TextPropertyComponent (getExtraPkgConfig(), "pkg-config libraries", 8192, false),
  271. "Extra pkg-config libraries for you application. Each package should be space separated.");
  272. }
  273. //==============================================================================
  274. bool anyTargetIsSharedLibrary() const
  275. {
  276. const int n = targets.size();
  277. for (int i = 0; i < n; ++i)
  278. {
  279. const ProjectType::Target::TargetFileType fileType = targets.getUnchecked (i)->getTargetFileType();
  280. if (fileType == ProjectType::Target::sharedLibraryOrDLL || fileType == ProjectType::Target::pluginBundle)
  281. return true;
  282. }
  283. return false;
  284. }
  285. //==============================================================================
  286. void create (const OwnedArray<LibraryModule>&) const override
  287. {
  288. MemoryOutputStream mo;
  289. writeMakefile (mo);
  290. overwriteFileIfDifferentOrThrow (getTargetFolder().getChildFile ("Makefile"), mo);
  291. }
  292. //==============================================================================
  293. void addPlatformSpecificSettingsForProjectType (const ProjectType&) override
  294. {
  295. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  296. {
  297. if (MakefileTarget* target = new MakefileTarget (targetType, *this))
  298. {
  299. if (targetType == ProjectType::Target::AggregateTarget)
  300. targets.insert (0, target);
  301. else
  302. targets.add (target);
  303. }
  304. });
  305. // If you hit this assert, you tried to generate a project for an exporter
  306. // that does not support any of your targets!
  307. jassert (targets.size() > 0);
  308. }
  309. private:
  310. //==============================================================================
  311. void writeDefineFlags (OutputStream& out, const BuildConfiguration& config) const
  312. {
  313. StringPairArray defines;
  314. defines.set ("LINUX", "1");
  315. if (config.isDebug())
  316. {
  317. defines.set ("DEBUG", "1");
  318. defines.set ("_DEBUG", "1");
  319. }
  320. else
  321. {
  322. defines.set ("NDEBUG", "1");
  323. }
  324. out << createGCCPreprocessorFlags (mergePreprocessorDefs (defines, getAllPreprocessorDefs (config, ProjectType::Target::unspecified)));
  325. }
  326. void writeHeaderPathFlags (OutputStream& out, const BuildConfiguration& config) const
  327. {
  328. StringArray searchPaths (extraSearchPaths);
  329. searchPaths.addArray (config.getHeaderSearchPaths());
  330. StringArray packages;
  331. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  332. packages.removeEmptyStrings();
  333. if (linuxPackages.size() > 0 || packages.size() > 0)
  334. {
  335. out << " $(shell pkg-config --cflags";
  336. for (int i = 0; i < linuxPackages.size(); ++i)
  337. out << " " << linuxPackages[i];
  338. for (int i = 0; i < packages.size(); ++i)
  339. out << " " << packages[i];
  340. out << ")";
  341. }
  342. if (linuxLibs.contains("pthread"))
  343. out << " -pthread";
  344. searchPaths = getCleanedStringArray (searchPaths);
  345. // Replace ~ character with $(HOME) environment variable
  346. for (int i = 0; i < searchPaths.size(); ++i)
  347. out << " -I" << escapeSpaces (FileHelpers::unixStylePath (replacePreprocessorTokens (config, searchPaths[i]))).replace ("~", "$(HOME)");
  348. }
  349. void writeCppFlags (OutputStream& out, const BuildConfiguration& config) const
  350. {
  351. out << " JUCE_CPPFLAGS := $(DEPFLAGS)";
  352. writeDefineFlags (out, config);
  353. writeHeaderPathFlags (out, config);
  354. out << " $(CPPFLAGS)" << newLine;
  355. }
  356. void writeLinkerFlags (OutputStream& out, const BuildConfiguration& config) const
  357. {
  358. out << " JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR)";
  359. {
  360. StringArray flags (makefileExtraLinkerFlags);
  361. if (! config.isDebug())
  362. flags.add ("-fvisibility=hidden");
  363. if (flags.size() > 0)
  364. out << " " << getCleanedStringArray (flags).joinIntoString (" ");
  365. }
  366. out << config.getGCCLibraryPathFlags();
  367. StringArray packages;
  368. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  369. packages.removeEmptyStrings();
  370. if (linuxPackages.size() > 0 || packages.size() > 0)
  371. {
  372. out << " $(shell pkg-config --libs";
  373. for (int i = 0; i < linuxPackages.size(); ++i)
  374. out << " " << linuxPackages[i];
  375. for (int i = 0; i < packages.size(); ++i)
  376. out << " " << packages[i];
  377. out << ")";
  378. }
  379. for (int i = 0; i < linuxLibs.size(); ++i)
  380. out << " -l" << linuxLibs[i];
  381. StringArray libraries;
  382. libraries.addTokens (getExternalLibrariesString(), ";", "\"'");
  383. libraries.removeEmptyStrings();
  384. if (libraries.size() != 0)
  385. out << " -l" << replacePreprocessorTokens (config, libraries.joinIntoString (" -l")).trim();
  386. out << " " << replacePreprocessorTokens (config, getExtraLinkerFlagsString()).trim()
  387. << " $(LDFLAGS)" << newLine;
  388. }
  389. void writeTargetLines (OutputStream& out, const bool useLinuxPackages) const
  390. {
  391. const int n = targets.size();
  392. for (int i = 0; i < n; ++i)
  393. {
  394. if (MakefileTarget* target = targets.getUnchecked (i))
  395. {
  396. if (target->type == ProjectType::Target::AggregateTarget)
  397. {
  398. StringArray dependencies;
  399. for (int j = 0; j < n; ++j)
  400. {
  401. if (i == j) continue;
  402. if (MakefileTarget* dependency = targets.getUnchecked (j))
  403. {
  404. if (dependency->type != ProjectType::Target::SharedCodeTarget)
  405. dependencies.add (dependency->getBuildProduct());
  406. }
  407. }
  408. out << "all : " << dependencies.joinIntoString (" ") << newLine << newLine;
  409. }
  410. else
  411. target->writeTargetLine (out, useLinuxPackages);
  412. }
  413. }
  414. }
  415. void writeConfig (OutputStream& out, const BuildConfiguration& config) const
  416. {
  417. const String buildDirName ("build");
  418. const String intermediatesDirName (buildDirName + "/intermediate/" + config.getName());
  419. String outputDir (buildDirName);
  420. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  421. {
  422. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  423. outputDir = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder).toUnixStyle();
  424. }
  425. out << "ifeq ($(CONFIG)," << escapeSpaces (config.getName()) << ")" << newLine;
  426. out << " JUCE_BINDIR := " << escapeSpaces (buildDirName) << newLine
  427. << " JUCE_LIBDIR := " << escapeSpaces (buildDirName) << newLine
  428. << " JUCE_OBJDIR := " << escapeSpaces (intermediatesDirName) << newLine
  429. << " JUCE_OUTDIR := " << escapeSpaces (outputDir) << newLine
  430. << newLine
  431. << " ifeq ($(TARGET_ARCH),)" << newLine
  432. << " TARGET_ARCH := " << getArchFlags (config) << newLine
  433. << " endif" << newLine
  434. << newLine;
  435. writeCppFlags (out, config);
  436. for (auto target : targets)
  437. {
  438. StringArray lines = target->getTargetSettings (config);
  439. if (lines.size() > 0)
  440. out << " " << lines.joinIntoString ("\n ") << newLine;
  441. out << newLine;
  442. }
  443. out << " JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH)";
  444. if (anyTargetIsSharedLibrary())
  445. out << " -fPIC";
  446. if (config.isDebug())
  447. out << " -g -ggdb";
  448. out << " -O" << config.getGCCOptimisationFlag()
  449. << (" " + replacePreprocessorTokens (config, getExtraCompilerFlagsString())).trimEnd()
  450. << " $(CFLAGS)" << newLine;
  451. String cppStandardToUse (getCppStandardString());
  452. if (cppStandardToUse.isEmpty())
  453. cppStandardToUse = "-std=c++11";
  454. out << " JUCE_CXXFLAGS += $(CXXFLAGS) $(JUCE_CFLAGS) "
  455. << cppStandardToUse << " $(CXXFLAGS)" << newLine;
  456. writeLinkerFlags (out, config);
  457. out << newLine;
  458. out << " CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR)" << newLine
  459. << "endif" << newLine
  460. << newLine;
  461. }
  462. void writeMakefile (OutputStream& out) const
  463. {
  464. out << "# Automatically generated makefile, created by the Projucer" << newLine
  465. << "# Don't edit this file! Your changes will be overwritten when you re-save the Projucer project!" << newLine
  466. << newLine;
  467. out << "# build with \"V=1\" for verbose builds" << newLine
  468. << "ifeq ($(V), 1)" << newLine
  469. << "V_AT =" << newLine
  470. << "else" << newLine
  471. << "V_AT = @" << newLine
  472. << "endif" << newLine
  473. << newLine;
  474. out << "# (this disables dependency generation if multiple architectures are set)" << newLine
  475. << "DEPFLAGS := $(if $(word 2, $(TARGET_ARCH)), , -MMD)" << newLine
  476. << newLine;
  477. out << "ifndef STRIP" << newLine
  478. << " STRIP=strip" << newLine
  479. << "endif" << newLine
  480. << newLine;
  481. out << "ifndef AR" << newLine
  482. << " AR=ar" << newLine
  483. << "endif" << newLine
  484. << newLine;
  485. out << "ifndef CONFIG" << newLine
  486. << " CONFIG=" << escapeSpaces (getConfiguration(0)->getName()) << newLine
  487. << "endif" << newLine
  488. << newLine;
  489. for (ConstConfigIterator config (*this); config.next();)
  490. writeConfig (out, *config);
  491. for (auto target : targets)
  492. target->writeObjects (out);
  493. out << ".PHONY: clean all" << newLine
  494. << newLine;
  495. StringArray packages;
  496. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  497. packages.removeEmptyStrings();
  498. const bool useLinuxPackages = (linuxPackages.size() > 0 || packages.size() > 0);
  499. writeTargetLines (out, useLinuxPackages);
  500. for (auto target : targets)
  501. target->addFiles (out);
  502. if (useLinuxPackages)
  503. {
  504. out << "check-pkg-config:" << newLine
  505. << "\t@command -v pkg-config >/dev/null 2>&1 || "
  506. "{ echo >&2 \"pkg-config not installed. Please, install it.\"; "
  507. "exit 1; }" << newLine
  508. << "\t@pkg-config --print-errors";
  509. for (int i = 0; i < linuxPackages.size(); ++i)
  510. out << " " << linuxPackages[i];
  511. for (int i = 0; i < packages.size(); ++i)
  512. out << " " << packages[i];
  513. out << newLine << newLine;
  514. }
  515. out << "clean:" << newLine
  516. << "\t@echo Cleaning " << projectName << newLine
  517. << "\t$(V_AT)$(CLEANCMD)" << newLine
  518. << newLine;
  519. out << "strip:" << newLine
  520. << "\t@echo Stripping " << projectName << newLine
  521. << "\t-$(V_AT)$(STRIP) --strip-unneeded $(JUCE_OUTDIR)/$(TARGET)" << newLine
  522. << newLine;
  523. out << "-include $(OBJECTS:%.o=%.d)" << newLine;
  524. }
  525. String getArchFlags (const BuildConfiguration& config) const
  526. {
  527. if (const MakeBuildConfiguration* makeConfig = dynamic_cast<const MakeBuildConfiguration*> (&config))
  528. if (! makeConfig->getArchitectureTypeVar().isVoid())
  529. return makeConfig->getArchitectureTypeVar();
  530. return "-march=native";
  531. }
  532. String getObjectFileFor (const RelativePath& file) const
  533. {
  534. return file.getFileNameWithoutExtension()
  535. + "_" + String::toHexString (file.toUnixStyle().hashCode()) + ".o";
  536. }
  537. void initialiseDependencyPathValues()
  538. {
  539. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder),
  540. Ids::vst3Path,
  541. TargetOS::linux)));
  542. }
  543. OwnedArray<MakefileTarget> targets;
  544. JUCE_DECLARE_NON_COPYABLE (MakefileProjectExporter)
  545. };