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.

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