-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
40 lines (33 loc) · 887 Bytes
/
Makefile
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
37
38
39
40
CC = gcc
CFLAGS = -fPIC -Wall -Werror -fopenmp
LDFLAGS = -shared -lm
TARGET = libflash.so
SRC = flash.c
OBJ = $(SRC:.c=.o)
INCLUDE = flash.h
INSTALL_DIR_LIB = /usr/lib
INSTALL_DIR_INCLUDE = /usr/include
all: $(TARGET)
$(TARGET): $(OBJ) $(INCLUDE)
$(CC) $(LDFLAGS) -o $@ $^
%.o: %.c $(INCLUDE)
$(CC) $(CFLAGS) -c $< -o $@
install: $(TARGET)
@if [ $(shell id -u) -ne 0 ]; then \
echo "Error: You need to be root to install the library."; \
exit 1; \
fi
sudo cp $(TARGET) $(INSTALL_DIR_LIB)
sudo cp $(INCLUDE) $(INSTALL_DIR_INCLUDE)
sudo ldconfig
uninstall:
@if [ $(shell id -u) -ne 0 ]; then \
echo "Error: You need to be root to uninstall the library."; \
exit 1; \
fi
sudo rm $(INSTALL_DIR_LIB)/$(TARGET)
sudo rm $(INSTALL_DIR_INCLUDE)/$(INCLUDE)
sudo ldconfig
clean:
rm -f $(TARGET) $(OBJ)
.PHONY: all install uninstall clean