Difference between revisions of "Installing New Modules"

From ASSS Wiki
Jump to: navigation, search
(added instructions for compiling using the asss makefile)
m (fixups to previous edit)
Line 6: Line 6:
  
 
=== Using the ASSS Makefile ===
 
=== Using the ASSS Makefile ===
The Makefile distributed with ASSS is designed to allow adding new code to it easily. This is probably the easiest way to get a new module compiling.
+
The Makefile distributed with ASSS is designed to allow adding new code to it easily. This is probably the easiest way to get a new module compiling, because all the correct compiler flags are supplied for you.
  
 
Create a directory for your module as a subdirectory of <tt>src</tt>, the directory containing all the ASSS code.
 
Create a directory for your module as a subdirectory of <tt>src</tt>, the directory containing all the ASSS code.

Revision as of 19:16, 16 January 2005

Firstly I want to say this is how I do it (Smong). Others may do it differently and can edit this page.

When you want to add more functionality to your server you can install new custom modules. Differences in server version often mean something will break in a module, so I like to distribute with source code.

C modules

Using the ASSS Makefile

The Makefile distributed with ASSS is designed to allow adding new code to it easily. This is probably the easiest way to get a new module compiling, because all the correct compiler flags are supplied for you.

Create a directory for your module as a subdirectory of src, the directory containing all the ASSS code.

$ cd asss-1.3.5/src
$ mkdir mymod

Create a mymod.mk file within that directory that looks like this:

mymod/mymod.$(SO): mymod/mymod.o

All *.mk files (let's call them "Makefile fragments") in any subdirectories will be included by the big Makefile automatically. Two fragments come in the contrib directory in the ASSS package, which you might want to look at as examples.

Note that we use a Makefile variable, $(SO), instead of typing .so directly. That's so that the same Makefile works on windows, where modules have to be named mymod.dll instead of mymod.so. Also note that all the filenames have to be prefixed with the directory they're in. That's because make considers all files relative to the directory it runs in.

Now compile your module and copy it into your bin directory:

$ make mymod/mymod.so
... compiler output ...
$ install mymod/mymod.so ../bin

Note that you have to specify the target name manually; it won't get built or copy by default if you just type make. If you do want your custom module to get built and copied automatically, along with the rest of ASSS, when you type just make, add this line at the top of the Makefile fragment:

ALL_STUFF += mymod/mymod.$(SO)

Also note that you can list more than one .o file on the line. All will be compiled into the same shared library.

The module specifier for this new module will be mymod:mymod, for use in modules.conf or with ?insmod.

Using a custom Makefile

Sometimes you might want to create your own Makefile, if you need to use custom compilation options, or a different source file layout. Here is a very basic one (they can get very long).

# simple makefile
# jan 11 smong

OUTFILE = somefile.so
MODULES = autoturret.o

CC = gcc -std=gnu99 -pipe
CFLAGS = -s -O2 -Wall

all: ${OUTFILE}

${OUTFILE}: ${MODULES}
	${CC} -fPIC -shared -o ${OUTFILE} ${MODULES}

install: ${OUTFILE}
	install ${OUTFILE} ../bin/${OUTFILE}

clean:
	rm -f ${OUTFILE} ${MODULES}

You can change the name of the resulting file with OUTFILE and add more modules on the MODULES line. Note: the indentation must be a tab and not a bunch of spaces.

To use a makefile one would type something like this:

$ make -f some.mk
$ make -f some.mk install

The -f switch tells make to use some.mk instead of the default which is 'Makefile'. Also two commands are used so you can spot any errors during compilation.

By hand

You may need to execute the commands to compile from source, and then move the resulting .so file to the bin directory using install.

Python modules

No compiling is necessary. Move the .py file to the bin directory. There may be 'softcoded' settings within the .py file, so examine any comments near the top of the file for instructions.

Configuring

It is a good idea to examine any documents that came with the module. There may be comments at the top of the source code and if you are unsure you can do a search on the file for 'cfg->Get', which will return all customisable settings this module reads.

$ grep 'cfg->Get' src/module.c
$ grep 'cfg.Get' bin/module.py

I suggest putting module settings in their own .conf file and include this from your arena.conf.

There may also be commands that you must set the permissions for. You can add new commands to the group files found in conf/groupdef.dir. Prefix cmd_ to the command to allow users to send the command publicly and privcmd_ for team and private targets.

Finally you must load the module. Either add an entry to conf/modules.conf or use ?insmod. Some modules are arena specific, in which case you must also add it to your arena.conf Modules:AttahModules setting or use ?attmod.

If you have any questions left chances are they have already been answered at the Module FAQ.