Advertisement
Mark2020H

Makefile to compile the RPI C Code

Mar 20th, 2024
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. ## The Makefile for the RPI  flash led  file named blink.c at this address https://pastebin.com/YjQNewfY
  2. ## MD Harrington  London Kent 20-03-2024 UK
  3.  
  4.  
  5.  
  6. CC = gcc
  7. CFLAGS = -Wall -Wextra -std=c99
  8. LIBS = -lwiringPi -lpthread -lbcm2835
  9.  
  10. TARGET = blink
  11.  
  12. SRC_DIR = source
  13. INC_DIR = include
  14.  
  15. SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
  16. OBJ_DIR = obj
  17. OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
  18.  
  19. INC_FILES = $(wildcard $(INC_DIR)/*.h)
  20.  
  21. $(TARGET): $(OBJ_FILES)
  22.     $(CC) $(CFLAGS) -o $(TARGET) $(OBJ_FILES) $(LIBS)
  23.  
  24. $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
  25.     $(CC) $(CFLAGS) -c -o $@ $< -I$(INC_DIR)
  26.  
  27. $(OBJ_DIR):
  28.     mkdir -p $(OBJ_DIR)
  29.  
  30.  
  31. .PHONY: clean
  32.  
  33. clean:
  34.     rm -rf $(OBJ_DIR) $(TARGET)
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement