Re: switching from gnu make to bsd make
On Fri, 11 Feb 2011 10:26:13 +0200, Vikash Badal wrote: > Make all produces the follow output: > > make all > cc -o bin/nntpd -lpthread -lmysqlclient_r -Wall -g -Iinclude > -I/usr/local/include -I/usr/local/include/mysql -L/usr/local/lib > -L/usr/local/lib/mysql obj/log.o obj/cleanup.o obj/config.o > obj/leecherpool.o obj/mytime.o obj/nntp.o obj/upstream.o obj/mysleep.o > obj/sqlpool.o obj/sql.o obj/signalhandler.o obj/daemon.o obj/list.o > obj/tcpserver.o obj/tmpfiles.o obj/listenpool.o obj/workers.o > obj/nntpd.o > cc: obj/log.o: No such file or directory > cc: obj/cleanup.o: No such file or directory > cc: obj/config.o: No such file or directory > cc: obj/leecherpool.o: No such file or directory > cc: obj/mytime.o: No such file or directory > cc: obj/nntp.o: No such file or directory > cc: obj/upstream.o: No such file or directory > cc: obj/mysleep.o: No such file or directory > cc: obj/sqlpool.o: No such file or directory > cc: obj/sql.o: No such file or directory > cc: obj/signalhandler.o: No such file or directory > cc: obj/daemon.o: No such file or directory > cc: obj/list.o: No such file or directory > cc: obj/tcpserver.o: No such file or directory > cc: obj/tmpfiles.o: No such file or directory > cc: obj/listenpool.o: No such file or directory > cc: obj/workers.o: No such file or directory > cc: obj/nntpd.o: No such file or directory > *** Error code 1 > > With gmake : > $(OBJDIR)/%.o:${SRCDIR}/%.c > ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ > > This creates all the .o files I need Does gmake also create the `obj/' directory automagically? I kind of doubt that, unless the gmake folks have started doing all sorts of magic behind-your-back stuff. You have no makefile rule to create `obj/' and no dependency of all the object files to the object directory. > How do I do this with bsd make ? The canonical way of writing a program that depends on object files that _may_ live in another object directory is to use the existing makefile macros from `/usr/share/mk/bsd.*.mk'. This means you will have to re-organize your Makefile a bit though. Instead of all the hand-crafted rules you are now trying to debug, which are nice but will take ages to 'get the job done', you should probably use a Makefile like this: PROG= nntpd SRCS= cleanup.c \ config.c \ leecherpool.c \ list.c \ listenpool.c \ log.c \ mysleep.c \ mytime.c \ nntpd.c \ signalhandler.c \ sql.c \ tcpserver.c \ upstream.c \ workers.c MYSQLPREFIX?= /usr/local MYSQLINCDIR?= ${MYSQLPREFIX}/include MYSQLLIBDIR?= ${MYSQLPREFIX}/lib CFLAGS+=-I${.CURDIR}/include \ -I/usr/local/include \ -I${MYSQLINCDIR} LDFLAGS+= -L/usr/local/lib \ -L${MYSQLLIBDIR} LDADD+= -lmysqlclient_r -lpthread .include By using the `bsd.prog.mk' rules, you can now type stuff like this: 1. # Build everything, putting object files in the current directory. make all 2. # Build and install everything, but use debugging CFLAGS and inhibit # the final 'strip' step of 'make install' by setting DEBUG_FLAGS. make CFLAGS='' DEBUG_FLAGS='-O0 -ggdb' all install 3. # Clean everything. make clean 4. # Build everything, but instead of installing in /usr/{bin,sbin} # install in a chroot under `/tmp/chroot', with the binaries # auto-mapped to `/tmp/chroot/usr/{bin,sbin}'. env DESTDIR='/tmp/chroot' make install 5. # Set up a special 'object tree' under /tmp/obj, to keep the sources # clean from generated files. mkdir /tmp/obj # Point the bsd.*.mk glue to the new object tree. export MAKEOBJDIRPREFIX=/tmp/obj # Create a 'mirror' of the source tree under `/tmp/obj', so that # e.g. the object code for `/home/keramida/src/foo' will be saved at # `/tmp/obj/home/keramida/tmp/foo'. make obj # Try to build `.depend' files with source/header -> object file # dependencies. make depend # Biuld everything, saving object code in /tmp/obj make all # Clean up /tmp/obj. Then clean up current directory too. make cleandir make cleandir The bsd.prog.mk rules will take care of creating the object directory paths; they will take care of generating the appropriate rules to build with the sources in one place and the object files in another directory; the macros will let you built multiple snapshots of the same source tree in different places, e.g. one for 'release' builds and one for 'debug' builds with different CFLAGS, etc. Another important point is that if you _do_ the legwork of converting the makefile rules from gmake to BSD make, you will have tons of examples of how to do things by looking at the makefiles of FreeBSD itself. All our makefiles use bsd.prog.mk, bsd.lib.mk, a
Re: switching from gnu make to bsd make
On Thu, 10 Feb 2011 17:59:14 -0600 (CST), Robert Bonomi wrote: >> From: Vikash Badal >> Date: Thu, 10 Feb 2011 11:30:02 +0200 >> Subject: RE: switching from gnu make to bsd make >> >> > -Original Message- >> > From: Polytropon [mailto:free...@edvax.de] Sent: 10 February 2011 10:11 >> > AM To: Vikash Badal Cc: freebsd-questions@freebsd.org Subject: Re: >> > switching from gnu make to bsd make >> > >> > Of course, in my testing case OBJDIR and SRCDIR are empty, and I >> > didn't define any of CC, CFLAGS, INCDIR or LIBDIR, so the defaults >> > have been chosen. >> > >> > Do you encounter a specific problem? >> >> This is my problem: >> >> vix:$ make make: don't know how to make src/%.c. Stop > > Just telling people "what happened" is *NOT* enough for intelligent > diagnosis of the problem. You also have to tell people WHAT YOU DID > that provoked the error you encountered. > > That said, dusting off my crystal ball -- which appears to be *working* > today -- you simply typed "make" at the shell prompt. > > Try typing "make all" and see what happens then. Right. this should fix the immediate problem. The 'bug' seems to be that the Makefile lists the '$(OBJDIR)/%.o' target *first*. >> this is my make file: >> >> -- >> >> CC= cc > * LIBS = -lpthread -lmysqlclient_r >> CFLAGS= -Wall -g >> INCDIR= -Iinclude -I/usr/local/include -I/usr/local/include/mysql >> LIBDIR= -L/usr/local/lib -L/usr/local/lib/mysql >> OBJDIR= obj >> SRCDIR= src >> BINDIR= bin >> PREFIX= /usr/local/nntpd >> BINDIRFILES = ${BINDIR}/nntpd >> OBJS = ${OBJDIR}/log.o ${OBJDIR}/cleanup.o ${OBJDIR}/config.o \ >> ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o >> ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o >> ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o >> ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o >> ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ >> ${OBJDIR}/nntpd.o >> >> $(OBJDIR)/%.o:${SRCDIR}/%.c >> ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ >> >> all:${OBJS} >> ${CC} -o ${BINDIR}/nntpd ${LIBS} ${CFLAGS} ${INCDIR} ${LIBDIR} \ >> ${OBJDIR}/log.o ${OBJDIR}/cleanup.o ${OBJDIR}/config.o \ >> ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o ${OBJDIR}/nntp.o \ >> ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o ${OBJDIR}/sqlpool.o \ >> ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o ${OBJDIR}/daemon.o \ >> ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o ${OBJDIR}/tmpfiles.o \ >> ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ >> ${OBJDIR}/nntpd.o Try swapping the order of the two targets above. BSD make(1) considers the first target the 'default', so when you just type 'make' it tries to build a target named '$(OBJDIR)/%.o', which fails. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
RE: switching from gnu make to bsd make
> -Original Message- > From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- > questi...@freebsd.org] On Behalf Of Robert Bonomi > Sent: 11 February 2011 01:59 AM > To: Vikash Badal > Cc: freebsd-questions@freebsd.org > Subject: Re: switching from gnu make to bsd make > > Try typing "make all" and see what happens then. > > Make all produces the follow output: make all cc -o bin/nntpd -lpthread -lmysqlclient_r -Wall -g -Iinclude -I/usr/local/include -I/usr/local/include/mysql -L/usr/local/lib -L/usr/local/lib/mysql obj/log.o obj/cleanup.o obj/config.o obj/leecherpool.o obj/mytime.o obj/nntp.o obj/upstream.o obj/mysleep.o obj/sqlpool.o obj/sql.o obj/signalhandler.o obj/daemon.o obj/list.o obj/tcpserver.o obj/tmpfiles.o obj/listenpool.o obj/workers.o obj/nntpd.o cc: obj/log.o: No such file or directory cc: obj/cleanup.o: No such file or directory cc: obj/config.o: No such file or directory cc: obj/leecherpool.o: No such file or directory cc: obj/mytime.o: No such file or directory cc: obj/nntp.o: No such file or directory cc: obj/upstream.o: No such file or directory cc: obj/mysleep.o: No such file or directory cc: obj/sqlpool.o: No such file or directory cc: obj/sql.o: No such file or directory cc: obj/signalhandler.o: No such file or directory cc: obj/daemon.o: No such file or directory cc: obj/list.o: No such file or directory cc: obj/tcpserver.o: No such file or directory cc: obj/tmpfiles.o: No such file or directory cc: obj/listenpool.o: No such file or directory cc: obj/workers.o: No such file or directory cc: obj/nntpd.o: No such file or directory *** Error code 1 With gmake : $(OBJDIR)/%.o:${SRCDIR}/%.c ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ This creates all the .o files I need How do I do this with bsd make ? > > > > > > this is my make file: > > > > - > - > > > > CC= cc > * LIBS = -lpthread -lmysqlclient_r > > CFLAGS= -Wall -g > > INCDIR= -Iinclude -I/usr/local/include - > I/usr/local/include/mysql > > LIBDIR= -L/usr/local/lib -L/usr/local/lib/mysql > > OBJDIR= obj > > SRCDIR= src > > BINDIR= bin > > PREFIX= /usr/local/nntpd > > BINDIRFILES = ${BINDIR}/nntpd > > OBJS = ${OBJDIR}/log.o ${OBJDIR}/cleanup.o > ${OBJDIR}/config.o \ > > ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o > > ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o > > ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o > > ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o > > ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ > > ${OBJDIR}/nntpd.o > > > > $(OBJDIR)/%.o:${SRCDIR}/%.c > > ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ > > > > all:${OBJS} > > ${CC} -o ${BINDIR}/nntpd ${LIBS} ${CFLAGS} ${INCDIR} > ${LIBDIR} \ > > ${OBJDIR}/log.o ${OBJDIR}/cleanup.o ${OBJDIR}/config.o \ > > ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o ${OBJDIR}/nntp.o \ > > ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o ${OBJDIR}/sqlpool.o > \ > > ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o ${OBJDIR}/daemon.o > \ > > ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o ${OBJDIR}/tmpfiles.o \ > > ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ > > ${OBJDIR}/nntpd.o > > > > - > - > > > ___ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions- > unsubscr...@freebsd.org" Please note: This email and its content are subject to the disclaimer as displayed at the following link http://www.is.co.za/legal/E-mail+Confidentiality+Notice+and+Disclaimer.htm. Should you not have Web access, send a mail to disclaim...@is.co.za and a copy will be emailed to you. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: switching from gnu make to bsd make
> From: Vikash Badal > Date: Thu, 10 Feb 2011 11:30:02 +0200 > Subject: RE: switching from gnu make to bsd make > > > -Original Message- > > From: Polytropon [mailto:free...@edvax.de] Sent: 10 February 2011 10:11 > > AM To: Vikash Badal Cc: freebsd-questions@freebsd.org Subject: Re: > > switching from gnu make to bsd make > > > > Of course, in my testing case OBJDIR and SRCDIR are empty, and I didn't > > define any of CC, CFLAGS, INCDIR or LIBDIR, so the defaults have been > > chosen. > > > > Do you encounter a specific problem? > > This is my problem: > > vix:$ make make: don't know how to make src/%.c. Stop Just telling people "what happened" is *NOT* enough for intelligent diagnosis of the problem. You also have to tell people WHAT YOU DID that provoked the error you encountered. That said, dusting off my crystal ball -- which appears to be *working* today -- you simply typed "make" at the shell prompt. Try typing "make all" and see what happens then. > > > this is my make file: > > -- > > CC= cc * LIBS = -lpthread -lmysqlclient_r > CFLAGS= -Wall -g > INCDIR= -Iinclude -I/usr/local/include -I/usr/local/include/mysql > LIBDIR= -L/usr/local/lib -L/usr/local/lib/mysql > OBJDIR= obj > SRCDIR= src > BINDIR= bin > PREFIX= /usr/local/nntpd > BINDIRFILES = ${BINDIR}/nntpd > OBJS = ${OBJDIR}/log.o ${OBJDIR}/cleanup.o ${OBJDIR}/config.o \ > ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o > ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o > ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o > ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o > ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ > ${OBJDIR}/nntpd.o > > $(OBJDIR)/%.o:${SRCDIR}/%.c > ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ > > all:${OBJS} > ${CC} -o ${BINDIR}/nntpd ${LIBS} ${CFLAGS} ${INCDIR} ${LIBDIR} \ > ${OBJDIR}/log.o ${OBJDIR}/cleanup.o ${OBJDIR}/config.o \ > ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o ${OBJDIR}/nntp.o \ > ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o ${OBJDIR}/sqlpool.o \ > ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o ${OBJDIR}/daemon.o \ > ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o ${OBJDIR}/tmpfiles.o \ > ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ > ${OBJDIR}/nntpd.o > > -- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: switching from gnu make to bsd make
On Thu, Feb 10, 2011 at 8:32 AM, Vikash Badal wrote: > Can someone please advise me as to how I switch the following lines of gnu > make to bsd make > > > $(OBJDIR)/%.o:${SRCDIR}/%.c > ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ > I use BSD make for XML and XSLT transformations, so I cannot advise you about this particular issue, but there is a very nice tutorial about the BSD make at http://www.freebsd.org/doc/en_US.ISO8859-1/books/pmake/index.html Good luck ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
RE: switching from gnu make to bsd make
> -Original Message- > From: Polytropon [mailto:free...@edvax.de] > Sent: 10 February 2011 10:11 AM > To: Vikash Badal > Cc: freebsd-questions@freebsd.org > Subject: Re: switching from gnu make to bsd make > > Of course, in my testing case OBJDIR and SRCDIR are > empty, and I didn't define any of CC, CFLAGS, INCDIR or > LIBDIR, so the defaults have been chosen. > > Do you encounter a specific problem? This is my problem: vix:$ make make: don't know how to make src/%.c. Stop this is my make file: -- CC= cc LIBS = -lpthread -lmysqlclient_r CFLAGS= -Wall -g INCDIR= -Iinclude -I/usr/local/include -I/usr/local/include/mysql LIBDIR= -L/usr/local/lib -L/usr/local/lib/mysql OBJDIR= obj SRCDIR= src BINDIR= bin PREFIX= /usr/local/nntpd BINDIRFILES = ${BINDIR}/nntpd OBJS = ${OBJDIR}/log.o ${OBJDIR}/cleanup.o ${OBJDIR}/config.o \ ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o ${OBJDIR}/nntp.o \ ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o ${OBJDIR}/sqlpool.o \ ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o ${OBJDIR}/daemon.o \ ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o ${OBJDIR}/tmpfiles.o \ ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ ${OBJDIR}/nntpd.o $(OBJDIR)/%.o:${SRCDIR}/%.c ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ all:${OBJS} ${CC} -o ${BINDIR}/nntpd ${LIBS} ${CFLAGS} ${INCDIR} ${LIBDIR} \ ${OBJDIR}/log.o ${OBJDIR}/cleanup.o ${OBJDIR}/config.o \ ${OBJDIR}/leecherpool.o ${OBJDIR}/mytime.o ${OBJDIR}/nntp.o \ ${OBJDIR}/upstream.o ${OBJDIR}/mysleep.o ${OBJDIR}/sqlpool.o \ ${OBJDIR}/sql.o ${OBJDIR}/signalhandler.o ${OBJDIR}/daemon.o \ ${OBJDIR}/list.o ${OBJDIR}/tcpserver.o ${OBJDIR}/tmpfiles.o \ ${OBJDIR}/listenpool.o ${OBJDIR}/workers.o \ ${OBJDIR}/nntpd.o -- > > > > -- > Polytropon > Magdeburg, Germany > Happy FreeBSD user since 4.0 > Andra moi ennepe, Mousa, ... Please note: This email and its content are subject to the disclaimer as displayed at the following link http://www.is.co.za/legal/E-mail+Confidentiality+Notice+and+Disclaimer.htm. Should you not have Web access, send a mail to disclaim...@is.co.za and a copy will be emailed to you. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: switching from gnu make to bsd make
On Thu, 10 Feb 2011 09:32:06 +0200, Vikash Badal wrote: > Can someone please advise me as to how I switch the following lines of gnu > make to bsd make > > > $(OBJDIR)/%.o:${SRCDIR}/%.c > ${CC} -c ${CFLAGS} ${INCDIR} ${LIBDIR} $< -o $@ It sems to work with BSD make, I've tried it. % make foo ... starts compiling foo.c ... The only thing I would change is the order of the last arguments, which should be "-o $@ $<" (input files last), and a space after ":" in the first line (for better reading). Anyway, it seems to be compatible. Of course, in my testing case OBJDIR and SRCDIR are empty, and I didn't define any of CC, CFLAGS, INCDIR or LIBDIR, so the defaults have been chosen. Do you encounter a specific problem? -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"