2017-03-19 17:43:55 +00:00
|
|
|
COMPILER=cc
|
2012-06-09 14:25:28 +00:00
|
|
|
|
|
|
|
C = c
|
2017-08-14 11:42:47 +00:00
|
|
|
OBJ = o
|
2012-06-09 14:25:28 +00:00
|
|
|
OUTPUT_PATH = bin/
|
|
|
|
SOURCE_PATH = src/
|
2020-05-19 14:06:27 +00:00
|
|
|
TESTS_PATH = tests/
|
|
|
|
TESTS_BIN = bin/mbpfan-tests
|
2017-03-19 17:43:55 +00:00
|
|
|
BIN = bin/mbpfan
|
2012-07-04 23:22:48 +00:00
|
|
|
CONF = mbpfan.conf
|
2022-08-12 01:59:30 +00:00
|
|
|
DEPEND_MODULE = mbpfan.depend.conf
|
2016-07-04 02:12:15 +00:00
|
|
|
DOC = README.md
|
|
|
|
MAN = mbpfan.8.gz
|
2012-06-09 14:25:28 +00:00
|
|
|
|
2017-03-19 17:43:55 +00:00
|
|
|
COPT =
|
2018-08-20 22:19:04 +00:00
|
|
|
CC ?= cc
|
2017-03-19 17:43:55 +00:00
|
|
|
OBJFLAG = -o
|
|
|
|
BINFLAG = -o
|
|
|
|
INCLUDES =
|
|
|
|
LIBS = -lm
|
|
|
|
LIBPATH =
|
2019-10-28 00:03:31 +00:00
|
|
|
CFLAGS += $(COPT) -g $(INCLUDES) -Wall -Wextra -Wno-unused-function -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500
|
2019-10-31 03:22:54 +00:00
|
|
|
LDFLAGS += $(LIBPATH) -g
|
2012-06-09 14:25:28 +00:00
|
|
|
|
|
|
|
OBJS := $(patsubst %.$(C),%.$(OBJ),$(wildcard $(SOURCE_PATH)*.$(C)))
|
2020-05-19 14:06:27 +00:00
|
|
|
TESTS_OBJS := $(patsubst %.$(C),%.$(OBJ),$(wildcard $(TESTS_PATH)*.$(C)))
|
|
|
|
TESTS_OBJS += $(filter-out %main.$(OBJ),$(OBJS))
|
|
|
|
|
|
|
|
.PHONY: all clean tests uninstall install rebuild
|
2012-06-09 14:25:28 +00:00
|
|
|
|
|
|
|
%.$(OBJ):%.$(C)
|
2012-07-03 11:30:43 +00:00
|
|
|
mkdir -p bin
|
2012-06-09 14:25:28 +00:00
|
|
|
@echo Compiling $(basename $<)...
|
2017-03-19 17:43:55 +00:00
|
|
|
$(CC) -c $(CFLAGS) $< $(OBJFLAG)$@
|
2012-06-09 14:25:28 +00:00
|
|
|
|
2020-05-19 14:06:27 +00:00
|
|
|
all: $(BIN) $(TESTS_BIN)
|
2017-04-02 20:43:59 +00:00
|
|
|
|
|
|
|
$(BIN): $(OBJS)
|
2012-06-09 14:25:28 +00:00
|
|
|
@echo Linking...
|
2017-03-19 17:43:55 +00:00
|
|
|
$(CC) $(LDFLAGS) $^ $(LIBS) $(BINFLAG) $(BIN)
|
2012-06-09 14:25:28 +00:00
|
|
|
|
2020-05-19 14:06:27 +00:00
|
|
|
$(TESTS_BIN): $(TESTS_OBJS)
|
|
|
|
@echo Linking...
|
|
|
|
$(CC) $(LDFLAGS) $^ $(LIBS) $(BINFLAG) $(TESTS_BIN)
|
|
|
|
|
2012-06-09 14:25:28 +00:00
|
|
|
clean:
|
2017-03-19 17:43:55 +00:00
|
|
|
rm -rf $(SOURCE_PATH)*.$(OBJ) $(BIN)
|
2020-05-19 14:06:27 +00:00
|
|
|
rm -rf $(TESTS_PATH)*.$(OBJ) $(TESTS_BIN)
|
2012-06-09 14:25:28 +00:00
|
|
|
|
2020-05-19 14:06:27 +00:00
|
|
|
tests: all
|
|
|
|
./bin/mbpfan-tests
|
2012-08-22 13:05:52 +00:00
|
|
|
|
2012-08-22 13:53:07 +00:00
|
|
|
uninstall:
|
|
|
|
rm /usr/sbin/mbpfan
|
|
|
|
rm /etc/mbpfan.conf
|
2022-08-12 01:59:30 +00:00
|
|
|
rm /lib/modules-load.d/mbpfan.depend.conf
|
2016-07-04 02:12:15 +00:00
|
|
|
rm /lib/systemd/system/mbpfan.service
|
|
|
|
rm /usr/share/man/man8/mbpfan.8.gz
|
|
|
|
rm -rf /usr/share/doc/mbpfan
|
2012-08-22 13:53:07 +00:00
|
|
|
|
2020-05-19 14:06:27 +00:00
|
|
|
install: all
|
2016-07-04 02:12:15 +00:00
|
|
|
install -d $(DESTDIR)/usr/sbin
|
|
|
|
install -d $(DESTDIR)/etc
|
|
|
|
install -d $(DESTDIR)/lib/systemd/system
|
|
|
|
install -d $(DESTDIR)/usr/share/doc/mbpfan
|
2022-11-19 19:22:39 +00:00
|
|
|
install -d $(DESTDIR)/lib/modules-load.d
|
2017-03-19 17:43:55 +00:00
|
|
|
install $(BIN) $(DESTDIR)/usr/sbin
|
2016-07-04 02:12:15 +00:00
|
|
|
install -m644 $(CONF) $(DESTDIR)/etc
|
2022-08-12 01:59:30 +00:00
|
|
|
install -m644 $(DEPEND_MODULE) $(DESTDIR)/lib/modules-load.d
|
2016-07-04 02:12:15 +00:00
|
|
|
install -m644 $(DOC) $(DESTDIR)/usr/share/doc/mbpfan
|
|
|
|
install -d $(DESTDIR)/usr/share/man/man8
|
|
|
|
install -m644 $(MAN) $(DESTDIR)/usr/share/man/man8
|
2012-08-19 12:33:35 +00:00
|
|
|
@echo ""
|
2012-08-22 13:05:52 +00:00
|
|
|
@echo "******************"
|
|
|
|
@echo "INSTALL COMPLETED"
|
|
|
|
@echo "******************"
|
|
|
|
@echo ""
|
2016-08-31 07:26:22 +00:00
|
|
|
@echo "A configuration file has been copied (might overwrite existing file) to /etc/mbpfan.conf."
|
2012-08-22 13:05:52 +00:00
|
|
|
@echo "See README.md file to have mbpfan automatically started at system boot."
|
|
|
|
@echo ""
|
|
|
|
@echo "Please run the tests now with the command"
|
|
|
|
@echo " sudo make tests"
|
2012-08-19 12:33:35 +00:00
|
|
|
@echo ""
|
2012-06-09 14:25:28 +00:00
|
|
|
rebuild: clean all
|
2014-07-07 06:59:06 +00:00
|
|
|
#rebuild is not entirely correct
|