-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
160 lines (133 loc) · 3.52 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Makefile for YAIV for mostly POSIX.
# ----------------------------------------------------------------------
# Written by Raph.K.
#
GCC = gcc
GPP = g++
AR = ar
WRC = windres
FCG = fltk-config --use-images
# FLTK configs
FLTKCFG_CXX := $(shell ${FCG} --cxxflags)
FLTKCFG_LFG := $(shell ${FCG} --ldflags)
# Base PATH
BASE_PATH = .
FIMG_PATH = ../fl_imgtk/lib
SRC_PATH = $(BASE_PATH)/src
# TARGET settings
TARGET_PKG = yaiv
TARGET_DIR = ./bin
TARGET_OBJ = ./obj
# DEFINITIONS
DEFS = -D_POSIX_THREADS -DSUPPORT_DRAGDROP -DMININI_ANSI
DEFS += -DUSE_OMP
DEFS += -DINI_ANSIONLY
# Compiler optiops
COPTS += -ffast-math -fexceptions
LOPTS =
LTWKS =
CXXOPTS =
# Are you debugging ?
DEBUG =
ifeq ($(DEBUG),1)
COPTS += -g -DDEBUG
else
COPTS += -O2
endif
# Automatic detecting platform -
ARCH_S = $(shell uname -s)
ARCH_M = $(shell uname -m)
ARCH_R = $(shell uname -r | cut -d . -f1)
# Architecture reconfiguration ...
ifeq ($(ARCH_S),Darwin)
GCC = llvm-gcc
CPP = llvm-g++
CXXOPTS += -std=c++11
ifeq ($(shell test $(ARCH_R) -gt 19; echo $$?),0)
COPTS += -arch x86_64 -arch arm64
endif
LOPTS += -lwebp -lwebpdemux -lwebpmux
ifeq ($(DEBUG),0)
LTWKS += -s
endif
else ifeq ($(ARCH_S),Linux)
CXXOPTS += -std=c++11
COPTS += -fopenmp
LOPTS += -lwebp -lwebpdemux -lwebpmux
else
ARCH_SS = $(shell echo $(ARCH_S) | cut -d _ -f1)
ifeq ($(ARCH_SS),MINGW64)
COPTS += -mms-bitfields -mwindows
COPTS += -fopenmp
LOPTS += -lwebp -lwebpdecoder -lwebpdemux -lwebpmux
endif
ifeq ($(DEBUG),0)
LTWKS += -s
endif
endif
# CC FLAGS
CFLAGS = -I$(SRC_PATH)
CFLAGS += -I$(SRC_PATH)/toolbar
CFLAGS += -I$(FIMG_PATH)
CFLAGS += $(DEFS)
CFLAGS += $(COPTS)
# CXX FLAGS
CXXFLAGS = -I$(SRC_PATH)
CXXFLAGS += -I$(SRC_PATH)/toolbar
CXXFLAGS += -I$(FIMG_PATH)
CXXFLAGS += $(FLTKCFG_CXX)
CXXFLAGS += $(DEFS)
CXXFLAGS += $(COPTS)
CXXFLAGS += $(CXXOPTS)
# Windows Resource Flags
WFLGAS = $(CFLAGS)
# LINK FLAG
LFLAGS =
LFLAGS += -L$(FIMG_PATH)
LFLAGS += -lfl_imgtk
LFLAGS += ${FLTKCFG_LFG}
LFLAGS += -lpthread
LFLAGS += -lsqlite3
LFLAGS += $(LOPTS)
LFLAGS += $(LTWKS)
# Sources
SRCS_CPP = $(wildcard $(SRC_PATH)/*.cpp)
SRCS_C = $(wildcard $(SRC_PATH)/*.c)
SRCS_TOOLBAR = $(wildcard $(SRC_PATH)/toolbar/*.cxx)
# Make object targets from SRCS.
OBJS_CPP = $(SRCS_CPP:$(SRC_PATH)/%.cpp=$(TARGET_OBJ)/%.cxo)
OBJS_C = $(SRCS_C:$(SRC_PATH)/%.c=$(TARGET_OBJ)/%.co)
OBJS_TOOLBAR = $(SRCS_TOOLBAR:$(SRC_PATH)/toolbar/%.cxx=$(TARGET_OBJ)/toolbar/%.cxo)
.PHONY: prepare clean avx
all: prepare continue
continue: $(TARGET_DIR)/$(TARGET_PKG)
prepare:
@mkdir -p $(TARGET_DIR)
@mkdir -p $(TARGET_OBJ)
@mkdir -p $(TARGET_OBJ)/toolbar
cleanobj:
@echo "Cleaning objects ..."
@rm -rf $(TARGET_INC)/*.h
@rm -rf $(TARGET_OBJ)/*.cxo
@rm -rf $(TARGET_OBJ)/*.co
@rm -rf $(TARGET_OBJ)/toolbar/*.cxo
@rm -rf $(TARGET_WROBJ)/*.res
clean: cleanobj
@echo "Cleaning built targets ..."
@rm -rf $(TARGET_DIR)/$(TARGET_PKG).*
packaging:
@cp -rf pkgscripts/license.rtf ${TARGET_DIR}
@cp -rf pkgscripts/readme.rtf ${TARGET_DIR}
$(OBJS_C): $(TARGET_OBJ)/%.co: $(SRC_PATH)/%.c
@echo "Building $< ... "
@$(GCC) $(CFLAGS) -c $< -o $@
$(OBJS_CPP): $(TARGET_OBJ)/%.cxo: $(SRC_PATH)/%.cpp
@echo "Building $< ... "
@$(GPP) $(CXXFLAGS) -c $< -o $@
$(OBJS_TOOLBAR): $(TARGET_OBJ)/toolbar/%.cxo: $(SRC_PATH)/toolbar/%.cxx
@echo "Building $< ... "
@$(GPP) $(CXXFLAGS) -c $< -o $@
$(TARGET_DIR)/$(TARGET_PKG): $(OBJS_CPP) $(OBJS_C) $(OBJS_TOOLBAR)
@echo "Generating $@ ..."
@$(GPP) $^ $(CFLAGS) $(LFLAGS) -o $@
@echo "done."