default: temp

MODINC := $(shell ./find-modinc)
BINDIR := $(shell ./find-bindir)
ifeq "$(MODINC)" ""
$(error Required files for building components not present.  Install emc2-dev)
endif
include $(MODINC)

ifeq ($(RUN_IN_PLACE),no)
EXTRA_CFLAGS += -I$(EMC2_HOME)/include/linuxcnc
#EXTRA_CFLAGS += -I/usr/include/emc2
LIBDIR := $(shell ./find-libdir)
ifeq "$(LIBDIR)" ""
$(error LIBDIR not found)
endif
endif


CFLAGS := $(EXTRA_CFLAGS) -URTAPI -U__MODULE__ -DULAPI -Os
CFLAGS += $(shell pkg-config --cflags glib-2.0)
LFLAGS := -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) -llinuxcnchal  -lusb
LFLAGS += $(shell pkg-config --libs glib-2.0)

install: temp 
	cp temp  $(BINDIR)

temp: temperature.o pcsensor.o 
	$(CC) -o $@ $^ $(LFLAGS)

%.o: %.c
	$(CC) $(CFLAGS) -o $@ -c $<

clean:
	-rm -f temp
	-rm -rf *.o


rules-install: # must be superuser to do this
	cp 98-tempsensor.rules /etc/udev/rules.d
