How do I create Makefiles for my Lazarus Project for distribution packaging? lazarus / 31-LCL ---------------------------------------------------------------------- Gizmo · 2011-09-21 21:33 Hi I have created a program. A developer has offered to help me get it packaged into Ubuntu as an official package that can be installed using apt-get, but he naturally doesn't want to do it all himself and I don't expect him to. Though Lazarus created a compiled binary, he wants a specific Ubuntu package creating. He has asked: QuoteCan you write a makefile? Or at least give me a couple of shell commands that compile your code? Other than knowing that makefiles compile C programs using gcc etc, I am farily clueless as to what he means. Having spent some time Googling I have read several links, but I'm still struggling. I have read http://www.lazarus.freepascal.org/index.php?topic=5792.0 (titled 'How to create a MakeFile) and have tried going to Project Options --> Compiler Options --> Compiler and the 'Create Makefile' checkbox is greyed out, and unticked. So I can't tick it. I have also tried fpcmake and read http://wiki.freepascal.org/Fpcmake. However, that's a tad confusing for someone who's never made a MakeFile before or even attempted to package a program. I did try copying the lazarus/tools/Makefile.fpc to my project directory and then from the command line I ran Code: [Select]MyProjectDir> fpcmake -w -Tall Makefile.fpc but it returned Code: [Select]Processing Makefile.fpc Error: Directory "apiwizz" not found I tried creating apiwizz then it said it could not find a MakeFile. So  copied it into the apiwizz directory and ran it again. It then repeated the above error. I then realised that /lazarus/tools contains both Makefile.fpc and Makefile and the apiwizz directory, so I tried running the command from there but I then got the following error: Code: [Select]Processing Makefile.fpc Error: Target "go32v2", package "rtl" not found So I then read http://wiki.freepascal.org/Deploying_Your_Application, specifically http://wiki.freepascal.org/Deploying_Your_Application#Cre ating_a_Makefile_for_your_Lazarus_software But I am unclear - do I have to create those 4 files and copy & paste the content from the wiki page into each of them as instructed? If so, do I then place them all in my project root? I have also read http://stackoverflow.com/questions/1897435/fpcmake- and-makefile-fpc-where-can-i-get-some-training Forgive my stupidity. Any guidance warmyl received. ---------------------------------------------------------------------- fabienwang · 2011-09-22 05:39 To have your package in Ubuntu repository is not really important, as long as you can provide a .deb on your website. (or you would have to submit package for all distros/repositories you want to be in). fpcmake will build a makefile from the file makefile.fpc, and this new makefile created will be suitable for gnu make utility, to be able to compile your project. But you can totally create a deb package with binaries and no source (mozilla does it). a tool exists for debian packages creation (same as ubuntu ones). it's called CDBS read some informations here: http://cdbs-doc.duckcorp.org/ About more infos on fpcmake, i don't know it unfortunately. I hope i gave you some more understanding. Cya ---------------------------------------------------------------------- BigChimp · 2011-09-22 09:19 If it's a Lazarus application, can't you write a bash script that calls lazbuild? Personnally, I disagree a bit with Fabien Wang: though it's not necessary to have your package in the Ubuntu repositories, it is cool and easier for users to install. Yes, you can host .debs on your own site, but you'll have to create debs in both situations anyway. The developer who helps you might also benefit from some instructions on how to get Lazarus etc, maybe even include it into your bash script, e.g. (off the top of my head) Code: [Select]#!/bin/bash # get lazarus and freepascal sudo aptitude install lazarus fpc fpc-source #don't know if source is needed lazbuild yourapp.lpr ---------------------------------------------------------------------- Gizmo · 2011-09-22 12:35 Hi both (good to hear from you again Fabien! - long time no speak - I've noticed you not about in IRC). I did try lazbuild last night after Dresco pointed it out to me via IRC. But again, I struggled to get it to work. I tried using the '-- create-makefile' switch, but it didn't appear to generate a makefile? Does anyone know where lazbuild saves the generated makefile file? ---------------------------------------------------------------------- Gizmo · 2011-09-23 15:35 From within the lazarus/components directory there's a Makefile.fpc file and a default 'Makefile'. Running fpcmake from that path generates a new Makefile (I wish fpcmake documentation was a bit clearer on that point because I assumed it had to be ran from within your project?) Code: [Select]~/lazarus/components$ fpcmake -w Makefile.fpc Processing Makefile.fpc  i386-linux requires:  Writing Makefile However, I don't really know how to use it. If I run it (sh Makefile) I get : Code: [Select]ted@acer-laptop:~/temp$ sh ./Makefile ./Makefile: 4: default:: not found ./Makefile: 6: BSDs: not found ./Makefile: 7: BSDs: not found ./Makefile: 7: UNIXs: not found ./Makefile: 8: LIMIT83fs: not found ./Makefile: 9: OSNeedsComspecToRunBatch: not found ./Makefile: 10: FORCE:: not found ./Makefile: 11: .PHONY:: not found ./Makefile: 12: PATH: not found ./Makefile: 12: subst: not found ./Makefile: 12: patsubst: not found ./Makefile: 12: override: not found ./Makefile: 13: Syntax error: word unexpected (expecting ")") ---------------------------------------------------------------------- TurboRascal · 2011-09-28 08:15 Makefile is not a shell script and it cannot be run by shell the way you tried. It is interpreted by Make and it works by calling 'make' command in the same directory with that Makefile... ---------------------------------------------------------------------- Gizmo · 2011-10-04 19:11 OK. Well, can anyone help me with providing an explanation to the folowing chain because I fear I am going to make myself sound like an idiot : https://answers.launchpad.net/ecryptfs/+question/171830 ---------------------------------------------------------------------- BigChimp · 2011-10-05 07:14 Ok, giving it a shot. I'm on Debian stable (Squeeze) x86, but I've tried to keep Ubuntu in mind: Code: [Select]#install Lazarus IDE and dependencies (FPC compiler etc) #should be done as root or using sudo on Ubuntu sudo aptitude install lazarus #If necessary, get wget, don't know if it is installed by default on ubuntu #adapt the following line #sudo aptitude install wget #get eCryptfs Parser source code from sourceforge: cd /tmp wget "http://sourceforge.net/projects/ecryptfs-p/files/v1.1.0- Linux/ecryptfsparser-source.tar.gz/download" #we should have gotten a .tar.gz tar xzvf download lazbuild project1.lpr This gives errors: Code: [Select]Free Pascal Compiler version 2.4.0-2 [2010/02/20] for i386 Copyright (c) 1993-2009 by Florian Klaempfl Target OS: Linux for i386 Compiling project1.lpr Compiling ecryptfstools.pas ecryptfstools.pas(168,32) Error: identifier idents no member "SaveToCSVFile" ecryptfstools.pas(254,6) Warning: Comment level 2 found ecryptfstools.pas(255,6) Warning: Comment level 2 found ecryptfstools.pas(256,6) Warning: Comment level 2 found ecryptfstools.pas(352,40) Hint: Local variable "header" does not seem to be initialized ecryptfstools.pas(412,18) Warning: Comment level 2 found ecryptfstools.pas(413,18) Warning: Comment level 2 found ecryptfstools.pas(414,18) Warning: Comment level 2 found ecryptfstools.pas(415,18) Warning: Comment level 2 found ecryptfstools.pas(711) Fatal: There were 1 errors compiling module, stopping ERROR: failed compiling of project /tmp/project1.lpi because the Lazarus used to compile is too old: Code: [Select]lazbuild --version 0.9.28.2-12 So probably easier to do it via SVN. I'll get back to you on that. ---------------------------------------------------------------------- BigChimp · 2011-10-05 07:52 Tried to do it via SVN on my Debian Squeeze machine but I got into trouble (see below), maybe because I don't have libgdk-pixbuf-dev, see http://lazarus.freepascal.org/index.php/topic,14843.msg79056.html#msg7 9056 I'm giving up - maybe it's easier to do on Ubuntu and you can use the commands below. Code: [Select]#Step 1: prerequisites & get Lazarus IDE and FPC compiler from SVN cd /tmp #If necessary, get wget, don't know if it is installed by default on ubuntu #adapt the following line #sudo aptitude install wget #get required packages - don't know if these are the right version for current ubuntu #taken from http://wiki.lazarus.freepascal.org/Installing_Lazarus#Inst alling_from_source sudo aptitude install build-essential libgtk2.0-dev libgdk-pixbuf-dev #Get FPC bootstrap compiler: wget "http://sourceforge.net/projects/freepascal/files/Bootstrap/2.4.4 /i386-linux-ppc386.bz2/download" bunzip2 download > ppc386 chmod ug+x ppc386 rm download #Get a stable FPC source that has backported stability fixes: svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_4 fpc24fixes #to update: #svn update /tmp/fpc24fixes #then compile source again #Compile FPC source using our bootstrap compiler: cd /tmp/fpc24fixes make all FPC=/tmp/ppc386 ===> error occurs here: make compiler_cycle RELEASE=1 make[1]: Entering directory `/tmp/fpc24fixes' make -C compiler cycle make[2]: Entering directory `/tmp/fpc24fixes/compiler' make tempclean ppc3.exe make[3]: Entering directory `/tmp/fpc24fixes/compiler' /bin/rm -f ppcross ppc ppc1.exe ppc2.exe ppc3.exe ./msg2inc.exe make 'OLDFPC=' next make[4]: Entering directory `/tmp/fpc24fixes/compiler' make rtlclean rtl make[5]: Entering directory `/tmp/fpc24fixes/compiler' make -C  clean make: Entering an unknown directory make: *** clean: No such file or directory.  Stop. make: Leaving an unknown directory make[5]: *** [rtlclean] Error 2 make[5]: Leaving directory `/tmp/fpc24fixes/compiler' make[4]: *** [next] Error 2 make[4]: Leaving directory `/tmp/fpc24fixes/compiler' make[3]: *** [ppc1.exe] Error 2 make[3]: Leaving directory `/tmp/fpc24fixes/compiler' make[2]: *** [cycle] Error 2 make[2]: Leaving directory `/tmp/fpc24fixes/compiler' make[1]: *** [compiler_cycle] Error 2 make[1]: Leaving directory `/tmp/fpc24fixes' make: *** [build-stamp.-] Error 2 #probably this is not required #make install PREFIX=/tmp/fpc24fixesbin FPC=/tmp/ppc386 #Create fpc config - necessary??? #Get Lazarus source: #to do: specify a specific known good version that works with ecryptfs. svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarustrunk #to update: #svn update /tmp/lazarustrunk #Compile Lazarus cd /tmp/lazarustrunk #Make with our newly compiled FPC make FPC=/tmp/***whatever*** #probably do something with environmentoptions.xml so it has the proper paths #to the fpc compiler and source #Step 2: get ecryptfs Parser source code: #get eCryptfs Parser source code from sourceforge: cd /tmp wget "http://sourceforge.net/projects/ecryptfs-p/files/v1.1.0- Linux/ecryptfsparser-source.tar.gz/download" #we should have gotten a .tar.gz tar xzvf download rm download #Step 3: compile: lazbuild project1.lpr ---------------------------------------------------------------------- Vincent Snijders · 2011-10-05 08:27 First test, that you can build you application with lazbuild. Then look at winff as an example of how to package a LCL application.