#
# Makefile for xmbmon related things
#  (for FreeBSD)
#

srcdir = @srcdir@
VPATH  = @srcdir@

# for Linux
#DEFS=-DHAVE_CONFIG_H -Wall -DLINUX
# for using SMBus ioctl
#DEFS=-DHAVE_CONFIG_H -Wall -DSMBUS_IOCTL
# for using temperature limit (see getMBinfo.c)
#DEFS=-DHAVE_CONFIG_H -Wall -DTEMP_LIMIT

# for using logging facility
#DEFS=-DHAVE_CONFIG_H -Wall -DLOGGING

# for making small_mbmon
#DEFS=-DHAVE_CONFIG_H -Wall -DSMALL_MBMON

DEFS=-DSMBUS_IOCTL -DHAVE_CONFIG_H -Wall @HOSTDEF@

INCLUDES=-I$(srcdir)
LIBS=@ADDLIBS@ @LIBS@
LIBSX=$(LIBS) @X_LIBS@ -lXt @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@

#CC=/compat/linux/usr/bin/gcc
CC=@CC@
CFLAGS+=$(INCLUDES) $(DEFS)
CFLAGSX=$(CFLAGS) @X_CFLAGS@
LDFLAGS=

LINT=lint
# LINT=$(CC) -c -Wall -Wshadow -Wpointer-arith
# also maybe -Wcast-qual -Wwrite-strings
RM=rm -f
INSTALL=install

INST_DIR=/usr/local/bin
INST_MANDIR=/usr/local/man/man1
INST_XDIR=/usr/X11R6/bin
INST_MANXDIR=/usr/X11R6/man/man1
INST_XRDIR=/usr/X11R6/lib/X11/app-defaults
 
.c.o:
	$(CC) -c $(CFLAGS) $*.c

MANPAGE = mbmon.1 xmbmon.1x
PROGRAM = mbmon xmbmon

TESTPROG = testpci testsmb testhwm testfan

MB_OBJ  = getMB-via.o getMB-smb.o getMB-isa.o
SMB_OBJ = smbuses.o smbus_piix4.o smbus_amd.o smbus_ali.o smbus_amd8.o
HWM_OBJ = sens_winbond.o sens_via686.o sens_it87.o sens_gl52.o sens_lm85.o sens_lm80.o sens_lm90.o sens_lm75.o sens_wl784.o smb_extemp.o
OBJS = getMBinfo.o tyan_tiger.o pci_pm.o sensors.o $(MB_OBJ) $(SMB_OBJ) $(HWM_OBJ)

all: $(PROGRAM)

mbmon: mbmon.c mbmon.h methods.h pci_pm.h smbuses.h sensors.h $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ mbmon.c $(OBJS) $(LIBS)

mbmon_small: mbmon_small.c mbmon.h methods.h pci_pm.h smbuses.h sensors.h $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ mbmon_small.c $(OBJS) $(LIBS)

xmbmon: xmbmon.c mbmon.h methods.h pci_pm.h smbuses.h sensors.h $(OBJS)
	$(CC) $(CFLAGSX) $(LDFLAGS) -o $@ xmbmon.c $(OBJS) $(LIBSX)

testprog: $(TESTPROG)

testpci: testpci.c pci_smb.c pci_pm.o pci_pm.h
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ testpci.c pci_pm.o $(SMB_OBJ) $(LIBS)

testsmb: testsmb.c pci_smb.c pci_pm.o pci_pm.h smbus_piix4.c smbus_amd.c smbus_ali.c smbus_amd8.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ testsmb.c pci_pm.o $(SMB_OBJ) $(LIBS)

testhwm: testhwm.c pci_smb.c pci_pm.o pci_pm.h smbus_piix4.c smbus_amd.c smbus_ali.c smbus_amd8.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ testhwm.c pci_pm.o $(SMB_OBJ) $(LIBS)

testfan: testhwm.c pci_smb.c pci_pm.o pci_pm.h smbus_piix4.c smbus_amd.c smbus_ali.c smbus_amd8.c
	$(CC) -DFAN_DIV_CHK $(CFLAGS) $(LDFLAGS) -o $@ testhwm.c pci_pm.o $(SMB_OBJ) $(LIBS)


getMB-isa.o: getMB-isa.c methods.h io_static.c io_cpu.h

getMB-smb.o: getMB-smb.c getMB-smb_ioctl.c methods.h smbuses.h io_static.c io_cpu.h

getMB-via.o: getMB-via.c methods.h io_static.c io_cpu.h

getMBinfo.o: getMBinfo.c methods.h pci_pm.h smbuses.h sensors.h sensors.c

pci_pm.o: pci_pm.c pci_pm.h io_static.c io_cpu.h

smbuses.o: smbuses.c smbuses.h

smbus_piix4.o: smbus_piix4.c smbuses.h io_cpu.h

smbus_amd.o: smbus_amd.c smbuses.h io_cpu.h

smbus_ali.o: smbus_ali.c smbuses.h io_cpu.h

smbus_amd8.o: smbus_amd8.c smbuses.h io_cpu.h

sensors.o: sensors.c sensors.h

sens_it87.o: sens_it87.c sensors.h sensors.c

sens_gl52.o: sens_gl52.c sensors.h sensors.c

sens_lm85.o: sens_lm85.c sensors.h sensors.c

sens_lm80.o: sens_lm80.c sensors.h sensors.c

sens_via686.o: sens_via686.c sensors.h sensors.c

sens_winbond.o: sens_winbond.c sens_winbond.h sensors.h sensors.c

sens_lm90.o: sens_lm90.c sensors.h sensors.c

sens_lm75.o: sens_lm75.c sensors.h sensors.c

sens_wl784.o: sens_wl784.c sens_wl784.h sensors.h sensors.c

tyan_tiger.o: tyan_tiger.c io_static.c io_cpu.h

smb_extemp.o: smb_extemp.c smb_extemp.h

clean:
	$(RM) *.o *.bak a.out core *.core *~ $(PROGRAM) $(TESTPROG) mbmon_small

distclean: clean
	$(RM) Makefile config.cache config.log config.h config.status

install: $(PROGRAM)
	$(INSTALL) -o root -g wheel -m 4555 -c -p mbmon $(INST_DIR)
	$(INSTALL) -o root -g wheel -m 4555 -c -p xmbmon $(INST_XDIR)

install-man: $(MANPAGE)
	$(INSTALL) -o root -g wheel -m 444 -c -p mbmon.1 $(INST_MANDIR)
	$(INSTALL) -o root -g wheel -m 444 -c -p xmbmon.1x $(INST_MANXDIR)

lint:
	$(LINT) $(INCLUDES) $(DEFS) $(FONTDEFINES) $(SRCS) -lm


syntax highlighted by Code2HTML, v. 0.9.1