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
➜ SMAUG coding
➜ I have no 'Makefile' and am still confused at to why I need one....
|
I have no 'Makefile' and am still confused at to why I need one....
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Alvryn
(6 posts) Bio
|
| Date
| Fri 11 Nov 2005 11:07 AM (UTC) |
| Message
| Hello there. I am trying to set up a MUD on my home Windows XP pc mainly for personal use, and to learn coding and building. I have a pretty good handle on the building part, but have no background in C programming. Though I'm pretty confident I can pick it up.. I need a bit of help for now.
I downloaded the windows version of SMAUG: winsmaug1.4a.zip
This version comes already installed with:
smaug.exe
startup.bat
I can successfully log onto the game, and have set myself as supreme being etc, through the startup.bat
I have taken cues from this forum and downloaded Cygwin as described. However, when I tried to compile my files I realized that there is no makefile included. I have not been able to find (here) what the makefile must consist of.
Doing a search of my hard-drive I did find makefiles in Cygwin, and was wondering if it could 'generate' one for me.
I do not want to download Nicks version used in the example because i have no use for the mxc that is included and think my version is closer to what i'm used to.
The reason I have decided to post is bacause there is almost no mention of this version of SMAUG in these forums or others, and what is here is pretty obsure.
So my main questions are:
How do I obtain a makefile?
Do I really even need a makefile and to compile at all?
Thank you in advance. | | Top |
|
| Posted by
| Conner
USA (381 posts) Bio
|
| Date
| Reply #1 on Fri 11 Nov 2005 12:32 PM (UTC) Amended on Tue 11 Mar 2008 03:31 AM (UTC) by Nick Gammon
|
| Message
| You don't need a makefile or to compile if you're never going to be making any changes to the code itslf, though 1.4a is riddled with bugs and you did mention that you think you can learn C which implies that you intend to make changes. Since you've said that you've already installed cygwin anyway, I'd visit www.smaugfuss.org and download the latest copy of SmaugFUSS 1.6 and install that in place of the version you've already installed. Then you'll have a version that's already got the majority of bugs fixed and that does come with a makefile as well as a whole community that's willing to help you as you go, both at this site and at forums.smaugfuss.org. Now, I'm not saying that you have to do this, just that it's what I would do in your situation. (SmaugFUSS does run under cygwin just fine, you only need to add/remove a # symbol in a couple of, maybe only one, spots in the makefile to compile it cleanly under cygwin 'out of the box'.)
[EDIT - 11 March 2008] - The Smaug FUSS site is now http://www.smaugmuds.org/ |
-=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
| Alvryn
(6 posts) Bio
|
| Date
| Reply #2 on Fri 11 Nov 2005 03:26 PM (UTC) |
| Message
| Ok, I have done as you suggested.
Compiled with no errors whatsoever.
I'm still having trouble using Cygwin and actually have
ended up using wordpad to make most of my changes because
of it. I'll wander around a bit more to get a good idea
of how it works.
Thank you for suggesting this version. | | Top |
|
| Posted by
| Conner
USA (381 posts) Bio
|
| Date
| Reply #3 on Fri 11 Nov 2005 05:05 PM (UTC) |
| Message
| Glad to be able to help, you might consider checking out a more true text editor like editpad+ (they have a lite version which is free) or Vim for windows so they don't add anything to your files like line feeds instead of carriage returns, but otherwise you sound like you're well on your way. If you skim through the forums at smaugfuss.org you should already be caught up on the bug fixes to date, but there may be enhancement fixes posted or just discussions that you will find useful/interesting too.
|
-=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
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #4 on Fri 11 Nov 2005 08:08 PM (UTC) Amended on Fri 11 Nov 2005 08:09 PM (UTC) by Nick Gammon
|
| Message
| There is a whole book (and man page) about the program "make" and the files it reads. Typically the file is called "Makefile". The reason for having it at all is to simplify compiling large projects.
For a simple program you won't need a makefile, and can compile and link it in a single line:
gcc test.c -o test
This compiles test.c and produces "test" as an executable. (This example assumes you are using Unix or Cygwin as a development platform).
You can even compile more than one source file and link them together in one line:
gcc test.c test2.c -o test
This compiles test.c and test2.c and links them to produce "test" executable.
However once you get many files in your project this gets tedious, and more importantly, the command above would recompile every file even if only some have changed.
This is where "make" comes into it. The example below is a small "Makefile" that I used for compiling a small server. It compiles 3 files (tinywebserver.cpp utils.cpp and messages.cpp).
However it uses the relationship between the .cpp and the .o files to work out which ones to compile. Typing "make" in this case recompiles all required files and creates "tinywebserver".
CC=g++
CCFLAGS=-g -Wall
O_FILES = tinywebserver.o utils.o messages.o
tinywebserver : $(O_FILES)
$(CC) $(CCFLAGS) -o tinywebserver $(O_FILES)
.SUFFIXES : .o .cpp
.cpp.o :
$(CC) $(CCFLAGS) -c $<
clean:
rm tinywebserver *.o
(Note, the indented lines have a <tab> at the start, not a series of spaces, otherwise they won't work).
Now if you change one file (like utils.cpp) and then type "make" it recompiles utils.cpp and then relinks.
There is still a problem with this example. If an include file is changed (for example, utils.h) then this won't force a recompile as the dependency of utils.cpp and tinywebserver.cpp is not known by make.
One way around this is to simply force a recompile of everything when you change include files (type "make clean") however this is a rather brute-force approach, and you might forget.
Fortunately there is a way of working this out. Using the -MM option in gcc you can find out dependencies, like this:
$ gcc -MM tinywebserver.cpp
tinywebserver.o: tinywebserver.cpp utils.h clients.h
$ gcc -MM utils.cpp
utils.o: utils.cpp utils.h
The output from that can be used as input to make to tell it what files depend on what.
If we modify the Makefile a bit we can get it to generate these dependency files, and then use them next time around:
CC=g++
CCFLAGS=-g -Wall
O_FILES = tinywebserver.o utils.o messages.o
tinywebserver : $(O_FILES)
$(CC) $(CCFLAGS) -o tinywebserver $(O_FILES)
# pull in dependency info for *existing* .o files
-include $(O_FILES:.o=.d)
.SUFFIXES : .o .cpp
.cpp.o :
$(CC) $(CCFLAGS) -c $<
$(CC) -MM $(CFLAGS) $*.cpp > $*.d
clean:
rm tinywebserver *.o *.d
(New stuff in bold). Now, each time you type "make" it uses the dependency files (the .d files) generated last time you compiled to work out what needs to be recompiled, even if you only changed an include file, this time around.
The only caveat is that if you add a new .cpp file you would need to do a "make clean" (or at least regenerate the .d files) so it knows about the new dependencies.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Alvryn
(6 posts) Bio
|
| Date
| Reply #5 on Sat 12 Nov 2005 10:14 AM (UTC) |
| Message
| I thank you Nick for the long and explicit reply.
If I had some knowledge of Unix commands or C coding I'm
sure I would not be half as confused as I am right now.
As I said, this is a learning project for me and every bit
helps. So even though my ears are smoking right now I thank you. Your pages and forum are a great resource and have helped me greatly already. | | 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.
21,380 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top