b15f/control/src/Makefile

82 lines
2.3 KiB
Makefile
Raw Normal View History

2019-03-26 09:57:01 +01:00
# Name: Makefile
2019-05-16 10:07:27 +02:00
# Project: B15F (Board 15 Famulus Edition)
2019-03-26 09:57:01 +01:00
# Author: Tristan Krause
# Creation Date: 2019-03-22
2019-04-03 15:20:49 +02:00
# Environment
2019-05-16 09:59:34 +02:00
PATH_COMPILER = g++
# install paths
PATH_BIN = /usr/bin/
PATH_LIB = /usr/lib/
PATH_INCLUDE = /usr/include/b15f/
# tmp paths
PATH_TMP_BIN = ../bin/
PATH_TMP_LIB = ../lib/
# outputs
2019-05-16 10:17:48 +02:00
OUT_TMP_DRV = $(PATH_TMP_LIB)/libb15fdrv.so
OUT_TMP_CLI = $(PATH_TMP_BIN)/cli.elf
OUT_TMP_PLOTTY = $(PATH_TMP_BIN)/plotty
OUT_DRV = $(PATH_LIB)/libb15fdrv.so
OUT_CLI = $(PATH_BIN)/b15fcli
OUT_PLOTTY = $(PATH_BIN)/plotty
2019-05-16 09:59:34 +02:00
# compiling & linking parameters
2019-05-15 11:06:52 +02:00
CFLAGS = -std=c++17 -O3 -Wall -Wextra -fPIC
2019-05-15 15:39:16 +02:00
LDFLAGS_DRV = -lcurses -lpthread
2019-05-16 09:59:34 +02:00
LDFLAGS_CLI = $(LDFLAGS_DRV) -lb15fdrv
# objects
2019-04-04 13:19:11 +02:00
OBJECTS_DRV = drv/usart.o drv/b15f.o drv/plottyfile.o drv/dot.o
2019-05-16 09:59:34 +02:00
OBJECTS_CLI = cli.o ui/view.o ui/view_selection.o ui/view_promt.o ui/view_info.o ui/view_monitor.o ui/ui.o
2019-03-26 09:57:01 +01:00
2019-05-16 09:59:34 +02:00
# *** TARGETS ***
2019-03-26 09:57:01 +01:00
2019-05-15 10:51:39 +02:00
all: drv cli
2019-05-16 09:59:34 +02:00
drv: $(OBJECTS_DRV) $(OUT_TMP_DRV)
2019-05-15 13:36:40 +02:00
2019-04-03 15:20:49 +02:00
2019-05-16 09:59:34 +02:00
cli: drv $(OBJECTS_CLI)
2019-05-15 11:06:52 +02:00
@echo "Linking cli..."
2019-05-16 09:59:34 +02:00
@mkdir -p ../bin
$(PATH_COMPILER) $(CFLAGS) $(OBJECTS_CLI) -L $(PATH_TMP_LIB) -o $(OUT_TMP_CLI) $(LDFLAGS_CLI)
@bash -c 'if [ ! -f "$(OUT_DRV)" ]; then echo -e "\n*** Warning ***: driver not installed\nType \"sudo make install\" to install or update b15fdrv."; fi'
2019-03-26 09:57:01 +01:00
2019-05-15 15:39:16 +02:00
install: drv
2019-05-16 09:59:34 +02:00
@echo "Installing driver..."
@mkdir -p $(PATH_INCLUDE)
2019-05-16 10:17:48 +02:00
cp $(OUT_TMP_DRV) $(OUT_DRV)
cp $(OUT_TMP_CLI) $(OUT_CLI)
cp $(OUT_TMP_PLOTTY) $(OUT_PLOTTY)
2019-05-16 09:59:34 +02:00
cp drv/*.h $(PATH_INCLUDE)
2019-05-15 15:39:16 +02:00
2019-05-16 10:17:48 +02:00
uninstall:
@echo "Uninstalling driver..."
rm -rf $(PATH_INCLUDE) $(OUT_DRV) $(OUT_CLI) $(OUT_PLOTTY)
2019-03-26 09:57:01 +01:00
help:
2019-05-15 11:06:52 +02:00
@echo "This Makefile compiles the b15f driver lib and command line interface (CLI):"
2019-05-16 10:02:26 +02:00
@echo "make ......... to compile all (no install)"
2019-05-15 11:06:52 +02:00
@echo "make drv ..... to compile the b15f driver lib"
2019-05-15 15:39:16 +02:00
@echo "make cli ..... to compile the cli"
2019-05-16 10:02:26 +02:00
@echo "make install . to install or update the lib and headers on this machine"
2019-05-16 10:17:48 +02:00
@echo "make uninstall to remove the lib and headers on this machine"
2019-04-03 15:20:49 +02:00
@echo "make clean ... to delete objects and executables"
2019-03-26 09:57:01 +01:00
clean:
@echo "Cleaning..."
2019-05-16 09:59:34 +02:00
rm -f $(OBJECTS_DRV) $(OBJECTS_CLI) $(OUT_TMP_CLI) $(OUT_TMP_DRV)
2019-03-26 09:57:01 +01:00
.cpp.o:
2019-05-16 09:59:34 +02:00
$(PATH_COMPILER) $(CFLAGS) -c $< -o $@
2019-05-15 13:36:40 +02:00
2019-05-16 09:59:34 +02:00
$(OUT_TMP_DRV):
2019-05-15 13:36:40 +02:00
@echo "Linking driver library..."
2019-05-16 09:59:34 +02:00
@mkdir -p ../lib
$(PATH_COMPILER) $(CFLAGS) $(OBJECTS_DRV) -shared -o $(OUT_TMP_DRV) $(LDFLAGS_CLI_DRV)