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. 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 isAndroid() const override { return false; }
  236. bool isWindows() const override { return false; }
  237. bool isLinux() const override { return true; }
  238. bool isOSX() const override { return false; }
  239. bool isiOS() const override { return false; }
  240. bool supportsTargetType (ProjectType::Target::Type type) const override
  241. {
  242. switch (type)
  243. {
  244. case ProjectType::Target::GUIApp:
  245. case ProjectType::Target::ConsoleApp:
  246. case ProjectType::Target::StaticLibrary:
  247. case ProjectType::Target::SharedCodeTarget:
  248. case ProjectType::Target::AggregateTarget:
  249. case ProjectType::Target::VSTPlugIn:
  250. case ProjectType::Target::StandalonePlugIn:
  251. case ProjectType::Target::DynamicLibrary:
  252. return true;
  253. default:
  254. break;
  255. }
  256. return false;
  257. }
  258. Value getCppStandardValue() { return getSetting (Ids::cppLanguageStandard); }
  259. String getCppStandardString() const { return settings[Ids::cppLanguageStandard]; }
  260. void createExporterProperties (PropertyListBuilder& properties) override
  261. {
  262. static const char* cppStandardNames[] = { "C++03", "C++11", "C++14", nullptr };
  263. static const char* cppStandardValues[] = { "-std=c++03", "-std=c++11", "-std=c++14", nullptr };
  264. properties.add (new ChoicePropertyComponent (getCppStandardValue(),
  265. "C++ standard to use",
  266. StringArray (cppStandardNames),
  267. Array<var> (cppStandardValues)),
  268. "The C++ standard to specify in the makefile");
  269. properties.add (new TextPropertyComponent (getExtraPkgConfig(), "pkg-config libraries", 8192, false),
  270. "Extra pkg-config libraries for you application. Each package should be space separated.");
  271. }
  272. //==============================================================================
  273. bool anyTargetIsSharedLibrary() const
  274. {
  275. const int n = targets.size();
  276. for (int i = 0; i < n; ++i)
  277. {
  278. const ProjectType::Target::TargetFileType fileType = targets.getUnchecked (i)->getTargetFileType();
  279. if (fileType == ProjectType::Target::sharedLibraryOrDLL || fileType == ProjectType::Target::pluginBundle)
  280. return true;
  281. }
  282. return false;
  283. }
  284. //==============================================================================
  285. void create (const OwnedArray<LibraryModule>&) const override
  286. {
  287. MemoryOutputStream mo;
  288. writeMakefile (mo);
  289. overwriteFileIfDifferentOrThrow (getTargetFolder().getChildFile ("Makefile"), mo);
  290. }
  291. //==============================================================================
  292. void addPlatformSpecificSettingsForProjectType (const ProjectType&) override
  293. {
  294. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  295. {
  296. if (MakefileTarget* target = new MakefileTarget (targetType, *this))
  297. {
  298. if (targetType == ProjectType::Target::AggregateTarget)
  299. targets.insert (0, target);
  300. else
  301. targets.add (target);
  302. }
  303. });
  304. // If you hit this assert, you tried to generate a project for an exporter
  305. // that does not support any of your targets!
  306. jassert (targets.size() > 0);
  307. }
  308. private:
  309. //==============================================================================
  310. void writeDefineFlags (OutputStream& out, const BuildConfiguration& config) const
  311. {
  312. StringPairArray defines;
  313. defines.set ("LINUX", "1");
  314. if (config.isDebug())
  315. {
  316. defines.set ("DEBUG", "1");
  317. defines.set ("_DEBUG", "1");
  318. }
  319. else
  320. {
  321. defines.set ("NDEBUG", "1");
  322. }
  323. out << createGCCPreprocessorFlags (mergePreprocessorDefs (defines, getAllPreprocessorDefs (config, ProjectType::Target::unspecified)));
  324. }
  325. void writeHeaderPathFlags (OutputStream& out, const BuildConfiguration& config) const
  326. {
  327. StringArray searchPaths (extraSearchPaths);
  328. searchPaths.addArray (config.getHeaderSearchPaths());
  329. StringArray packages;
  330. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  331. packages.removeEmptyStrings();
  332. if (linuxPackages.size() > 0 || packages.size() > 0)
  333. {
  334. out << " $(shell pkg-config --cflags";
  335. for (int i = 0; i < linuxPackages.size(); ++i)
  336. out << " " << linuxPackages[i];
  337. for (int i = 0; i < packages.size(); ++i)
  338. out << " " << packages[i];
  339. out << ")";
  340. }
  341. if (linuxLibs.contains("pthread"))
  342. out << " -pthread";
  343. searchPaths = getCleanedStringArray (searchPaths);
  344. // Replace ~ character with $(HOME) environment variable
  345. for (int i = 0; i < searchPaths.size(); ++i)
  346. out << " -I" << escapeSpaces (FileHelpers::unixStylePath (replacePreprocessorTokens (config, searchPaths[i]))).replace ("~", "$(HOME)");
  347. }
  348. void writeCppFlags (OutputStream& out, const BuildConfiguration& config) const
  349. {
  350. out << " JUCE_CPPFLAGS := $(DEPFLAGS)";
  351. writeDefineFlags (out, config);
  352. writeHeaderPathFlags (out, config);
  353. out << " $(CPPFLAGS)" << newLine;
  354. }
  355. void writeLinkerFlags (OutputStream& out, const BuildConfiguration& config) const
  356. {
  357. out << " JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR)";
  358. {
  359. StringArray flags (makefileExtraLinkerFlags);
  360. if (! config.isDebug())
  361. flags.add ("-fvisibility=hidden");
  362. if (flags.size() > 0)
  363. out << " " << getCleanedStringArray (flags).joinIntoString (" ");
  364. }
  365. out << config.getGCCLibraryPathFlags();
  366. StringArray packages;
  367. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  368. packages.removeEmptyStrings();
  369. if (linuxPackages.size() > 0 || packages.size() > 0)
  370. {
  371. out << " $(shell pkg-config --libs";
  372. for (int i = 0; i < linuxPackages.size(); ++i)
  373. out << " " << linuxPackages[i];
  374. for (int i = 0; i < packages.size(); ++i)
  375. out << " " << packages[i];
  376. out << ")";
  377. }
  378. for (int i = 0; i < linuxLibs.size(); ++i)
  379. out << " -l" << linuxLibs[i];
  380. StringArray libraries;
  381. libraries.addTokens (getExternalLibrariesString(), ";", "\"'");
  382. libraries.removeEmptyStrings();
  383. if (libraries.size() != 0)
  384. out << " -l" << replacePreprocessorTokens (config, libraries.joinIntoString (" -l")).trim();
  385. out << " " << replacePreprocessorTokens (config, getExtraLinkerFlagsString()).trim()
  386. << " $(LDFLAGS)" << newLine;
  387. }
  388. void writeTargetLines (OutputStream& out, const bool useLinuxPackages) const
  389. {
  390. const int n = targets.size();
  391. for (int i = 0; i < n; ++i)
  392. {
  393. if (MakefileTarget* target = targets.getUnchecked (i))
  394. {
  395. if (target->type == ProjectType::Target::AggregateTarget)
  396. {
  397. StringArray dependencies;
  398. for (int j = 0; j < n; ++j)
  399. {
  400. if (i == j) continue;
  401. if (MakefileTarget* dependency = targets.getUnchecked (j))
  402. {
  403. if (dependency->type != ProjectType::Target::SharedCodeTarget)
  404. dependencies.add (dependency->getBuildProduct());
  405. }
  406. }
  407. out << "all : " << dependencies.joinIntoString (" ") << newLine << newLine;
  408. }
  409. else
  410. target->writeTargetLine (out, useLinuxPackages);
  411. }
  412. }
  413. }
  414. void writeConfig (OutputStream& out, const BuildConfiguration& config) const
  415. {
  416. const String buildDirName ("build");
  417. const String intermediatesDirName (buildDirName + "/intermediate/" + config.getName());
  418. String outputDir (buildDirName);
  419. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  420. {
  421. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  422. outputDir = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder).toUnixStyle();
  423. }
  424. out << "ifeq ($(CONFIG)," << escapeSpaces (config.getName()) << ")" << newLine;
  425. out << " JUCE_BINDIR := " << escapeSpaces (buildDirName) << newLine
  426. << " JUCE_LIBDIR := " << escapeSpaces (buildDirName) << newLine
  427. << " JUCE_OBJDIR := " << escapeSpaces (intermediatesDirName) << newLine
  428. << " JUCE_OUTDIR := " << escapeSpaces (outputDir) << newLine
  429. << newLine
  430. << " ifeq ($(TARGET_ARCH),)" << newLine
  431. << " TARGET_ARCH := " << getArchFlags (config) << newLine
  432. << " endif" << newLine
  433. << newLine;
  434. writeCppFlags (out, config);
  435. for (auto target : targets)
  436. {
  437. StringArray lines = target->getTargetSettings (config);
  438. if (lines.size() > 0)
  439. out << " " << lines.joinIntoString ("\n ") << newLine;
  440. out << newLine;
  441. }
  442. out << " JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH)";
  443. if (anyTargetIsSharedLibrary())
  444. out << " -fPIC";
  445. if (config.isDebug())
  446. out << " -g -ggdb";
  447. out << " -O" << config.getGCCOptimisationFlag()
  448. << (" " + replacePreprocessorTokens (config, getExtraCompilerFlagsString())).trimEnd()
  449. << " $(CFLAGS)" << newLine;
  450. String cppStandardToUse (getCppStandardString());
  451. if (cppStandardToUse.isEmpty())
  452. cppStandardToUse = "-std=c++11";
  453. out << " JUCE_CXXFLAGS += $(CXXFLAGS) $(JUCE_CFLAGS) "
  454. << cppStandardToUse << " $(CXXFLAGS)" << newLine;
  455. writeLinkerFlags (out, config);
  456. out << newLine;
  457. out << " CLEANCMD = rm -rf $(JUCE_OUTDIR)/$(TARGET) $(JUCE_OBJDIR)" << newLine
  458. << "endif" << newLine
  459. << newLine;
  460. }
  461. void writeMakefile (OutputStream& out) const
  462. {
  463. out << "# Automatically generated makefile, created by the Projucer" << newLine
  464. << "# Don't edit this file! Your changes will be overwritten when you re-save the Projucer project!" << newLine
  465. << newLine;
  466. out << "# build with \"V=1\" for verbose builds" << newLine
  467. << "ifeq ($(V), 1)" << newLine
  468. << "V_AT =" << newLine
  469. << "else" << newLine
  470. << "V_AT = @" << newLine
  471. << "endif" << newLine
  472. << newLine;
  473. out << "# (this disables dependency generation if multiple architectures are set)" << newLine
  474. << "DEPFLAGS := $(if $(word 2, $(TARGET_ARCH)), , -MMD)" << newLine
  475. << newLine;
  476. out << "ifndef STRIP" << newLine
  477. << " STRIP=strip" << newLine
  478. << "endif" << newLine
  479. << newLine;
  480. out << "ifndef AR" << newLine
  481. << " AR=ar" << newLine
  482. << "endif" << newLine
  483. << newLine;
  484. out << "ifndef CONFIG" << newLine
  485. << " CONFIG=" << escapeSpaces (getConfiguration(0)->getName()) << newLine
  486. << "endif" << newLine
  487. << newLine;
  488. for (ConstConfigIterator config (*this); config.next();)
  489. writeConfig (out, *config);
  490. for (auto target : targets)
  491. target->writeObjects (out);
  492. out << ".PHONY: clean all" << newLine
  493. << newLine;
  494. StringArray packages;
  495. packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
  496. packages.removeEmptyStrings();
  497. const bool useLinuxPackages = (linuxPackages.size() > 0 || packages.size() > 0);
  498. writeTargetLines (out, useLinuxPackages);
  499. for (auto target : targets)
  500. target->addFiles (out);
  501. if (useLinuxPackages)
  502. {
  503. out << "check-pkg-config:" << newLine
  504. << "\t@command -v pkg-config >/dev/null 2>&1 || "
  505. "{ echo >&2 \"pkg-config not installed. Please, install it.\"; "
  506. "exit 1; }" << newLine
  507. << "\t@pkg-config --print-errors";
  508. for (int i = 0; i < linuxPackages.size(); ++i)
  509. out << " " << linuxPackages[i];
  510. for (int i = 0; i < packages.size(); ++i)
  511. out << " " << packages[i];
  512. out << newLine << newLine;
  513. }
  514. out << "clean:" << newLine
  515. << "\t@echo Cleaning " << projectName << newLine
  516. << "\t$(V_AT)$(CLEANCMD)" << newLine
  517. << newLine;
  518. out << "strip:" << newLine
  519. << "\t@echo Stripping " << projectName << newLine
  520. << "\t-$(V_AT)$(STRIP) --strip-unneeded $(JUCE_OUTDIR)/$(TARGET)" << newLine
  521. << newLine;
  522. out << "-include $(OBJECTS:%.o=%.d)" << newLine;
  523. }
  524. String getArchFlags (const BuildConfiguration& config) const
  525. {
  526. if (const MakeBuildConfiguration* makeConfig = dynamic_cast<const MakeBuildConfiguration*> (&config))
  527. if (! makeConfig->getArchitectureTypeVar().isVoid())
  528. return makeConfig->getArchitectureTypeVar();
  529. return "-march=native";
  530. }
  531. String getObjectFileFor (const RelativePath& file) const
  532. {
  533. return file.getFileNameWithoutExtension()
  534. + "_" + String::toHexString (file.toUnixStyle().hashCode()) + ".o";
  535. }
  536. void initialiseDependencyPathValues()
  537. {
  538. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder),
  539. Ids::vst3Path,
  540. TargetOS::linux)));
  541. }
  542. OwnedArray<MakefileTarget> targets;
  543. JUCE_DECLARE_NON_COPYABLE (MakefileProjectExporter)
  544. };