-
Notifications
You must be signed in to change notification settings - Fork 10
/
makefile
61 lines (45 loc) · 1.59 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
# Which compiler to use
COMPILER = gcc
# Path to core
PATH_CORE = core
# Path to plugins
PATH_PLUGINS = plugins
# Path to plugins src
PATH_PLUGINS_SRC = $(PATH_PLUGINS)/*/src/*.c
# Path to plugins libs
PATH_PLUGINS_LIBS = $(PATH_PLUGINS)/*/libs/*
# Path to core source files
PATH_SRC_CORE = $(PATH_CORE)/src
# Name of CHL library
NAME_MAIN_LIB = libchl
# Name of CHL directories
NAME_CHL_DIR = chl
# Path to default location for libraries and headers
LIBSPATH = /usr/lib/$(NAME_CHL_DIR)
HEADERSPATH = /usr/include/$(NAME_CHL_DIR)
# Default, compile to object files
all: compile
# Move lib and header files to proper locations
install: lib
if ! [ -d "$(LIBSPATH)" ]; then mkdir $(LIBSPATH); fi
if ! [ -d "$(HEADERSPATH)" ]; then mkdir $(HEADERSPATH); fi
mv $(NAME_MAIN_LIB).$(EXTENSION) $(LIBSPATH)/
cp $(wildcard $(PATH_PLUGINS_LIBS).so*) $(LIBSPATH)/ 2>/dev/null || :
cp $(PATH_CORE)/*.h $(HEADERSPATH)/
cp $(wildcard $(PATH_PLUGINS)/*/*.h) $(HEADERSPATH)/ 2>/dev/null || :
ln -f -s $(LIBSPATH)/* /usr/lib/
# Create main and plugin shared libraries
lib: compile
# Create main shared library
gcc -shared -o $(NAME_MAIN_LIB).so *.o
make clean
# Create plugin libraries
bash createlibs $(PATH_PLUGINS)
# Compile source files to position independent object files
compile:
# Check whether to compile for FastCGI or CGI
if [ "${TYPE}" != "FCGI" ]; then $(COMPILER) -c -Wall -Werror -fPIC $(PATH_SRC_CORE)/*.c $(wildcard $(PATH_PLUGINS_SRC)); else $(COMPILER) -c -D '_F_CHL_' -Wall -Werror -fPIC $(PATH_SRC_CORE)/*.c $(wildcard $(PATH_PLUGINS_SRC)); fi
$(eval EXTENSION = so)
# Clean up
clean:
rm *.o