3

I'm making a very basic Debian repo for a client. Started with a bash script, but decided a Makefile would eliminate duplicated work. I've hammered out a working Makefile, but it works only if I make all. For some reason, a straight make only builds the first deb. make clean does nothing. What am I doing wrong?

MFGR:=MyCoolEmployer
MAJOR:=1
MINOR:=0
REVISION:=1000
VERSION:=$(MAJOR).$(MINOR)-$(REVISION)
MODELS:=SpiffyModel1 SpiffyModel2
COMMON:=common
SOFT_TARGETS:=$(COMMON) $(MODELS)
SOFT_TARGET_FOLDERS:=$(patsubst %, $(MFGR)-%_$(VERSION), $(SOFT_TARGETS))
DEBs := $(patsubst %, %.deb, $(SOFT_TARGET_FOLDERS))
REPO_DEBs :=$(patsubst %, Repo/binary/%, $(DEBs))
REPO=repo.zip
PACKAGES_GZ := Repo/binary/Packages.gz

%.deb: %
    dpkg-deb --build $<

$(REPO_DEBs): $(DEBs)
    cp $^ Repo/binary/

$(PACKAGES_GZ): $(REPO_DEBs)
    dpkg-scanpackages Repo/binary /dev/null | gzip -9c > $@

$(REPO): $(REPO_DEBs) $(PACKAGES_GZ)
    cd Repo; zip -r -v -0 ../$@ . ; cd ..

TARGETS: $(REPO) $(PACKAGES_GZ) $(REPO_DEBs) $(DEBs)

all:    TARGETS

clean:
    rm -f $(TARGETS)

This assumes the packages exist as folders named MyCoolEmployer-PACKAGENAME_1.0-1000

  • Can you clarify what happens when you do make clean?  Does it just go directly back to your shell prompt?  Does it pause a little?  Does it say anything?  Are you sure that your rm command begins with a tab and not a bunch of spaces?  If you add some innocuous command (like date or ls) immediately before or after the rm, do they run when you do make clean? – G-Man Jun 10 at 17:29
  • Next time, use remake, probably as remake -x to debug your Makefile – Basile Starynkevitch Jun 11 at 4:30
7

Your question contains its own answer.  By default, make processes only the first entry in the Makefile.  You need to put the "all" entry first.

6

The "make clean" does nothing because $(TARGETS) isn't a variable, you've never set it to any value.

  • This doesn't actually answer the question OP has. – ruohola Jun 11 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.