2

My project is already being compiled into a .so and .a file. I want my Makefile to directly generate the RPM. I have found a way to generate the RPM here: What is the minimum I have to do to create an RPM file?

Can I just use shell commands in a Makefile? Or should I call a shell script from the Makefile to do this for me.

Community
  • 1
  • 1
Sid Sahay
  • 368
  • 5
  • 20
  • 2
    You can do it either way. – Fara Importanta Jul 04 '16 at 08:59
  • Okay. I guess doing it in the Makefile will be better since I can make use of the variables set in my configure script? – Sid Sahay Jul 04 '16 at 09:09
  • 1
    That's right and it's one less script to maintain. In a general way I'd recommend to put in the Makefile anything that fits without too much complexity. – Tim Jul 04 '16 at 09:12
  • Can I use an m4 file for this? That way, it'll be a separate macro that I could just call; more modularization. – Sid Sahay Jul 04 '16 at 09:14
  • 1
    The variables are not a problem, you can pass them as parameters to the script. My rule of thumb is that if the logic for building the RPM is too big (and it usually is) it's better put in a script. That also has the benefit that it avoids some limitations on what you can do in a Makefile. – Fara Importanta Jul 04 '16 at 09:18
  • 1
    Sid, the `.spec` file is the basis for rpm building. While there are some makefiles that will output a `.spec` file for you, it is generally your `.spec` file that will be calling your makefiles to build the package. The maximumrpm site is an oldie but a goodie for walking through the process. – David C. Rankin Jul 04 '16 at 09:19
  • Thanks a lot David and @FaraImportanta! – Sid Sahay Jul 04 '16 at 09:55

1 Answers1

3

I was in your position 10 years ago. We had a Makefile for generating tar.gz, srpm, rpm. Another target for generating RPMs from snapshots. It grows up every month. At the end we had huge Makefile splitted into several files, which was pain to maintain.

That was the time when Tito project was born: https://github.com/dgoodwin/tito

Just drop .spec file in that git directory and use Tito for RPM building. You can use just fraction of its features. And you can learn the more powerful features later.

You do not need to care about changelog bumping. Checking if your collegues pushed git-tag. Inventing how to bump up release for developers build etc.

msuchy
  • 5,162
  • 1
  • 14
  • 26