
all: thinkpad.o smapi.o superio.o rtcmosram.o thinkpadpm.o

DIR_MODULES:=/lib/modules
DIR_MODULES_VER:=$(DIR_MODULES)/$(shell uname -r)
KSRC?=$(DIR_MODULES_VER)/build

CFLAGS:=-Wall -Wcast-align -Wstrict-prototypes -O2

ALLCFLAGS:=$(CFLAGS) -I$(KSRC)/include -I. -I../include -DLINUX

export-objs     := thinkpad.o

thinkpad.o: thinkpad.c ../include/thinkpad_common.h ../include/thinkpad_driver.h ../include/thinkpad.h
	$(CC) $(ALLCFLAGS) -o $@ -c thinkpad.c

smapi.o: smapi_core.o smapi_call.o
	ld -r $^ -o $@ 

smapi_core.o: smapi_core.c ../include/thinkpad_common.h ../include/thinkpad_driver.h ../include/smapi.h ../include/smapi_call.h
	$(CC) $(ALLCFLAGS) -o $@ -c smapi_core.c

smapi_call.o: smapi_call.s
	$(CC) $(ALLCFLAGS) -o $@ -c smapi_call.s

superio.o: superio.c ../include/thinkpad_common.h ../include/thinkpad_driver.h ../include/superio.h
	$(CC) $(ALLCFLAGS) -o $@ -c superio.c

rtcmosram.o: rtcmosram.c ../include/thinkpad_common.h ../include/thinkpad_driver.h ../include/rtcmosram.h
	$(CC) $(ALLCFLAGS) -o $@ -c rtcmosram.c

thinkpadpm.o: thinkpadpm.c ../include/thinkpad_common.h ../include/thinkpad_driver.h ../include/thinkpadpm.h
	$(CC) $(ALLCFLAGS) -o $@ -c thinkpadpm.c

clean:
	rm -vf *.o
