Date: Tue, 16 Feb 1999 18:17:18 +0100 (MET) From: Emmanuel DELOGET <pixel@DotCom.FR> To: jesse@prinz-atm.CS.Uni-Magdeburg.De (Roland Jesse) Cc: hackers@FreeBSD.ORG (FreeBSD Hackers Mail List) Subject: Re: Makefile: >1 program without a single target each. Message-ID: <199902161717.RAA01752@excalibur.oceanis.net> In-Reply-To: <19990216154145.A1700@cs.uni-magdeburg.de> from Roland Jesse at "Feb 16, 1999 3:41:45 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902161717.RAA01752>
