Modified Makefile to create a shared library
Modified Makefile to create a easy to link shard library for e-Paper display driver for Raspberry Pi (C code). This way, it is more easy to link against this code when creating custom projects which use that e-paper screen. * Reorganized src variables * Created 2 new targets: make lib and make example (and make all) * make clean now does not file if files do not exist * make clean removes bin directory. There is a target which create it automatically
This commit is contained in:
parent
f464eb8a72
commit
daa29e49c6
1 changed files with 34 additions and 12 deletions
|
|
@ -1,14 +1,28 @@
|
||||||
|
# Make sure to run make on the same directory where Makefile is located
|
||||||
|
# Make sure to execute the example "epd" as sudo and in the same directory where Makefile is located
|
||||||
|
|
||||||
DIR_Config = ./lib/Config
|
DIR_Config = ./lib/Config
|
||||||
DIR_EPD = ./lib/e-Paper
|
DIR_EPD = ./lib/e-Paper
|
||||||
DIR_FONTS = ./lib/Fonts
|
DIR_FONTS = ./lib/Fonts
|
||||||
DIR_GUI = ./lib/GUI
|
DIR_GUI = ./lib/GUI
|
||||||
DIR_Examples = ./examples
|
DIR_Examples = ./examples
|
||||||
DIR_BIN = ./bin
|
DIR_BIN = ./bin
|
||||||
|
DIR_LIB = "$(shell pwd)"
|
||||||
|
|
||||||
OBJ_C = $(wildcard ${DIR_EPD}/*.c ${DIR_Config}/*.c ${DIR_GUI}/*.c ${DIR_Examples}/*.c ${DIR_FONTS}/*.c)
|
SRC_EPD = $(wildcard ${DIR_EPD}/*.c)
|
||||||
OBJ_O = $(patsubst %.c,${DIR_BIN}/%.o,$(notdir ${OBJ_C}))
|
SRC_Config = $(wildcard ${DIR_Config}/*.c)
|
||||||
|
SRC_GUI = $(wildcard ${DIR_GUI}/*.c)
|
||||||
|
SRC_Examples = $(wildcard ${DIR_Examples}/*.c)
|
||||||
|
SRC_FONTS = $(wildcard ${DIR_FONTS}/*.c)
|
||||||
|
|
||||||
TARGET = epd
|
SRC_LIB = $(SRC_EPD) $(SRC_Config) $(SRC_GUI) $(SRC_FONTS)
|
||||||
|
OBJ_LIB = $(patsubst %.c,${DIR_BIN}/%.o,$(notdir ${SRC_LIB}))
|
||||||
|
|
||||||
|
SRC_EXAMPLE = $(SRC_Examples)
|
||||||
|
OBJ_EXAMPLE = $(patsubst %.c,${DIR_BIN}/%.o,$(notdir ${SRC_EXAMPLE}))
|
||||||
|
|
||||||
|
TARGET_LIB = libepd.so
|
||||||
|
TARGET_EXAMPLE = epd
|
||||||
|
|
||||||
USELIB = USE_BCM2835_LIB
|
USELIB = USE_BCM2835_LIB
|
||||||
# USELIB = USE_WIRINGPI_LIB
|
# USELIB = USE_WIRINGPI_LIB
|
||||||
|
|
@ -20,11 +34,19 @@ else ifeq ($(USELIB), USE_WIRINGPI_LIB)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
MSG = -g -O0 -Wall
|
MSG = -g -O0 -Wall -fpic
|
||||||
CFLAGS += $(MSG) $(DEBUG)
|
CFLAGS += $(MSG) $(DEBUG)
|
||||||
|
|
||||||
${TARGET}:${OBJ_O}
|
all: make_bin_dir lib example
|
||||||
$(CC) $(CFLAGS) $(OBJ_O) -o $@ $(LIB)
|
|
||||||
|
make_bin_dir:
|
||||||
|
mkdir -p $(DIR_BIN)
|
||||||
|
|
||||||
|
lib: make_bin_dir $(OBJ_LIB)
|
||||||
|
$(CC) -shared -o $(TARGET_LIB) $(OBJ_LIB) $(LIB)
|
||||||
|
|
||||||
|
example: make_bin_dir lib $(OBJ_EXAMPLE)
|
||||||
|
$(CC) $(CFLAGS) $(OBJ_EXAMPLE) -o $(TARGET_EXAMPLE) $(LIB) -L$(DIR_LIB) -lepd -Wl,-rpath=$(DIR_LIB)
|
||||||
|
|
||||||
${DIR_BIN}/%.o:$(DIR_Examples)/%.c
|
${DIR_BIN}/%.o:$(DIR_Examples)/%.c
|
||||||
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) -I $(DIR_GUI) -I $(DIR_EPD)
|
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) -I $(DIR_GUI) -I $(DIR_EPD)
|
||||||
|
|
@ -42,6 +64,6 @@ ${DIR_BIN}/%.o:$(DIR_GUI)/%.c
|
||||||
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config)
|
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config)
|
||||||
|
|
||||||
|
|
||||||
clean :
|
clean:
|
||||||
rm $(DIR_BIN)/*.*
|
rm -rf $(DIR_BIN)
|
||||||
rm $(TARGET)
|
rm -f $(TARGET_EXAMPLE) $(TARGET_LIB)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue