baccala@usna.arpa (Brent W Baccala) (10/20/86)
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. Thanks, - BRENT W. BACCALA - Aerospace Engineering Department U.S. Naval Academy Annapolis, MD <decvax!brl-smoke!usna!baccala> <seismo!usna!baccala> <baccala@usna.arpa> "I do graphics work on an SGI Iris, fun work on a VAX 11/780, grunge work on an IBM XT"
rs@mirror.UUCP (Rich Salz) (10/21/86)
In article <4730@brl-smoke.ARPA>, baccala@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: -@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@mirror.TMC.COM {mit-eddie, ihnp4, wjh12, cca, cbosgd, seismo}!mirror!rs