Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ Compiling the server ➜ Deletion of O directory necessary?

Deletion of O directory necessary?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by Samson   USA  (683 posts)  Bio
Date Reply #15 on Sun 04 Sep 2005 12:48 AM (UTC)
Message
Now then. When I type "make .depend" the .depend file is generated properly from what I can tell. The above post is only part of it, but it has plenty more where that came from.

So one then expects that if an H file is modified, typing "make" at this point should cause it to compile the necessary files, right? It doesn't do anything at all.
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #16 on Sun 04 Sep 2005 02:51 AM (UTC)

Amended on Tue 11 Mar 2008 03:22 AM (UTC) by Nick Gammon

Message
A solution was found by Eloi@EoD:

http://forums.smaugfuss.org/index.php?a=topic&t=3#p2

[EDIT - 11 March 2008] - The Smaug FUSS site is now http://www.smaugmuds.org/
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #17 on Sun 04 Sep 2005 05:17 AM (UTC)

Amended on Sun 04 Sep 2005 05:18 AM (UTC) by David Haley

Message
Samson, I think your problem is that you include the depend information after you have the o/%.o:%.c rule. That means that the first rule takes precedence, I think. Note that the solution posted on your link does just that - it doesn't have the first rule.

FWIW, I didn't come up with what I posted. It's something I found on google, and the versions posted here are indeed much simpler. I'm not sure why the sed stuff was necessary. To be honest once it worked, I just stopped fiddling with it.

EDIT: Note however that your solution depends on the makedepend program, which is not necessarily a good thing. What I proposed (and others as well IIRC) uses only gcc.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #18 on Sun 04 Sep 2005 08:01 AM (UTC)
Message

