# Usage: dmake -f Makefile [BT=] [ROOT=/tmp] [PREFIX=/local/usr] $TARGET
#
# TARGETs:
# - config: create required config files wrt. the current platform. It must be
# run once before one of the following targets can properly be made.
# - all: compile and link everything
# - clean: remove alle temporary files required for linking
# - clobber: clean + remove all config files which rarely change
# - install: install all the stuff below $(ROOT)/$(PREFIX)
#
# 'BT=' compiles 32bit, if ommitted it defaults to '64'
# ROOT defaults to an empty string
# PREFIX defaults to /usr
default: all
# avoid the chicken and egg problem
CONF:sh = if [ -f config.mk ]; then echo "config.mk" ; else echo "/dev/null" ;fi
include $(CONF)
SUBDIRS = src
CONFIG_H = configure.h
include Makefile.master
.LOCAL .PARALLEL: config tgz
config: $(CONFIG_H)
.PARALLEL all: $(SUBDIRS)
CLOBBERFILES += $(MAN1MFILES) $(CONFIG_H) \
ldpitest.c dlpiTest lpcitest.c lpciTest
tgz:
if [[ -e $${TMPDIR:-/tmp}/k10sensor ]]; then \
$(ECHO) "$${TMPDIR:-/tmp}/k10sensor exists. Remove it first." ; false ; \
fi
svn export . $${TMPDIR:-/tmp}/k10sensor
(cd $${TMPDIR:-/tmp} ; tar cplf - k10sensor | gzip -c9 >k10sensor.tar.gz )
rm -rf $${TMPDIR:-/tmp}/k10sensor
@echo "\nSource archive ready: $${TMPDIR:-/tmp}/k10sensor.tar.gz\n"
$(CONFIG_H) $(MAKECONFIG): Makefile ontools
@$(ECHO) "\n\
#include <pciaccess.h>\nint main(int argc, char **argv) {\n\
pci_system_init();\n}" >lpcitest.c
@$(ECHO) "Checking for libpciaccess - ignore any warnings/errors - ..."
@export CW_NO_SHADOW=1 ; $(CC) lpcitest.c -o lpciTest -lpciaccess || true
@$(ECHO) "Done."
@[ ! -x lpciTest ] && $(ECHO) "libpciaccess not found. LIBPCI_* variables in the generated config.mk need help!" || true
@# aquire all info so that we can write out in one row
@JOBS=$(JOBS:sh) ; \
$(ECHO) "Configuring $$JOBS parallel dmake jobs per default" ; \
PCI_STUFF=$$([ ! -x lpciTest ] && echo "\
#for Solaris 10, we need to know, where libpci is installed\n\
LIBPCI_DIR = /export/scratch/\$$(USER)/build/libpciaccess-0.12.1\n\
LIBPCI_INC = -I\$$(LIBPCI_DIR)/include\n\
LIBPCI_LIB = -L\$$(LIBPCI_DIR)/src\n\
ENVCPPFLAGS1 += \$$(LIBPCI_INC) \$$(LIBPCI_LIB)\n\n" || true) ; \
# write out the results \
$(PRINTF) "DMAKE_MAX_JOBS = $$JOBS\n\
C99MODE = %s(C99_ENABLE)\n\
DLPI_LIBS = $$DLPI_LIBS\n\
STAT_LIBS = -lkstat -lkvm -ldevinfo \$$(DLPI_LIBS)\n\
$$PCI_STUFF\n" \
'$$' \
>> $(MAKECONFIG) && \
$(ECHO) "$$DLPI_DEFS" >$@