Add Makefile

This commit is contained in:
Steven Tracey 2024-11-19 21:52:04 -05:00
parent 2aca002000
commit 0eff928c47
2 changed files with 91 additions and 1 deletions

3
.gitignore vendored
View File

@ -113,4 +113,5 @@ compile_commands.json
CTestTestfile.cmake
_deps
c/build
c/build
!c/Makefile

89
c/Makefile Normal file
View File

@ -0,0 +1,89 @@
DIR_Config = ./libs/Config
DIR_EPD = ./libs/e-Paper
DIR_FONTS = ./libs/Fonts
DIR_GUI = ./libs/GUI
DIR_BIN = ./bin
DIR_SRC = ./src
OBJ_C_EPD = ${DIR_EPD}/EPD_2in13_V4.c
OBJ_C_Program = ${DIR_SRC}/p2fa.c
OBJ_C = $(wildcard ${OBJ_C_EPD} ${DIR_GUI}/*.c ${OBJ_C_Program} ${DIR_SRC}/main.c ${DIR_SRC}/ImageData2.c ${DIR_SRC}/ImageData.c ${DIR_FONTS}/*.c )
OBJ_O = $(patsubst %.c,${DIR_BIN}/%.o,$(notdir ${OBJ_C}))
RPI_DEV_C = $(wildcard $(DIR_BIN)/dev_hardware_SPI.o $(DIR_BIN)/RPI_gpiod.o $(DIR_BIN)/DEV_Config.o )
JETSON_DEV_C = $(wildcard $(DIR_BIN)/sysfs_software_spi.o $(DIR_BIN)/sysfs_gpio.o $(DIR_BIN)/DEV_Config.o )
DEBUG = -D DEBUG
USELIB_RPI = USE_LGPIO_LIB
LIB_RPI=-Wl,--gc-sections
ifeq ($(USELIB_RPI), USE_BCM2835_LIB)
LIB_RPI += -lbcm2835 -lm
else ifeq ($(USELIB_RPI), USE_WIRINGPI_LIB)
LIB_RPI += -lwiringPi -lm
else ifeq ($(USELIB_RPI), USE_LGPIO_LIB)
LIB_RPI += -llgpio -lm
else ifeq ($(USELIB_RPI), USE_DEV_LIB)
LIB_RPI += -lgpiod -lm
endif
DEBUG_RPI = -D $(USELIB_RPI) -D RPI
USELIB_JETSONI = USE_DEV_LIB
ifeq ($(USELIB_JETSONI), USE_DEV_LIB)
LIB_JETSONI = -lm
else ifeq ($(USELIB_JETSONI), USE_HARDWARE_LIB)
LIB_JETSONI = -lm
endif
DEBUG_JETSONI = -D $(USELIB_JETSONI) -D JETSON
.PHONY : RPI JETSON clean
RPI:RPI_DEV RPI_epd
JETSON: JETSON_DEV JETSON_epd
TARGET = epd
CC = gcc
MSG = -g -O -ffunction-sections -fdata-sections -Wall
CFLAGS += $(MSG) -D $(EPD)
RPI_epd:${OBJ_O}
echo $(@)
$(CC) $(CFLAGS) -D RPI $(OBJ_O) $(RPI_DEV_C) -o $(TARGET) $(LIB_RPI) $(DEBUG)
JETSON_epd:${OBJ_O}
echo $(@)
$(CC) $(CFLAGS) $(OBJ_O) $(JETSON_DEV_C) -o $(TARGET) $(LIB_JETSONI) $(DEBUG)
$(shell mkdir -p $(DIR_BIN))
${DIR_BIN}/%.o:$(DIR_SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) -I $(DIR_GUI) -I $(DIR_EPD) $(DEBUG)
${DIR_BIN}/%.o:$(DIR_EPD)/%.c
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) $(DEBUG)
${DIR_BIN}/%.o:$(DIR_FONTS)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(DEBUG)
${DIR_BIN}/%.o:$(DIR_GUI)/%.c
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) $(DEBUG)
RPI_DEV:
ifeq ($(USELIB_RPI), USE_DEV_LIB)
$(CC) $(CFLAGS) $(DEBUG_RPI) -c $(DIR_Config)/dev_hardware_SPI.c -o $(DIR_BIN)/dev_hardware_SPI.o $(LIB_RPI) $(DEBUG)
$(CC) $(CFLAGS) $(DEBUG_RPI) -c $(DIR_Config)/DEV_Config.c -o $(DIR_BIN)/DEV_Config.o $(LIB_RPI) $(DEBUG)
$(CC) $(CFLAGS) $(DEBUG_RPI) -c $(DIR_Config)/RPI_gpiod.c -o $(DIR_BIN)/RPI_gpiod.o $(LIB_RPI) $(DEBUG)
else
$(CC) $(CFLAGS) $(DEBUG_RPI) -c $(DIR_Config)/dev_hardware_SPI.c -o $(DIR_BIN)/dev_hardware_SPI.o $(LIB_RPI) $(DEBUG)
$(CC) $(CFLAGS) $(DEBUG_RPI) -c $(DIR_Config)/DEV_Config.c -o $(DIR_BIN)/DEV_Config.o $(LIB_RPI) $(DEBUG)
endif
JETSON_DEV:
$(CC) $(CFLAGS) $(DEBUG_JETSONI) -c $(DIR_Config)/sysfs_software_spi.c -o $(DIR_BIN)/sysfs_software_spi.o $(LIB_JETSONI) $(DEBUG)
$(CC) $(CFLAGS) $(DEBUG_JETSONI) -c $(DIR_Config)/sysfs_gpio.c -o $(DIR_BIN)/sysfs_gpio.o $(LIB_JETSONI) $(DEBUG)
$(CC) $(CFLAGS) $(DEBUG_JETSONI) -c $(DIR_Config)/DEV_Config.c -o $(DIR_BIN)/DEV_Config.o $(LIB_JETSONI) $(DEBUG)
clean :
rm -rf $(DIR_BIN)/*.*
rm -rf $(TARGET)