-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
36 lines (27 loc) · 762 Bytes
/
Makefile
File metadata and controls
36 lines (27 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
DIR_SRC := ./src
DIR_INC := ./include
DIR_OBJ := ./obj
DIR_LIB := ./lib
TARGET := example.out
LIB_TARGET := serial
CC := aarch64-linux-gnu-gcc
CFLAGS := -I ./include
BIN_TARGET := $(DIR_OBJ)/$(TARGET)
SRC := $(wildcard $(DIR_SRC)/*.c)
OBJ := $(patsubst %.c, $(DIR_OBJ)/%.o, $(notdir $(SRC)))
$(BIN_TARGET) : $(OBJ)
@echo cc = $(CC)
$(CC) $^ -o $@
$(DIR_OBJ)/%.o : $(DIR_SRC)/%.c
$(CC) -c $< $(CFLAGS) -o $@
.PHONY : lib
lib : $(DIR_LIB)/lib$(LIB_TARGET).so $(DIR_LIB)/lib$(LIB_TARGET).a
$(DIR_LIB)/lib$(LIB_TARGET).so : $(DIR_SRC)/$(LIB_TARGET).c
$(CC) $< $(CFLAGS) -shared -fPIC -o $@
$(DIR_LIB)/lib$(LIB_TARGET).a : $(DIR_OBJ)/$(LIB_TARGET).o
ar crv $@ $<
.PHONY : clean
clean :
-rm $(OBJ) $(BIN_TARGET)
-rm $(DIR_LIB)/*.so
-rm $(DIR_LIB)/*.a