leopoodle
leopoodle

Reputation: 2482

How to write "install" target in Makefile

I am new to Makefile and like to write an install target in Makefile. My Makefile is going to be called from another Makefile like this:

DESTDIR=$(DIR_A) BINDIR=/dir_b make -C $(CURDIR)/xxxx/yyy all

where /xxxx/yyy is where my Makefile is located.

My Makefile is going to generate 2 binaries that I like to install them i.e. by install, I mean to copy both of the binaries to a specific directory (BINDIR) and make them executable.

How should I write the install target in this case if my 2 binaries are generated in /aaaa/bbbb/bin folder?

Upvotes: 7

Views: 6148

Answers (1)

DYZ
DYZ

Reputation: 57033

"Install" is going to be a "phony" target. And I strongly advise to use utility install instead of cp and chmod:

.PHONY: install
install:
    install -m 0755 /aaaa/bbbb/bin/first /aaaa/bbbb/bin/second $BINDIR

Now, you can do make install.

Upvotes: 3

Related Questions