Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2003 21:55:42 +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:  <20030807185542.GC45191@sunbay.com>
In-Reply-To: <16178.40843.224377.273862@grasshopper.cs.duke.edu>
References:  <16178.40342.11000.35373@grasshopper.cs.duke.edu> <20030807184846.GB45191@sunbay.com> <16178.40843.224377.273862@grasshopper.cs.duke.edu>

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

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

On Thu, Aug 07, 2003 at 02:50:51PM -0400, Andrew Gallatin wrote:
>=20
> Ruslan Ermilov writes:
>  > 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.
>  >=20
>  > > 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?  ;-)
>  >=20
>  > $ make -n
>  > cc -O -pipe -march=3Dpentiumpro -c lib/foo.c
>=20
> ;)  But its missing the -DLIB or -DMCP.
>=20
> Thanks for the .CURDIR hint.
>=20
Ah, didn't notice it.  Try this:

=2Efor f in $(LIB)
$(f:.c=3D.o): $(f)
	gcc -DLIB -c $< -o $@
=2Eendfor

=2Efor f in $(MCP)
$(f:.c=3D.o): $(f)
	gcc -DMCP -c $< -o $@
=2Eendfor


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

--iFRdW5/EC4oqxDHL
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQE/MqCuUkv4P6juNwoRAvXDAJ4rp8/sAuusy27xlrl8iCN0s35mNACfUNas
lVBqO0XUciD7ZQUxOP4rDEM=
=wUOd
-----END PGP SIGNATURE-----

--iFRdW5/EC4oqxDHL--



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