forked from Cotix/cReddit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
102 lines (80 loc) · 2.34 KB
/
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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
# CREDDIT MAKEFILE
#
# Normal usage: make; make install
#
# 'make' will default to compiling creddit in ./build/creddit and libreddit as
# ./build/libreddit.so (shared object)
# To compile libreddit as a shared library separately, use 'make libreddit'
#
# To compile libreddit as a static library, compile with STATIC=y
# Ex. make STATIC=y
#
# To turn on debugging, set an environment variable called 'REDDIT_DEBUG' to
# 'y' and then 'make clean' and 'make'. This will turn off optimization, turn on
# the -g flag, and set the 'REDDIT_DEBUG' C macro for all of the project's C
# files.
#
# Bash users can run the command 'export REDDIT_DEBUG=y' to turn debugging on.
#
# You can also compile individual parts or individual files on their own, by
# specifying their object name.
# Ex. 'make build/src/main.o'
QUIETLY:=@
# Set some basic program-wide compile settings
# In the future these shouldn't be assumed.
CC:=$(QUIETLY)gcc
ifdef REDDIT_DEBUG
PROJCFLAGS+=-g -DREDDIT_DEBUG
RUN_FIRST:=debug-msg real-all
else
PROJCFLAGS=-O2
RUN_FIRST:=real-all
endif
PROJCFLAGS+=-Wall -I'./include' -fvisibility=hidden
PROJLDFLAGS:=-fvisibility=hidden
LD:=$(QUIETLY)ld
AR:=$(QUIETLY)ar
INSTALL:=$(QUIETLY)install
OBJCOPY:=$(QUIETLY)objcopy
BUILD_DIR:=build
MKDIR:=$(QUIETLY)mkdir -p
ECHO:=$(QUIETLY)echo
RM:=$(QUIETLY)rm
ifndef PREFIX
PREFIX=/usr
endif
all: $(RUN_FIRST)
debug-msg:
$(ECHO) " !!Debug Build!!"
include ./common.mk
# Set initial values for 'targets'
CLEAN_TARGETS:=
COMPILE_TARGETS:=
INSTALL_TARGETS:=
# Include mk files from any subdirectories
# These files add onto the 'targets'
include ./libreddit/libreddit.mk
include ./src/creddit.mk
# Add a few ending values for the main program
CLEAN_TARGETS +=build_clean
.PHONY: all real-all debug-msg install clean $(CLEAN_TARGETS) $(INSTALL_TARGETS)
real-all: $(EXECUTABLE_FULL)
$(PREFIX)/bin:
$(ECHO) " MKDIR $(PREFIX)/bin"
$(MKDIR) $(PREFIX)/bin
$(PREFIX)/include:
$(ECHO) " MKDIR $(PREFIX)/include"
$(MKDIR) $(PREFIX)/include
$(PREFIX)/lib:
$(ECHO) " MKDIR $(PREFIX)/lib"
$(MKDIR) $(PREFIX)/lib
install: $(INSTALL_TARGETS)
$(BUILD_DIR):
$(ECHO) " MKDIR $(BUILD_DIR)"
$(MKDIR) $(BUILD_DIR)
# Calls all the clean targets to be run, so we can clean up the build directory
clean: $(CLEAN_TARGETS)
# Top level clean -- deletes whole build directory
build_clean:
$(ECHO) " RM $(BUILD_DIR)"
$(RM) -fr $(BUILD_DIR)