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.

702 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())
  97. targetName = getStaticLibbedFilename (targetName);
  98. else if (owner.projectType.isDynamicLibrary())
  99. targetName = getDynamicLibbedFilename (targetName);
  100. else
  101. targetName = targetName.upToLastOccurrenceOf (".", false, false) + getTargetFileSuffix();
  102. s.add (String ("JUCE_TARGET_") + getTargetVarName() + String (" := ") + escapeSpaces (targetName));
  103. return s;
  104. }
  105. String getTargetFileSuffix() const
  106. {
  107. switch (type)
  108. {
  109. case VSTPlugIn:
  110. return ".so";
  111. case VST3PlugIn:
  112. return ".vst3";
  113. case SharedCodeTarget:
  114. return ".a";
  115. default:
  116. break;
  117. }
  118. return String();
  119. }
  120. String getTargetVarName() const
  121. {
  122. return String (getName()).toUpperCase().replaceCharacter (L' ', L'_');
  123. }
  124. void writeObjects (OutputStream& out) const
  125. {
  126. Array<RelativePath> targetFiles;
  127. for (int i = 0; i < owner.getAllGroups().size(); ++i)
  128. findAllFilesToCompile (owner.getAllGroups().getReference(i), targetFiles);
  129. out << "OBJECTS_" + getTargetVarName() + String (" := \\") << newLine;
  130. for (int i = 0; i < targetFiles.size(); ++i)
  131. out << " $(JUCE_OBJDIR)/" << escapeSpaces (owner.getObjectFileFor (targetFiles.getReference(i))) << " \\" << newLine;
  132. out << newLine;
  133. }
  134. void findAllFilesToCompile (const Project::Item& projectItem, Array<RelativePath>& results) const
  135. {
  136. if (projectItem.isGroup())
  137. {
  138. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  139. findAllFilesToCompile (projectItem.getChild(i), results);
  140. }
  141. else
  142. {
  143. if (projectItem.shouldBeCompiled())
  144. {
  145. const Type targetType = (owner.getProject().getProjectType().isAudioPlugin() ? type : SharedCodeTarget);
  146. const File f = projectItem.getFile();
  147. RelativePath relativePath (f, owner.getTargetFolder(), RelativePath::buildTargetFolder);
  148. if (owner.shouldFileBeCompiledByDefault (relativePath)
  149. && owner.getProject().getTargetTypeFromFilePath (f, true) == targetType)
  150. results.add (relativePath);
  151. }
  152. }
  153. }
  154. void addFiles (OutputStream& out)
  155. {
  156. Array<RelativePath> targetFiles;
  157. for (int i = 0; i < owner.getAllGroups().size(); ++i)
  158. findAllFilesToCompile (owner.getAllGroups().getReference(i), targetFiles);
  159. const String cppflagsVarName = String ("JUCE_CPPFLAGS_") + getTargetVarName();
  160. const String cflagsVarName = String ("JUCE_CFLAGS_") + getTargetVarName();
  161. for (int i = 0; i < targetFiles.size(); ++i)
  162. {
  163. jassert (targetFiles.getReference(i).getRoot() == RelativePath::buildTargetFolder);
  164. out << "$(JUCE_OBJDIR)/" << escapeSpaces (owner.getObjectFileFor (targetFiles.getReference(i)))
  165. << ": " << escapeSpaces (targetFiles.getReference(i).toUnixStyle()) << newLine
  166. << "\t-$(V_AT)mkdir -p $(JUCE_OBJDIR)" << newLine
  167. << "\t@echo \"Compiling " << targetFiles.getReference(i).getFileName() << "\"" << newLine
  168. << (targetFiles.getReference(i).hasFileExtension ("c;s;S") ? "\t$(V_AT)$(CC) $(JUCE_CFLAGS)" : "\t$(V_AT)$(CXX) $(JUCE_CXXFLAGS) ")
  169. << "$(" << cppflagsVarName << ") $(" << cflagsVarName << ") -o \"$@\" -c \"$<\""
  170. << newLine << newLine;
  171. }
  172. }
  173. String getBuildProduct() const
  174. {
  175. return String ("$(JUCE_OUTDIR)/$(JUCE_TARGET_") + getTargetVarName() + String (")");
  176. }
  177. void writeTargetLine (OutputStream& out, const bool useLinuxPackages)
  178. {
  179. jassert (type != AggregateTarget);
  180. out << getBuildProduct() << " : "
  181. << ((useLinuxPackages) ? "check-pkg-config " : "")
  182. << "$(OBJECTS_" << getTargetVarName() << ") $(RESOURCES)";
  183. if (type != SharedCodeTarget && owner.shouldBuildTargetType (SharedCodeTarget))
  184. out << " $(JUCE_OUTDIR)/$(JUCE_TARGET_SHARED_CODE)";
  185. out << newLine << "\t@echo Linking \"" << owner.projectName << " - " << getName() << "\"" << newLine
  186. << "\t-$(V_AT)mkdir -p $(JUCE_BINDIR)" << newLine
  187. << "\t-$(V_AT)mkdir -p $(JUCE_LIBDIR)" << newLine
  188. << "\t-$(V_AT)mkdir -p $(JUCE_OUTDIR)" << newLine;
  189. if (owner.projectType.isStaticLibrary() || type == SharedCodeTarget)
  190. out << "\t$(V_AT)$(AR) -rcs " << getBuildProduct()
  191. << " $(OBJECTS_" << getTargetVarName() << ")" << newLine;
  192. else
  193. {
  194. out << "\t$(V_AT)$(CXX) -o " << getBuildProduct()
  195. << " $(OBJECTS_" << getTargetVarName() << ") ";
  196. if (owner.shouldBuildTargetType (SharedCodeTarget))
  197. out << "$(JUCE_OUTDIR)/$(JUCE_TARGET_SHARED_CODE) ";
  198. out << "$(JUCE_LDFLAGS) ";
  199. if (getTargetFileType() == sharedLibraryOrDLL || getTargetFileType() == pluginBundle)
  200. out << "$(JUCE_LDFLAGS_" << getTargetVarName() << ") ";
  201. out << "$(RESOURCES) $(TARGET_ARCH)" << newLine;
  202. }
  203. out << newLine;
  204. }
  205. const MakefileProjectExporter& owner;
  206. };
  207. //==============================================================================
  208. static const char* getNameLinux() { return "Linux Makefile"; }
  209. static const char* getValueTreeTypeName() { return "LINUX_MAKE"; }
  210. Value getExtraPkgConfig() { return getSetting (Ids::linuxExtraPkgConfig); }
  211. String getExtraPkgConfigString() const { return getSettingString (Ids::linuxExtraPkgConfig); }
  212. static MakefileProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  213. {
  214. if (settings.hasType (getValueTreeTypeName()))
  215. return new MakefileProjectExporter (project, settings);
  216. return nullptr;
  217. }
  218. //==============================================================================
  219. MakefileProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t)
  220. {
  221. name = getNameLinux();
  222. if (getTargetLocationString().isEmpty())
  223. getTargetLocationValue() = getDefaultBuildsRootFolder() + "LinuxMakefile";
  224. initialiseDependencyPathValues();
  225. }
  226. //==============================================================================
  227. bool canLaunchProject() override { return false; }
  228. bool launchProject() override { return false; }
  229. bool usesMMFiles() const override { return false; }
  230. bool canCopeWithDuplicateFiles() override { return false; }
  231. bool supportsUserDefinedConfigurations() const override { return true; }
  232. bool isXcode() const override { return false; }
  233. bool isVisualStudio() const override { return false; }
  234. bool isCodeBlocks() const override { return false; }
  235. bool isMakefile() const override { return true; }
  236. bool isAndroidStudio() const override { return false; }
  237. bool isAndroid() const override { return false; }
  238. bool isWindows() const override { return false; }
  239. bool isLinux() const override { return true; }
  240. bool isOSX() const override { return false; }
  241. bool isiOS() const override { return false; }
  242. bool supportsTargetType (ProjectType::Target::Type type) const override
  243. {
  244. switch (type)
  245. {
  246. case ProjectType::Target::GUIApp:
  247. case ProjectType::Target::ConsoleApp:
  248. case ProjectType::Target::StaticLibrary:
  249. case ProjectType::Target::SharedCodeTarget:
  250. case ProjectType::Target::AggregateTarget:
  251. case ProjectType::Target::VSTPlugIn:
  252. case ProjectType::Target::StandalonePlugIn:
  253. case ProjectType::Target::DynamicLibrary:
  254. return true;
  255. default:
  256. break;
  257. }
  258. return false;
  259. }
  260. Value getCppStandardValue() { return getSetting (Ids::cppLanguageStandard); }
  261. String getCppStandardString() const { return settings[Ids::cppLanguageStandard]; }
  262. void createExporterProperties (PropertyListBuilder& properties) override
  263. {
  264. static const char* cppStandardNames[] = { "C++03", "C++11", "C++14", nullptr };
  265. static const char* cppStandardValues[] = { "-std=c++03", "-std=c++11", "-std=c++14", nullptr };
  266. properties.add (new ChoicePropertyComponent (getCppStandardValue(),
  267. "C++ standard to use",
  268. StringArray (cppStandardNames),
  269. Array<var> (cppStandardValues)),
  270. "The C++ standard to specify in the makefile");
  271. properties.add (new TextPropertyComponent (getExtraPkgConfig(), "pkg-config libraries", 8192, false),
  272. "Extra pkg-config libraries for you application. Each package should be space separated.");
  273. }
  274. //==============================================================================
  275. bool anyTargetIsSharedLibrary() const
  276. {
  277. const int n = targets.size();
  278. for (int i = 0; i < n; ++i)
  279. {
  280. const ProjectType::Target::TargetFileType fileType = targets.getUnchecked (i)->getTargetFileType();
  281. if (fileType == ProjectType::Target::sharedLibraryOrDLL || fileType == ProjectType::Target::pluginBundle)
  282. return true;
  283. }
  284. return false;
  285. }
  286. //==============================================================================
  287. void create (const OwnedArray<LibraryModule>&) const override
  288. {
  289. MemoryOutputStream mo;
  290. writeMakefile (mo);
  291. overwriteFileIfDifferentOrThrow (getTargetFolder().getChildFile ("Makefile"), mo);
  292. }
  293. //==============================================================================
  294. void addPlatformSpecificSettingsForProjectType (const ProjectType&) override
  295. {
  296. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  297. {
  298. if (MakefileTarget* target = new MakefileTarget (targetType, *this))
  299. {
  300. if (targetType == ProjectType::Target::AggregateTarget)
  301. targets.insert (0, target);
  302. else
  303. targets.add (target);
  304. }
  305. });
  306. // If you hit this assert, you tried to generate a project for an exporter
  307. // that does not support any of your targets!
  308. jassert (targets.size() > 0);
  309. }
  310. private:
  311. //==============================================================================
  312. void writeDefineFlags (OutputStream& out, const BuildConfiguration& config) const
  313. {
  314. StringPairArray defines;
  315. defines.set ("LINUX", "1");
  316. if (config.isDebug())
  317. {
  318. defines.set ("DEBUG", "1");
  319. defines.set ("_DEBUG", "1");
  320. }
  321. else
  322. {
  323. defines.set ("NDEBUG", "1");
  324. }
  325. out << createGCCPreprocessorFlags (mergePreprocessorDefs (defines, getAllPreprocessorDefs (config, ProjectType::Target::unspecified)));
  326. }
  327. void writeHeaderPathFlags (OutputStream& out, const BuildConfiguration& config) const
  328. {
  329. StringArray searchPaths (extraSearchPaths);
  330. searchPaths.addArray (config.getHeaderSearchPaths());
  331. StringArray packages;
  332. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  333. packages.removeEmptyStrings();
  334. if (linuxPackages.size() > 0 || packages.size() > 0)
  335. {
  336. out << " $(shell pkg-config --cflags";
  337. for (int i = 0; i < linuxPackages.size(); ++i)
  338. out << " " << linuxPackages[i];
  339. for (int i = 0; i < packages.size(); ++i)
  340. out << " " << packages[i];
  341. out << ")";
  342. }
  343. if (linuxLibs.contains("pthread"))
  344. out << " -pthread";
  345. searchPaths = getCleanedStringArray (searchPaths);
  346. // Replace ~ character with $(HOME) environment variable
  347. for (int i = 0; i < searchPaths.size(); ++i)
  348. out << " -I" << escapeSpaces (FileHelpers::unixStylePath (replacePreprocessorTokens (config, searchPaths[i]))).replace ("~", "$(HOME)");
  349. }
  350. void writeCppFlags (OutputStream& out, const BuildConfiguration& config) const
  351. {
  352. out << " JUCE_CPPFLAGS := $(DEPFLAGS)";
  353. writeDefineFlags (out, config);
  354. writeHeaderPathFlags (out, config);
  355. out << " $(CPPFLAGS)" << newLine;
  356. }
  357. void writeLinkerFlags (OutputStream& out, const BuildConfiguration& config) const
  358. {
  359. out << " JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR)";
  360. {
  361. StringArray flags (makefileExtraLinkerFlags);
  362. if (! config.isDebug())
  363. flags.add ("-fvisibility=hidden");
  364. if (flags.size() > 0)
  365. out << " " << getCleanedStringArray (flags).joinIntoString (" ");
  366. }
  367. out << config.getGCCLibraryPathFlags();
  368. StringArray packages;
  369. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  370. packages.removeEmptyStrings();
  371. if (linuxPackages.size() > 0 || packages.size() > 0)
  372. {
  373. out << " $(shell pkg-config --libs";
  374. for (int i = 0; i < linuxPackages.size(); ++i)
  375. out << " " << linuxPackages[i];
  376. for (int i = 0; i < packages.size(); ++i)
  377. out << " " << packages[i];
  378. out << ")";
  379. }
  380. for (int i = 0; i < linuxLibs.size(); ++i)
  381. out << " -l" << linuxLibs[i];
  382. StringArray libraries;
  383. libraries.addTokens (getExternalLibrariesString(), ";", "\"'");
  384. libraries.removeEmptyStrings();
  385. if (libraries.size() != 0)
  386. out << " -l" << replacePreprocessorTokens (config, libraries.joinIntoString (" -l")).trim();
  387. out << " " << replacePreprocessorTokens (config, getExtraLinkerFlagsString()).trim()
  388. << " $(LDFLAGS)" << newLine;
  389. }
  390. void writeTargetLines (OutputStream& out, const bool useLinuxPackages) const
  391. {
  392. const int n = targets.size();
  393. for (int i = 0; i < n; ++i)
  394. {
  395. if (MakefileTarget* target = targets.getUnchecked (i))
  396. {
  397. if (target->type == ProjectType::Target::AggregateTarget)
  398. {
  399. StringArray dependencies;
  400. for (int j = 0; j < n; ++j)
  401. {
  402. if (i == j) continue;
  403. if (MakefileTarget* dependency = targets.getUnchecked (j))
  404. {
  405. if (dependency->type != ProjectType::Target::SharedCodeTarget)
  406. dependencies.add (dependency->getBuildProduct());
  407. }
  408. }
  409. out << "all : " << dependencies.joinIntoString (" ") << newLine << newLine;
  410. }
  411. else
  412. target->writeTargetLine (out, useLinuxPackages);
  413. }
  414. }
  415. }
  416. void writeConfig (OutputStream& out, const BuildConfiguration& config) const
  417. {
  418. const String buildDirName ("build");
  419. const String intermediatesDirName (buildDirName + "/intermediate/" + config.getName());
  420. String outputDir (buildDirName);
  421. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  422. {
  423. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  424. outputDir = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder).toUnixStyle();
  425. }
  426. out << "ifeq ($(CONFIG)," << escapeSpaces (config.getName()) << ")" << newLine;
  427. out << " JUCE_BINDIR := " << escapeSpaces (buildDirName) << newLine
  428. << " JUCE_LIBDIR := " << escapeSpaces (buildDirName) << newLine
  429. << " JUCE_OBJDIR := " << escapeSpaces (intermediatesDirName) << newLine
  430. << " JUCE_OUTDIR := " << escapeSpaces (outputDir) << newLine
  431. << newLine
  432. << " ifeq ($(TARGET_ARCH),)" << newLine
  433. << " TARGET_ARCH := " << getArchFlags (config) << newLine
  434. << " endif" << newLine
  435. << newLine;
  436. writeCppFlags (out, config);
  437. for (auto target : targets)
  438. {
  439. StringArray lines = target->getTargetSettings (config);
  440. if (lines.size() > 0)
  441. out << " " << lines.joinIntoString ("\n ") << newLine;
  442. out << newLine;
  443. }
  444. out << " JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH)";
  445. if (anyTargetIsSharedLibrary())
  446. out << " -fPIC";
  447. if (config.isDebug())
  448. out << " -g -ggdb";
  449. out << " -O" << config.getGCCOptimisationFlag()
  450. << (" " + replacePreprocessorTokens (config, getExtraCompilerFlagsString())).trimEnd()
  451. << " $(CFLAGS)" << newLine;
  452. String cppStandardToUse (getCppStandardString());
  453. if (cppStandardToUse.isEmpty())
  454. cppStandardToUse = "-std=c++11";
  455. out << " JUCE_CXXFLAGS += $(CXXFLAGS) $(JUCE_CFLAGS) "
  456. << cppStandardToUse << " $(CXXFLAGS)" << newLine;
  457. writeLinkerFlags (out, config);
  458. out << newLine;
  459. out << " CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR)" << newLine
  460. << "endif" << newLine
  461. << newLine;
  462. }
  463. void writeMakefile (OutputStream& out) const
  464. {
  465. out << "# Automatically generated makefile, created by the Projucer" << newLine
  466. << "# Don't edit this file! Your changes will be overwritten when you re-save the Projucer project!" << newLine
  467. << newLine;
  468. out << "# build with \"V=1\" for verbose builds" << newLine
  469. << "ifeq ($(V), 1)" << newLine
  470. << "V_AT =" << newLine
  471. << "else" << newLine
  472. << "V_AT = @" << newLine
  473. << "endif" << newLine
  474. << newLine;
  475. out << "# (this disables dependency generation if multiple architectures are set)" << newLine
  476. << "DEPFLAGS := $(if $(word 2, $(TARGET_ARCH)), , -MMD)" << newLine
  477. << newLine;
  478. out << "ifndef STRIP" << newLine
  479. << " STRIP=strip" << newLine
  480. << "endif" << newLine
  481. << newLine;
  482. out << "ifndef AR" << newLine
  483. << " AR=ar" << newLine
  484. << "endif" << newLine
  485. << newLine;
  486. out << "ifndef CONFIG" << newLine
  487. << " CONFIG=" << escapeSpaces (getConfiguration(0)->getName()) << newLine
  488. << "endif" << newLine
  489. << newLine;
  490. for (ConstConfigIterator config (*this); config.next();)
  491. writeConfig (out, *config);
  492. for (auto target : targets)
  493. target->writeObjects (out);
  494. out << ".PHONY: clean all" << newLine
  495. << newLine;
  496. StringArray packages;
  497. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  498. packages.removeEmptyStrings();
  499. const bool useLinuxPackages = (linuxPackages.size() > 0 || packages.size() > 0);
  500. writeTargetLines (out, useLinuxPackages);
  501. for (auto target : targets)
  502. target->addFiles (out);
  503. if (useLinuxPackages)
  504. {
  505. out << "check-pkg-config:" << newLine
  506. << "\t@command -v pkg-config >/dev/null 2>&1 || "
  507. "{ echo >&2 \"pkg-config not installed. Please, install it.\"; "
  508. "exit 1; }" << newLine
  509. << "\t@pkg-config --print-errors";
  510. for (int i = 0; i < linuxPackages.size(); ++i)
  511. out << " " << linuxPackages[i];
  512. for (int i = 0; i < packages.size(); ++i)
  513. out << " " << packages[i];
  514. out << newLine << newLine;
  515. }
  516. out << "clean:" << newLine
  517. << "\t@echo Cleaning " << projectName << newLine
  518. << "\t$(V_AT)$(CLEANCMD)" << newLine
  519. << newLine;
  520. out << "strip:" << newLine
  521. << "\t@echo Stripping " << projectName << newLine
  522. << "\t-$(V_AT)$(STRIP) --strip-unneeded $(JUCE_OUTDIR)/$(TARGET)" << newLine
  523. << newLine;
  524. out << "-include $(OBJECTS:%.o=%.d)" << newLine;
  525. }
  526. String getArchFlags (const BuildConfiguration& config) const
  527. {
  528. if (const MakeBuildConfiguration* makeConfig = dynamic_cast<const MakeBuildConfiguration*> (&config))
  529. if (! makeConfig->getArchitectureTypeVar().isVoid())
  530. return makeConfig->getArchitectureTypeVar();
  531. return "-march=native";
  532. }
  533. String getObjectFileFor (const RelativePath& file) const
  534. {
  535. return file.getFileNameWithoutExtension()
  536. + "_" + String::toHexString (file.toUnixStyle().hashCode()) + ".o";
  537. }
  538. void initialiseDependencyPathValues()
  539. {
  540. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder),
  541. Ids::vst3Path,
  542. TargetOS::linux)));
  543. }
  544. OwnedArray<MakefileTarget> targets;
  545. JUCE_DECLARE_NON_COPYABLE (MakefileProjectExporter)
  546. };