purge:  
	@rm -f o/*.o $(AFKMUD) afkmud.def afkmud.exp core $(RESOLVER) resolver.o

o/%.o: %.c
	@echo "  Compiling $@....";
	$(CC) -c $(C_FLAGS) $< -o $@

.c.o: mud.h
	$(CC) -c $(C_FLAGS) $<

# Funky "if exists.." stuff could be put here. I'm cheating. :-D
.depend:
	@rm -f .depend
	@touch .depend
	@makedepend -po/ -f .depend $(C_FILES) > /dev/null 2>&1

# Include the generated file.
include .depend


Well that's the last chunk of the Makefile and it has the o/%.o: %.c rule there, and it works just fine this way. Does exactly what I and others are expecting it to do.

So what's wrong with using the makedepend command?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #19 on Sun 04 Sep 2005 08:51 AM (UTC)

Amended on Sun 04 Sep 2005 08:55 AM (UTC) by David Haley

Message
Well, the first problem is that GCC does it already, so why introduce another program into the toolchain?

The second and much more significant reason is that makedepend does not seem to be included in Cygwin. At least, I was unable to find 'makedepend' in the list of available Cygwin packages, nor could I run it after updating make to the latest version.

So, since it's not in Cygwin and since gcc does the job already, makedepend seems like a bad choice.

EDIT:
Oh, and here's why I think the new makefile worked but the old one didn't. This one generates dependencies of the .c files and puts those after the dependencies of the .o files. Your previous method though seems to be generating dependencies of the .o files, which were already specified in the o/%.o:%.c rule. All this is just a guess but given what your .depend looks like I think it's fairly likely. I could be completely wrong though...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #20 on Sun 04 Sep 2005 05:42 PM (UTC)
Message
Well I tried the method you suggested but it didn't work, was placed as follows:


clean:  
	@rm -f o/*.o $(AFKMUD) afkmud.def afkmud.exp core $(RESOLVER) resolver.o
	$(MAKE) all
        
purge:  
	@rm -f o/*.o $(AFKMUD) afkmud.def afkmud.exp core $(RESOLVER) resolver.o

DEPDIR = deps
df = $(DEPDIR)/$(*F)

o/%.o: %.c
    $(CC) -MD -c $(C_FLAGS) -o $@ $<
    @cp $*.d $(df).P; \
      sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\$$//' \
          -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P; \
      rm -f $*.d

-include $(O_FILES:o/%.o=$(DEPDIR)/%.P)


Touching an H file did not cause it to recompile anything. Perhaps I've done something wrong but it looked to me like I got it in the right spot. The makedepend method may not be the best choice but so far it's the only choice that's worked.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #21 on Sun 04 Sep 2005 07:27 PM (UTC)
Message
I think the problem is that the object files are in a different directory? So when it includes them, it includes dependencies for %.o, not o/%.o...

I know for a fact that what I have works on my MUD, and somebody suggested something else from theirs. The easiest would be to send me the makefile you have and let me tweak it so that we don't have to keep going back-and-forth. Are you using the SMAUGfuss makefile that I can download from your site?

What I suspect has to happen is that the dependency files need to be modified such that any reference to *.o is replaced by a reference to o/*.o. That can probably be done fairly easily with sed, or even maybe makefile substitution rules on include.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Conner   USA  (381 posts)  Bio
Date Reply #22 on Sun 04 Sep 2005 08:05 PM (UTC)
Message
alright, here's my Makefile (currently working, but using makedepend)
Quote:
CC = gcc
#PROF = -p

#Uncomment to compile in Cygwin
#CYGWIN = -DCYGWIN

# Uncomment the two lines below if compiling on a Solaris box
#SOLARIS_FLAG = -Dsun -DSYSV
#SOLARIS_LINK = -lnsl -lsocket

#Intermud-3 - Comment out to disable I3 support in your code
I3 = 1

#IMC2 - Comment out to disable IMC2 support
IMC = 1

W_FLAGS = -Wall -Wformat-security -Winline -Wpointer-arith -Wcast-align -Wredundant-decls -Wstrict-prototypes
# add this back into to above line after -Wall to revert to having all warnings reported as errors
# including shadowed declarations: -Werror -Wshadow

C_FLAGS = -O0 -g -g2 $(W_FLAGS) $(SOLARIS_FLAG) $(PROF)
L_FLAGS = $(PROF) $(SOLARIS_LINK)

C_FILES = act_comm.c act_info.c act_move.c act_obj.c act_wiz.c alias.c ban.c boards.c \
build.c clans.c color.c comm.c comments.c const.c db.c deity.c fight.c grub.c \
handler.c hashstr.c hiscores.c hotboot.c imm_host.c interp.c magic.c makeobjs.c \
mapout.c md5.c misc.c mpxset.c mud_comm.c mud_prog.c news.c planes.c player.c \
polymorph.c ratings.c renumber.c reset.c save.c services.c shops.c skills.c \
slay.c special.c tables.c track.c update.c wedding.c arena.c tattoo.c bank.c \
quest.c

# immscore.c locker.c

ifdef I3
C_FILES := i3.c $(C_FILES)
C_FLAGS := $(C_FLAGS) -DI3 -DI3SMAUG
endif

ifdef IMC
C_FILES := imc.c $(C_FILES)
C_FLAGS := $(C_FLAGS) -DIMC -DIMCSMAUG
endif

O_FILES := $(patsubst %.c,o/%.o,$(C_FILES))

H_FILES = $(wildcard *.h)

all: .depend
$(MAKE) -s smaug

ifdef CYGWIN
smaug: $(O_FILES)
rm -f smaug.exe
$(CC) -o smaug.exe $(O_FILES) $(L_FLAGS)
echo "Done compiling mud.";
chmod g+w smaug.exe
chmod a+x smaug.exe
chmod g+w $(O_FILES)

clean:
rm -f o/*.o smaug.exe *~
else
smaug: $(O_FILES)
rm -f smaug
$(CC) -o smaug $(O_FILES) $(L_FLAGS)
echo "Done compiling mud.";
chmod g+w smaug
chmod a+x smaug
chmod g+w $(O_FILES)

clean:
rm -f o/*.o smaug *~
$(MAKE) all
endif

o/%.o: %.c
echo " Compiling $@....";
$(CC) -c $(C_FLAGS) $< -o $@

.c.o: mud.h
$(CC) -c $(C_FLAGS) $<

.depend:
@rm -f .depend
@touch .depend
@makedepend -po/ -f .depend $(C_FILES) > /dev/null 2>&1

include .depend

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #23 on Sun 04 Sep 2005 10:48 PM (UTC)
Message
The Makefile Conner just posted is the same as the one I'm using in the parts that cover the depends. I'd rather not have to rely on something more than gcc myself but makedepend seems to be widely available. Technically yours relies on sed being available too, and while it may also be widely available, what guarantee do we have that it's on everyone's system? :P

Anyway, yes, would appreciate it if you could look at this and figure something out.
Top

Posted by Gatewaysysop2   USA  (146 posts)  Bio
Date Reply #24 on Mon 05 Sep 2005 05:43 AM (UTC)
Message
Meh. A bit late to the table, but I just realized that this correlates with me not being able to compile the latest distro of FUSS. Apparently makedepend is, as Ksilyan said, not included in Cygwin (at least not the version I have).

Does anyone know if this is currently available for Cygwin so I can update? Not *really* an issue since I was only going to compile it and test something stock versus my own modified base, but nevertheless I am curious.

If nothing else I can always revert the makefile. ;)




"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #25 on Mon 05 Sep 2005 07:33 AM (UTC)
Message
I looked in the full package list and didn't see makedepend for Cygwin. I'll be working on this makefile thing and will provide a gcc-only solution shortly.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #26 on Sat 10 Sep 2005 02:18 PM (UTC)
Message
Anything more on this?
Top

Posted by Gatewaysysop2   USA  (146 posts)  Bio
Date Reply #27 on Thu 15 Sep 2005 04:57 AM (UTC)
Message
I'm curious about this also. ;)

"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


72,055 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.