all: application that builds application. Now I want to add and
option that user can type 'make install' that will copy (and build
if it hasn't been) to $PLATFORM/application to $APP/bin/
Thanks
> Thanks
From what you've said, adding this to your Makefile should work:
install: application
cp $PLATFORM/application $APP/bin/.
--
John Gordon A is for Amy, who fell down the stairs
gor...@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Don't forget to add
.PHONY: install
so that make doesn't expect cp to generate a file called `install'.
Also, you probably need to set the ownership and permissions of the file.
Your system probably has a program called `install' to do these all at
once. Try:
man 1 install
Alternatively you can add more command lines to the Makefile:
install: application
cp $PLATFORM/application $APP/bin/
chmod 755 $APP/bin/
chown root:wheel $APP/bin/
Well, here is my solution that i discovered by googling for sample
Makefile:
Below is what has been added to the file:
.SILENT: install
install:
echo "Installing Application..."; \
if test ! -d $(APP_DIR); then \
mkdir -p $(APP_DIR)/; \
echo "Copying resources:"; \
cp -f config_file_template $(APP_DIR); \
echo "Rename config_file_template to config_file, and modify
it appropriately." ; \
cp -f start_app.sh $(APP_DIR)/; \
echo "Use start_app.sh to start the application"; \
fi; \
if test -e $(PLATFORM)/$(APP); then \
/bin/cp -f $(PLATFORM)/$(APP) $(APP_DIR)/ ; \
else \
echo $(APP) binary is missing; \
fi; \
echo Done
What do you think about this solution?
It's doing in 16 lines what could be done in four or less.
--
Måns Rullgård
ma...@mansr.com
And don't forget .PHONY, to be pedantic.
> if test -e $(PLATFORM)/$(APP); then \
> /bin/cp -f $(PLATFORM)/$(APP) $(APP_DIR)/ ; \
> else \
> echo $(APP) binary is missing; \
> fi; \
The right way to do that is to make $(PLATFORM)/$(APP) a prerequisite!
As Måns suggests, the rest can be simplified further.
> >> I have Makefile that build a pretty complex application. In
> >> it, have all: application that builds application. Now I
> >> want to add and option that user can type 'make install'
> >> that will copy (and build if it hasn't been) to
> >> $PLATFORM/application to $APP/bin/
> > From what you've said, adding this to your Makefile should work:
> > install: application
> > cp $PLATFORM/application $APP/bin/.
> Don't forget to add
> .PHONY: install
> so that make doesn't expect cp to generate a file called `install'.
That's not really necessary. It does protect you if someone
accidentally creates a file named install, or from invoking the
rule twice in any given run, but typically, these aren't real
problems.
> Also, you probably need to set the ownership and permissions
> of the file.
> Your system probably has a program called `install' to do
> these all at once. Try:
> man 1 install
> Alternatively you can add more command lines to the Makefile:
> install: application
> cp $PLATFORM/application $APP/bin/
> chmod 755 $APP/bin/
> chown root:wheel $APP/bin/
Given the varieties in install, I generally either provide a
script in the local directory which does what I want, or do
something like the above. (Note, however, that the chown isn't
likely to work unless you're root.)
--
James Kanze (GABI Software) email:james...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
> .SILENT: install
Why?
> install:
> echo "Installing Application..."; \
> if test ! -d $(APP_DIR); then \
> mkdir -p $(APP_DIR)/; \
> echo "Copying resources:"; \
> cp -f config_file_template $(APP_DIR); \
> echo "Rename config_file_template to config_file, and modify
> it appropriately." ; \
> cp -f start_app.sh $(APP_DIR)/; \
> echo "Use start_app.sh to start the application"; \
> fi; \
Don't you have a bit too much in the if? For that matter, the
if isn't really necessary: "mkdir -p" succeeds if the directory
is already present.
> if test -e $(PLATFORM)/$(APP); then \
> /bin/cp -f $(PLATFORM)/$(APP) $(APP_DIR)/ ; \
> else \
> echo $(APP) binary is missing; \
> fi; \
> echo Done
> What do you think about this solution?
Not knowing what your application needs, it's hard to judge.
For starters, I'd just do something like:
install: $(APP)
mkdir -p $(PREFIX)/bin
cp $(APP) $(PREFIX)/bin/$(APP)
chmod 644 $(PREFIX)/bin/$(APP)
This supposes only one version, of course. If you want to
maintain versions for several different platforms on the same
disk, you may want to split $(PREFIX) off into an $(EXEC_PREFIX)
and a $(SHARED_PREFIX).
It's *unlikely* to be a real problem - but I prefer to include
a .PHONY declaration as it also adds to the Makefile's internal
documentation by clarifying intent.
This is more important if one is mixing phony and non-phony ('empty')
flag targets, which might otherwise be hard to distinguish without
carefully studying the rules.
> ...
> --
> James Kanze (GABI Software) email:james.ka...@gmail.com