mbpfan/Makefile

74 lines
1.7 KiB
Makefile
Raw Normal View History

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/
TESTS_PATH = tests/
TESTS_BIN = bin/mbpfan-tests
2024-03-28 13:47:46 +00:00
BIN = bin/mbpfan
CONF = mbpfan.conf
DEPEND_MODULE = mbpfan.depend.conf
2012-06-09 14:25:28 +00:00
COPT =
CC ?= cc
OBJFLAG = -o
BINFLAG = -o
INCLUDES =
LIBS = -lm
LIBPATH =
CFLAGS += $(COPT) -g $(INCLUDES) -Wall -Wextra -Wno-unused-function -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500
LDFLAGS += $(LIBPATH) -g
2012-06-09 14:25:28 +00:00
OBJS := $(patsubst %.$(C),%.$(OBJ),$(wildcard $(SOURCE_PATH)*.$(C)))
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)
mkdir -p bin
2012-06-09 14:25:28 +00:00
@echo Compiling $(basename $<)...
$(CC) -c $(CFLAGS) $< $(OBJFLAG)$@
2012-06-09 14:25:28 +00:00
all: $(BIN) $(TESTS_BIN)
$(BIN): $(OBJS)
2012-06-09 14:25:28 +00:00
@echo Linking...
$(CC) $(LDFLAGS) $^ $(LIBS) $(BINFLAG) $(BIN)
2012-06-09 14:25:28 +00:00
$(TESTS_BIN): $(TESTS_OBJS)
@echo Linking...
$(CC) $(LDFLAGS) $^ $(LIBS) $(BINFLAG) $(TESTS_BIN)
2012-06-09 14:25:28 +00:00
clean:
rm -rf $(SOURCE_PATH)*.$(OBJ) $(BIN)
rm -rf $(TESTS_PATH)*.$(OBJ) $(TESTS_BIN)
2012-06-09 14:25:28 +00:00
tests: all
./bin/mbpfan-tests
2012-08-22 13:53:07 +00:00
uninstall:
rm /usr/sbin/mbpfan
rm /etc/mbpfan.conf
install: all
install -d $(DESTDIR)/usr/sbin
install -d $(DESTDIR)/etc
install $(BIN) $(DESTDIR)/usr/sbin
install -m644 $(CONF) $(DESTDIR)/etc
2012-08-19 12:33:35 +00:00
@echo ""
@echo "******************"
@echo "INSTALL COMPLETED"
@echo "******************"
@echo ""
@echo "A configuration file has been copied (might overwrite existing file) to /etc/mbpfan.conf."
@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
#rebuild is not entirely correct