From owner-freebsd-hackers Tue Feb 16 9:17:31 1999 Received: from excalibur.oceanis.net (ns.dotcom.fr [195.154.74.11]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA11843 for ; Tue, 16 Feb 1999 09:17:27 -0800 (PST) (envelope-from pixel@excalibur.oceanis.net) Received: (from pixel@localhost) by excalibur.oceanis.net (8.9.1/8.9.1) id RAA01752; Tue, 16 Feb 1999 17:17:18 GMT From: Emmanuel DELOGET Message-Id: <199902161717.RAA01752@excalibur.oceanis.net> Subject: Re: Makefile: >1 program without a single target each. In-Reply-To: <19990216154145.A1700@cs.uni-magdeburg.de> from Roland Jesse at "Feb 16, 1999 3:41:45 pm" To: jesse@prinz-atm.CS.Uni-Magdeburg.De (Roland Jesse) Date: Tue, 16 Feb 1999 18:17:18 +0100 (MET) Cc: hackers@FreeBSD.ORG (FreeBSD Hackers Mail List) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG As the well known Roland Jesse said... -> Hello, -> -> Assumed, I have the source code for more than just one program in a -> directory (because they share a couple source code files). How does -> the Makefile has to / should look like? -> -> Normally, I would do something like: -> -> [makefile deleted] -> -> But what do I do when the Makefile is supposed to handle more than -> just one potential target? How do I specify the OBJS variable -> depending on the different source files? -> -> [other deleted makefile] -> -> Any ideas to get around the OBJS-problem are appreciated. -> My idea is you may use a classic src/lib, src/prg1, src/prg2 directory tree. You may put the shared source files in the lib directory, with an independant Makefile. Then, in the other directories, you put the proggies related source code. I like this architecture, because it's very clear (don't spend hours about searching which files are related to a project, and which files are not). You may put a more basic makefile in the top src dir (something like # top Makefile ------------------------------------------------ TARGETDIRS = lib prg1 prg2 all : @for i in $(TARGETDIRS); do \ @echo "** entering directory "$$i ; \ (cd $$i ; $(MAKE) all CFLAGS=$(CFLAGS) ); \ @echo "** living directory "$$i ; \ done # src/lib Makefile --------------------------------------------- LIBNAME = mylib SRCS = lib_1.C lib_2.c lib_n.c OBJS = $(SRCS:.c=.o) all : $(OBJS) @$(AR) $(CREATEARCHVE) lib$(LIBNAME).a $(OBJS) @$(RANLIB) $(RANLIBOPTIONS) lib$(LIBNAME).a # src/prgn Makefile -------------------------------------------- # you may use the bsd.prog.mk file here, of course... LIBDIR += -L../lib LIBS += -lmylib SRCS = prgn_1.c prgn_p.c OBJS = $(SRCS:.c=.o) PRGNAME = prgn all : $(OBJS) $(CC) $(CFLAGS) -o $(PRGNAME) $(LIBDIR) $(LIBS) Of course, this is just an idea... ;) -> Roland -- ____________________________________________________________________ Emmanuel DELOGET [pixel] pixel@{dotcom.fr,epita.fr} ---- DotCom SA -------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message