Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2003 21:48:46 +0300
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Andrew Gallatin <gallatin@cs.duke.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: BSD make question
Message-ID:  <20030807184846.GB45191@sunbay.com>
In-Reply-To: <16178.40342.11000.35373@grasshopper.cs.duke.edu>
References:  <16178.40342.11000.35373@grasshopper.cs.duke.edu>

next in thread | previous in thread | raw e-mail | index | archive | help

--KFztAG8eRSV9hGtP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Aug 07, 2003 at 02:42:30PM -0400, Andrew Gallatin wrote:
>=20
> Using BSD make, how can I apply different rules based on different
> directories while using only a single makefile?
>=20
There's a .CURDIR variable that can be used to conditionalize
parts of a makefile.

> Ie, the appended Makefile results in the following compilations:
>=20
>     gcc -DLIB -c lib/foo.c -o lib/foo.o
>     gcc -DLIB -c lib/bar.c -o lib/bar.o
>     gcc -DMCP -c mcp/baz.c -o mcp/baz.o
>=20
> Is it possible to do something similar with BSD make?
>=20
It just works "as is" with bmake.  What's your problem, Drew?  ;-)

$ make -n
cc -O -pipe -march=3Dpentiumpro -c lib/foo.c
cc -O -pipe -march=3Dpentiumpro -c lib/bar.c
cc -O -pipe -march=3Dpentiumpro -c mcp/baz.c

> ###################################
> .SUFFIXES:
> .SUFFIXES: .o .c
>=20
> LIB=3D\
> 	lib/foo.c \
> 	lib/bar.c
>=20
> MCP=3D\
> 	mcp/baz.c
>=20
> all: $(LIB:.c=3D.o) $(MCP:.c=3D.o)
>=20
> lib/%.o: lib/%.c
> 	gcc -DLIB -c $< -o $@
>=20
> mcp/%.o: mcp/%.c
> 	gcc -DMCP -c $< -o $@
>=20
> .PHONY: clean
> clean:
> 	rm -f $(LIB:.c=3D.o) $(MCP:.c=3D.o)
> ###################################

--=20
Ruslan Ermilov		Sysadmin and DBA,
ru@sunbay.com		Sunbay Software Ltd,
ru@FreeBSD.org		FreeBSD committer

--KFztAG8eRSV9hGtP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE/Mp8OUkv4P6juNwoRAma3AJwPJtGNl8MYZvbcTku1iUGW1+MDIgCaAq48
dryjzMRBPUX5IiKTnBAAX4k=
=Z36E
-----END PGP SIGNATURE-----

--KFztAG8eRSV9hGtP--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030807184846.GB45191>