# Specify your kernel modules' source
KMODSRC := lksteh_wqcounter.c lksteh_vminfo.c \
	lksteh_procstat.c lksteh_sysinfo.c
KMODOBJ := $(KMODSRC:%.c=%.o)
KMOD_KO := $(KMODOBJ:%.o=%.ko)

DEBUGOPT := -DDEBUG -g

ANLZSRC := event.c syscall.c procstat.c biotime.c blkqueue.c busywait.c \
	   buffer.c netroute.c netsend.c palloc.c runqueue.c schedrun.c \
	   schedule.c softirq.c spinlock.c timer.c vmscan.c waitqueue.c \
	   waittime.c proclive.c bioqueue.c elvtime.c elvqueue.c \
	   iosector.c biomake.c bdevtime.c exception.c sysinfo.c \
	   vminfo.c

LKSTLASRC := lkstla.c slot.c logfile.c ksymbols.c eventdesc.c multientry.c \
	     analyzer.c fmt_log.c fmt_dist.c fmt_stat.c $(ANLZSRC)
LKSTLAOBJ := $(LKSTLASRC:%.c=%.o)

# Specify your programs' source
PROGSRC := lkstlogdiv.c $(LKSTLASRC)
PROGOBJ := $(PROGSRC:%.c=%.o)
PROGBIN := lkstla lkstlogdiv

ifneq ($(KERNELRELEASE),)

obj-m	:= $(KMODOBJ)

else
# Specify the directory where the Makefile.base exists.
TOPDIR := ../
SUB_DIRS :=

# Specify an additional command run after clean, and distclean.(optional)
ADDCMD-clean :=
ADDCMD-distclean :=
#ADDCMD-build := cp $(KMOD_KO) ../modules/

include $(TOPDIR)/Makefile.base

CFLAGS += -I../include -g

# Describe additional targets here.(optional)
../include/syscalls.h:
	../scripts/mksyscalls.sh > ../include/syscalls.h

syscall.o: ../include/syscalls.h

lkstla.o: analyzers.list

lkstla: $(LKSTLAOBJ)
	gcc -lm -o $@ $(LKSTLAOBJ)
#	cp $@ ../bin/$@

lkstlogdiv: lkstlogdiv.o logfile.o
	gcc -o $@ lkstlogdiv.o logfile.o
#	cp $@ ../bin/$@

endif
