Installing Makefiles
Rich Salz
rs at mirror.UUCP
Wed Oct 22 02:07:27 AEST 1986
In article <4730 at brl-smoke.ARPA>, baccala at usna.arpa (Brent W Baccala) writes:
> Has anyone ever written a BSD-source-like Makefile which permits indiv.
> installation of binaries/libraries/documention. I was thinking of
> something like:
> make install_foo
> which would just install foo, without looking at any other files that
> might be laying around.
You can approximate this by taking assigning values to make variables
on the shell command line. This assignments silently override any
assignments made within the Makefile. Suppose you have two programs,
foo and bar. Then you can have a Makefile like the following:
top:
@echo "Say make WHAT=program target..."
install: $(WHAT)
cp $(WHAT) /usr/bin
# This won't catch foosubs.o, but it's good enough for now...
clean:
@rm -f $(WHAT) $(WHAT).o $(WHAT).lint
lint: lint.$(WHAT)
lint.$(WHAT):
lint $(LINTFLAGS) $(WHAT).c >lint.$(WHAT)
lint.foo:
lint $(LINTFLAGS) foo.c foosubs.c >lint.foo
foo: foo.o foosubs.o
$(CC) $(CFLAGS) foo.o foosubs.o -o foo
bar: bar.o
$(CC) $(CFLAGS) bar.o -o bar
With this Makefile, you can type "make WHAT=foo foo lint install" to compile,
lint, and install the 'foo' program.
If you have your source split into sub-directories, then you the game becomes
a bit cleaner: use a /bin/sh loop to loop and "recursively" call make
in each subdirectory for the targets you've specified. The trick is
in writing the loop:
install:
- at for i in $(LIST); \
do \
cd $$i ; make $(TARGET) ; cd .. \
done
Then you say things like 'make "LIST=foo bar baz zap" install'
Some versions of make have provisions to pass the make command-line flags
(e.g., -n, -t, etc.) on to such "recursive" invocations; this is usually
done through the MAKEFLAGS or MFLAGS macro, and is not always documented.
--
----
Rich $alz "Hi, mom!"
Mirror Systems rs at mirror.TMC.COM
{mit-eddie, ihnp4, wjh12, cca, cbosgd, seismo}!mirror!rs
More information about the Comp.unix.wizards
mailing list