So I have created a piece of software which I wanna package and post to Arch Linux User Repositories, AUR, -should note, that I have never packaged anything for any distro before - and I have also got it packaged and installed on my own machine via Arch's package manager Pacman successfully, but now I am wondering how on earth am I gonna structure the folders and files?
Normally when I wrote software, I use this structure:
build/ | src/ | makefile
As a minimum, and in the case of this piece of software, the makefile does nothing more than compile a .cpp file from src/ to build/.
To make the Arch package, I also had to create a .rc file, to use the program properly as a daemon and the PKGBUILD file, which is the file that tells the makepkg program how to build the installer-package - these two files, though, are specific to Arch.
If I wanna package the program for say debian, I would need another set of files to do this too, but these files only work for debian. Now, I can't just put the .rc file and the PKGBUILD file in to the programs root folder, since that would "be a mess" especially if I also had files to build a package for debian, but where do I put the distro-specific files? I need to have it in the programs root folder -at-least- to be able to keep track of it, and my initial thought was to go with a structure like distro/arch/ for Arch Linux specific files, and then the PKGBUILD file would just run the makefile in the programs root folder and copy the compiled file from build/ to distro/arch/ before it did anything else, but I discovered that I couldnt get PKGBUILD to work that way, and people on #archlinux on Freenode also said it was not a smart idea.
So where do I put the distro specific files? If I knew I only had to provide this program for Arch, it would be easy to just structure it only for Makepkg, but I dont like to imprison the softwarelike that, and I could also imagine providing packages for other mayor distros like debian, so how do I achieve this while keeping a sane file structure?
Regards,
Chris Buchholz
Very often you find in tarballs a directory called 'debian' which has the debian specific files in it. I would go the same route and create a directory 'archlinux' and put the files there.
Then I would go on and put a file README in the archlinux directory that explains how to use the PKGBUILD properly.
One solution could be to write a rule into your Makefile 'package-arch' that copies the PKGBUILD into the root directory, runs makepkg, then deletes the redundant PKGBUILD.
It's hackish, so I would also write a bug report for the Arch people to fix this limitation. However, did you try makepkg -p archlinux/PKGBUILD?
Related
I haven't programmed for a while and am trying to set up my build environment on a new laptop. I've just forgotten how and think that I did allot of things wrong last time!
What I'm trying to do is have that common Include Directory and common Lib directory so when I build projects or other dependencies, etc... my compiler is able to find all the include and lib files it needs. I'm not formally trained so some obvious things to you guys are learning points for me.
I'm going to use a Mingw compiler and MSYS. Off memory I put the Include directory and the lib directory in the Mingw directory but I could be wrong there.
I'm just trying to set up an effective and simple build environment on Windows 7.
Where should all my directories go? Thanks
If you aren't already, MSYS2 is generally preferred over MSYS. I'm going to answer this assuming MSYS2. I use the 64 bit version, so that is what I'll show, but it should be simple enough to change.
I will also assume you put the msys64 directory in the base directory, if not replace C:/msys64/ with C:/wherever/you/put/it/msys64/.
When using the msys shell, /c/msys64/usr/ is the same as C:/msys64/usr/ which is the same as /usr/ since it tries to blend Linux file organization with windows, and it can sometimes be slightly unintuitive. When you install msys libraries, usually the include files are in C:/msys64/usr/include/ and the libraries are in C:/msys64/usr/lib/. The exception to this is when you have a 64-bit version and a 32-bit version of a program, in which case the headers are in C:/msys64/mingw64/include/ and the libs in C:/msys64/mingw64/lib/ for 64-bit (mingw32 for 32 bit).
In order to build using these, you will need to add the appropriate include paths and library paths. So, to make all 64-bit programs available, you would add the following flags
-IC:/msys64/usr/include -IC:/msys64/mingw64/include -LC:/msys64/usr/lib -LC:/msys64/mingw64/lib
When you compile your own programs from source, you put them wherever you'd like. It is best not to put them in the same directory as the package manager to avoid collisions. Running make install sometimes won't run as seamlessly on msys as it would on linux. In these cases, creating a folder such as C:/msys64/custom/include/ is a safer alternative. See https://unix.stackexchange.com/questions/30/where-should-i-put-software-i-compile-myself for some more insight on this.
I am currently wondering how I can solve the situation, that I want to work on a C++ project from multiple devices with different OSs. So my idea was to just push my .cpp and .h files up. So I tried to clone it and create a project with exisiting sources files. I was hoping Netbeans would realize where to put the files in the right project subdirectories (like header files/source files). However it doesn't work because it needs the Makefile. Which is pointless though to push the Makefile up to git, since it contains information about the previous OS.
Is there a way that Netbeans will be smart enough to figure just out to put the files in the right folders and then I can compile it from scratch without existing Makefiles from the previous operation system?
Thank you very much.
I'm doing what #user4581301 was talking about for many years.
IMPORTANT: The Netbeans project type must be "C/C++ Project with Existing Sources".
The Makefile contains an ifeq statement, so it works differently on Linux and Windows:
MAIN = tc0001
ifeq (${OS},Windows_NT)
include ${MAKELIBHOME}/MINGW32.inc
include ${MAKELIBHOME}/WINDOWS.inc
else
MAKELIBHOME := ${HOME}/host/lib/make
include ${MAKELIBHOME}/GCC.inc
endif
build: ${MAIN}
clean:; rm -fr core *.o latest*
The MAKELIBHOME directory is a place where I store various pieces of makefiles (MINGW32.inc, GCC.inc etc.). The MAKELIBHOME is an environment variable on Windows, but the Netbeans on Linux doesn't understand such kind of environment variables, so I have to assign this variable right in the Makefile before including the pieces.
All is stored in the Git repo.
I take a look inside the asio folder there are
asio.manifest
autogen.sh
boost_asio.manifest
boostify.pl
configure.ac
include/
INSTALL
src/ (there are asio_ssl.cpp and asio.cpp)
I didn't see any configure script where I can execute. How do I build this asio?
I read asio is a header only library.
So, what I can make out of those files in the asio folder?
If you got it from a tarball, you should already have a configure script ready to be executed. If you checked from the repository, you probably need to run ./autogen.sh to generate the configure script for you, using configure.ac as input.
The convention is:
./bootstrap: it invokes autoconf to process configure.ac and spit out configure. Often it also invokes automake to process all Makefile.am files and turn them into Makefile.in. Many moons ago, the name autogen.sh was used instead of bootstrap. And configure.in was used instead of configure.ac.
./configure: detects everything on the system and creates config.status, then executes it.
./config.status: processes all *.in files into versions without the .in suffix. That includes Makefile.in -> Makefile. You don't have to run this script by hand.
INSTALL: this SHOULD contain build instructions, such as "run ./autogen.sh if you checked out a copy from the repository". Shame on the ASIO developers, they just point the user to look for a non-existing "doc" directory.
You need autoconf (and friends) installed to transform configure.ac into configure. Once that is done, the build system becomes self-contained. That is, you can do a make dist-gzip to pack all the sources (and the configure script), transfer the tar.gz it to another system, and follow from the ./configure step, even if autoconf is not installed there.
So, Here are the steps I've followed just now.
I went to http://think-async.com, which is the website that hosts the non-boost asio.
Their download link led me to sourceforge, and version 1.4.8 of the software.
I then extracted the folder, and looking inside, I see the usual layout.
So the following steps include ./configure, make, and probably sudo make install.
I'm a new Linux programmer trying to develop shared libraries and have been able to successfully compile one in Eclipse using the Eclipse project settings; only to find that to create a Debian package I need a ./configure script! So I set up Autotools on my system, and tried to create an Autotools project in Eclipse. I created it with the default library settings, and then renamed the .C file to a .CPP file, and changed the entry in the Makefile.am as per the documentation. I cleaned the project, rebuilt the Makefile, but for some reason it's still looking for the old .C file!!!! (No rule to make target libTest.c needed by libTest_la-libTest.lo'!
I've spend hours trying to figure this one out to no avail. Could someone please help!
The .deps folder stands for dependencies. These are generated when ./configure is run. Doing a make distclean (if one exists) or equivalent will remove this .deps directory along with any other generated files. The make clean only removes generated object files.
Re-running configure should generate a list of source file dependencies. Invoking make itself does not re-generate the dependencies.
OK. Found out the answer was hidden in a .deps folder. Deleting the .deps folder fixed the issue. I will award the answer to whoever can explain why deleting the folder worked though, because I'm really confused on this one.
I've got a C++ project which uses automake and autoconf. I'm new to both of these.
My home directory is network mounted -- the same on every server we have -- and I want to compile and run the project (and its executable) concurrently on separate machines.
Our servers are frequently different architectures. My desktop is 32-bit, but the server is 64-bit, etc.
What options do I use in configure.ac and Makefile.am to compile the object files in separate directories named for the machine architectures? It's relatively simple to do this in a regular Makefile, but I don't know how to set autotools.
If you don't do anything "wrong" or unusual in your configure.ac and Makefile.am setup, this is supported automatically:
mkdir /some/where/build
cd /some/where/build
/else/where/source/configure --options...
make
make install
Basically, you create the build directory anywhere you want (in your case probably on a non-network mount), and call configure from there. This will then build the code in the build directory you have created.