
 ###   #     # ######  ####### ######  #######    #    #     # #######
  #    ##   ## #     # #     # #     #    #      # #   ##    #    #
  #    # # # # #     # #     # #     #    #     #   #  # #   #    #
  #    #  #  # ######  #     # ######     #    #     # #  #  #    #
  #    #     # #       #     # #   #      #    ####### #   # #    #
  #    #     # #       #     # #    #     #    #     # #    ##    #
 ###   #     # #       ####### #     #    #    #     # #     #    #
 
 # You should read the INSTALL file before changing stuff here.

 WM = #-DBLACKBOX #-DTWM
 IO = #-DIO_MAJOR=3
 MMX = #-DMMX
 REDHAT = -I/usr/X11R6/include
 ANSI = #-ansi -Dinline=__inline__

 # Uncomment ONE of the following, to compile the appropriate mode
 # Comment out the next DEFINE to disable mode5.
 # For tcsysmon with "mode5" (4 steps for LED bars) (default)
 DEFINES = -DMODE5

 # For tcsysmon with 24 IRQ support with "mode5"
 # DEFINES = -DHIGHIRQ -DMODE5

 # For tcsysmon with 24 IRQ support without "mode5"
 # DEFINES = -DHIGHIRQ

 # For standard tcsysmon with EQ mode:
 # DEFINES = -DEQ

 # Normal, optimizing CFLAGS 
 CFLAGS = -Wall -O3 -fomit-frame-pointer -pipe -D_GNU_SOURCE

 # Profiling
 # CFLAGS = -Wall -pg -O3 -pipe -D_GNU_SOURCE -DPRO

 # Test coverage
 # CFLAGS = -fprofile-arcs -ftest-coverage -Wall -pipe -D_GNU_SOURCE -DPRO

 ########## Nothing to change below #########################################

CFLAGS += $(MMX) $(WM) $(IO) $(REDHAT) $(ANSI)
CC	= gcc
LIBS	= -L/usr/X11/lib -lX11 -lXpm -lXext

SRCS	= sysmon.c
OBJS	= sysmon.o

all:	sysmon monitor.o

sysmon:	$(OBJS) monitor.c
	$(CC) $(CFLAGS) -o sysmon $(OBJS) $(LIBS)

sysmon.o:	sysmon.c master.xpm Makefile /usr/src/linux/include/linux/version.h
	$(CC) $(CFLAGS) $(DEFINES) -c sysmon.c 

monitor.o:	monitor.c /usr/src/linux/include/linux/version.h
	$(CC) -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -DMODULE -include /usr/src/linux/include/linux/modversions.h -c monitor.c

clean:
	rm -f *.o *~ sysmon trace *.bb *.bbg *.gcov *.da *.out

install:
	@echo If you dont have devfs, run the next line as root:
	@echo mknod /dev/sysmon c 10 253
	mkdir -p /lib/modules/$(shell echo `uname -r`)/misc
	install -s -m 0755 sysmon /usr/local/bin/sysmon
	install -m 0644 monitor.o /lib/modules/$(shell echo `uname -r`)/misc/monitor.o
	install -m 0755 tcsysmon /usr/local/bin/tcsysmon

