# 
# Solaris Loadable Kernel Modules for Solaris 2.7 (sparc/x86)
# (c) 1999 by Plasmoid/THC <plasmoid@pimmel.com>
# [THC] The Hacker's Choice - http://www.infowar.co.uk/thc
#

# Customize the CC and LD setting if your c compiler is not in your path.
# If you are not using Gnu CC be sure to set the right CFLAGS and COPTS.
CC=gcc
LD=ld
CFLAGS=-O2
COPTS=-g -D_KERNEL -DSVR4 -DSOL2 -DDEBUG

# Script-Kiddies should uncomment the line below in order to hide the sitf
# and anm module. If DEBUG is not defined the modules won't write into syslogd
# and will be invisible to "modinfo". Don't do any illegal things!
# COPTS=-D_KERNEL -DSVR4 -DSOL2 

#(!) Developers: $PACKAGE is the name of your package, usefull with the target 
#    "make package". Currently: slkm-1.0 (Solaris Loadable Kernel Modules v1.0)
PACKAGE=slkm-1.0

# Check if the libC archive is inside your /lib directory otherwise change
# LIBCARCHIVE below. 
#
#(!) Developers: If you have the Solaris 2.7 source code rip functions like
#    memmove, strstr... from the libC source and include those directly into
#    your module instead of extracing objects from the libC archive.
LIBCARCHIVE=/lib/libc.a
LIBCOBJECTS=memmove.o memcpy.o strstr.o

MODULES=flkm anm sitf0.1 sitf0.2

# (!) Developers: You won't believe it, but it's quite a good idea to sync the
#     file system just in case your module won't work and the system will
#     crash. 
all:		$(MODULES)
		sync

# (!) Developers: Use this target to package the sources in a nice handy
#     tar-ball, be sure to set the $PACKAGE variable and rename the directory
#     including the source modules to $PACKAGE. 
package:	clean
		rm -rf ../$(PACKAGE).tar.gz
		mkdir $(PACKAGE)
		cp *.c Makefile $(PACKAGE)
		tar -cvf $(PACKAGE).tar $(PACKAGE)
		gzip $(PACKAGE).tar
		mv $(PACKAGE).tar.gz ..
		rm -rf $(PACKAGE)  

flkm:		flkm.o
		$(LD) -o $@ -r flkm.o
# (!) Developers: If you are going to develop your own modules, make backups
#     on a different system using nfs or something similar.
#		cp flkm.c /net/zebster/tmp/flkm.bak

sitf0.1:	sitf0.1.o
		$(LD) -o $@ -r sitf0.1.o $(LIBCOBJECTS)
#		cp sitf0.1.c /net/zebster/tmp/sitf0.1.bak

sitf0.2:	sitf0.2.o
		$(LD) -o $@ -r sitf0.2.o $(LIBCOBJECTS)
#		cp sitf0.2.c /net/zebster/tmp/sitf0.2.bak


anm:		anm.o
		$(LD) -o $@ -r anm.o $(LIBCOBJECTS)
#		cp anm.c /net/zebster/tmp/anm.bak


sitf0.1.o:	sitf0.1.c	
		$(CC) $(COPTS) $(CFLAGS) -c sitf0.1.c
		ar -x $(LIBCARCHIVE) $(LIBCOBJECTS)

sitf0.2.o:	sitf0.2.c	
		$(CC) $(COPTS) $(CFLAGS) -c sitf0.2.c
		ar -x $(LIBCARCHIVE) $(LIBCOBJECTS)

flkm.o:		flkm.c
		$(CC) $(COPTS) $(CFLAGS) -c flkm.c

anm.o:		anm.c
		$(CC) $(COPTS) $(CFLAGS) -c anm.c
		ar -x $(LIBCARCHIVE) $(LIBCOBJECTS)

clean:
		rm -rf $(MODULES)
# It is not a bad idea to indent your source, as far as I know there haven
# been guys busted because the coppers analyzed their coding style, especially
# spaces, brackets and tabs. But there are only a few Solaris systems, I saw,
# having an installed indent beside mine and Wilkins'. 		
		indent -kr *.c
		rm -rf *.o *~ core
