This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
96 lines (77 loc) · 2.51 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
# Shiny Profiler
# GNU Makefile for Linux
#
# By default libShiny.a will be compiled with g++ C++ compiler. If you prefer
# or need a plain C version use the 'cclib' target. The C compiled lib should
# be compatible to C AND C++ code conforming to ISO C99 and ISO C++98 (or
# later).
#
# To build Shiny as a static C++ library use:
# $ make
# or
# $ make shiny-cxx
#
# To build it as a static C library (ISO C99) use:
# $ make shiny-c
#
# For building either library including debug symbols use:
# $ make debug-cxx
# or
# $ make debug-c
#
# If you experience incompatibilities please feel free to tailor this makefile
# to your needs and report problems here:
# - sourceforge: http:https://sourceforge.net/projects/shinyprofiler/
# - Google Code: http:https://code.google.com/p/shinyprofiler/
SRCS = $(wildcard src/*.c)
OBJS = $(SRCS:.c=.o)
LIB_NAME = libShiny.a
LIB_PATH = lib
LIB_PATH_DEBUG = lib/debug
##################
# Compiler options
CFLAGS = -std=c99
CXXFLAGS = -std=c++98
CCFLAGS_RELEASE = -O3 -fPIC -Wall -Wpedantic
CCFLAGS_DEBUG = -g3 -O0 -Wall -Wpedantic
INCLUDE = -Iinclude
# C options
shiny-c debug-c: CCOMP = $(CC)
shiny-c: CCFLAGS = $(CCFLAGS_RELEASE) $(CFLAGS)
debug-c: CCFLAGS = $(CCFLAGS_DEBUG) $(CFLAGS)
# C++ options
shiny-cxx debug-cxx: CCOMP = $(CXX)
shiny-cxx: CCFLAGS = $(CCFLAGS_RELEASE) $(CXXFLAGS)
debug-cxx: CCFLAGS = $(CCFLAGS_DEBUG) $(CXXFLAGS)
##################
# Target definitions
# Default target builds static C++ lib
all: shiny-cxx
# Copy release build to lib/
shiny-c shiny-cxx: clean $(LIB_NAME)
mkdir -p $(LIB_PATH)
mv $(LIB_NAME) $(LIB_PATH)
# Copy debug build to lib/debug/
debug-c debug-cxx: clean $(LIB_NAME)
mkdir -p $(LIB_PATH_DEBUG)
mv $(LIB_NAME) $(LIB_PATH_DEBUG)
# Build static lib in either C or C++
$(LIB_NAME): $(OBJS)
$(AR) rcs $@ $^
# Create object files from source code
.c.o:
$(CCOMP) $(CCFLAGS) $(INCLUDE) -c $< -o $@
# Remove temporary files and compilation results
clean:
$(RM) $(OBJS) $(LIB_PATH)/$(LIB_NAME) $(LIB_PATH_DEBUG)/$(LIB_NAME)
help:
@echo "Available targets for Shiny"
@echo " all: Build static library libShiny.a using C++ compiler"
@echo " shiny-cxx: Build static library libShiny.a using C++ compiler"
@echo " shiny-c: Build static library libShiny.a using C compiler"
@echo ""
@echo " debug-cxx: Build static library libShiny.a with debug symbols using C++ compiler"
@echo " debug-c: Build static library libShiny.a with debug symbols using C compiler"
@echo ""
@echo " clean: Clean up directories"
.PHONY: all shiny-c shiny-cxx debug-c debug-cxx help clean