-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (74 loc) · 2.13 KB
/
Makefile
File metadata and controls
88 lines (74 loc) · 2.13 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Generic Makefile
# See LICENSE file for copyright and license details.
# See README for more information on the program
include config.mk
# CFLAG options
# Compiler debugging enabled
ifeq ($(DEBUG), yes)
CFLAGS += -Wextra
CFLAGS += -g
endif
# Pedantic warnings
ifeq ($(PEDANTIC), yes)
CFLAGS += -Werror
CFLAGS += -pedantic
CFLAGS += -pedantic-errors
endif
# Enable optimization
ifeq ($(OPTIMIZE), yes)
CFLAGS += -O3
endif
# Sets if lib or bin
ifeq ($(TYPE), lib)
DIR ?= $(LIB_DIR)
else
DIR ?= $(BIN_DIR)
endif
all: options $(TARGET)
options:
@echo "$(TARGET) build options:"
@echo "CFLAGS = $(CFLAGS)"
@echo "LIBS = $(LIBS)"
@echo "CC = $(CC)"
%.o: %.c
@echo -e "\n>> compiling object files <<\n"
$(CC) $(CFLAGS) -c $< -o $@
$(TARGET): $(OBJ)
@echo -e "\n>> linking object files into a shared library <<\n"
$(CC) $(LIBS) $(OBJ) -o $(DIR)/$(OUTPUT)
@echo -e "\n>> done compiling <<"
clean:
@echo -e ">> cleaning <<\n"
@rm -rvf $(DIR)/* $(OBJ) $(DIR)/*
@echo -e "\n>> done cleaning <<"
dist:
@echo -e ">> making dist tarball <<\n"
@mkdir -vp $(TARGET)-$(VERSION)
@cp -avr LICENSE Makefile config.mk $(SRC_DIR) $(TARGET)-$(VERSION)
tar -cvf $(TARGET)-$(VERSION).tar $(TARGET)-$(VERSION)
gzip -v $(TARGET)-$(VERSION).tar
@rm -rvf $(TARGET)-$(VERSION)
@echo -e "\n>> $(TARGET)-$(VERSION).tar.gz created <<"
install: all
@echo -e "\n>> installing $(TARGET)-$(VERSION) <<\n"
@mkdir -p $(DESTDIR)$(PREFIX)/$(DIR)
@mkdir -p $(DESTDIR)$(PREFIX)/$(INC_DIR)
@cp -vf $(DIR)/$(OUTPUT) $(DESTDIR)$(PREFIX)/$(DIR)
ifeq ($(TYPE), lib)
@cp -vf $(SRC_DIR)/*.h $(DESTDIR)$(PREFIX)/$(INC_DIR)
@/usr/bin/bash -c "pushd $(DESTDIR)$(PREFIX)/$(DIR) > /dev/null;\
ln -svf $(OUTPUT) $(LIB_LN);\
ln -svf $(OUTPUT) $(LIB_LN_V);\
popd > /dev/null;"
endif
@echo -e "\n>> done installing <<"
uninstall:
@echo -e ">> uninstalling $(TARGET)-$(VERSION) <<\n"
@rm -vf $(DESTDIR)$(PREFIX)/$(INC_DIR)/$(TARGET).h
@rm -vf $(DESTDIR)$(PREFIX)/$(DIR)/$(OUTPUT)
ifeq ($(TYPE), lib)
@rm -vf $(DESTDIR)$(PREFIX)/$(DIR)/$(LIB_LN)
@rm -vf $(DESTDIR)$(PREFIX)/$(DIR)/$(LIB_LN_V)
endif
@echo -e "\n>> done uninstalling <<"
.PHONY: all options clean dist install uninstall