-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
167 lines (119 loc) · 3.84 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
161
162
163
164
165
166
GRIT_VERSION := 0.8.6
GRIT_BUILD := 20100317
CXXFLAGS := -Icldib -Ilibgrit -Iextlib
CXXFLAGS += -DGRIT_VERSION=\"$(GRIT_VERSION)\" -DGRIT_BUILD=\"$(GRIT_BUILD)\"
LDFLAGS :=
# ---------------------------------------------------------------------
# Platform specific stuff
# ---------------------------------------------------------------------
UNAME := $(shell uname -s)
ifneq (,$(findstring MINGW,$(UNAME)))
PLATFORM := win32
EXEEXT := .exe
CFLAGS += -mno-cygwin
LDFLAGS += -mno-cygwin -s
OS := win32
EXTRAINSTALL := extlib/FreeImage.dll
endif
ifneq (,$(findstring CYGWIN,$(UNAME)))
CFLAGS += -mno-cygwin
LDFLAGS += -mno-cygwin -s
EXEEXT := .exe
OS := win32
EXTRAINSTALL := extlib/FreeImage.dll
endif
ifneq (,$(findstring Darwin,$(UNAME)))
SDK := /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
OSXCFLAGS := -mmacosx-version-min=10.7 -isysroot $(SDK) #-arch i386 -arch ppc
OSXCXXFLAGS := $(OSXCFLAGS) -stdlib=libc++11 -std=c++11
CXXFLAGS += -fvisibility=hidden
LDFLAGS += -mmacosx-version-min=10.7 -Wl,-syslibroot,$(SDK) #-arch i386 -arch ppc
endif
ifneq (,$(findstring Linux,$(UNAME)))
LDFLAGS += -s -static
OS := Linux
endif
TARGET := grit$(EXEEXT)
DRIVER_TARGET := driver$(EXEEXT)
# ---------------------------------------------------------------------
# Library directories
# ---------------------------------------------------------------------
# === cldib ===
CLDIB_DIR := cldib
LIBCLDIB := libcldib.a
LIBCLDIB_SRC := \
cldib_adjust.cpp \
cldib_conv.cpp \
cldib_core.cpp \
cldib_tmap.cpp \
cldib_tools.cpp \
cldib_wu.cpp \
cldib_bmp.cpp \
cldib_img.cpp
LIBCLDIB_OBJ := $(addprefix build/, $(LIBCLDIB_SRC:.cpp=.o))
# === libgrit ===
LIBGRIT_DIR := libgrit
LIBGRIT := libgrit.a
LIBGRIT_SRC := \
cprs.cpp \
cprs_huff.cpp \
cprs_lz.cpp \
cprs_rle.cpp \
grit_core.cpp \
grit_misc.cpp \
grit_prep.cpp \
grit_shared.cpp \
grit_xp.cpp \
logger.cpp \
pathfun.cpp
LIBGRIT_OBJ := $(addprefix build/, $(LIBGRIT_SRC:.cpp=.o))
# === External/shared library stuff ===
EXTLIB_DIR := extlib
# === Grit ===
GRIT_DIR := srcgrit
GRIT_SRC := grit_main.cpp cli.cpp
GRIT_OBJ := $(addprefix build/, $(GRIT_SRC:.cpp=.o))
# === DRIVER ===
DRIVER_DIR := fromager
DRIVER_SRC := driver.cpp
DRIVER_OBJ := $(addprefix build/, $(DRIVER_SRC:.cpp=.o))
DEPENDS := $(GRIT_OBJ:.o=.d) $(DRIVER_OBJ:.o=.d) $(LIBCLDIB_OBJ:.o=.d) $(LIBGRIT_OBJ:.o=.d)
# ---------------------------------------------------------------------
SRCDIRS := $(CLDIB_DIR) $(LIBGRIT_DIR) $(GRIT_DIR) $(DRIVER_DIR) $(EXTLIB_DIR)
INCDIRS := $(CLDIB_DIR) $(LIBGRIT_DIR) $(EXTLIB_DIR)
LIBDIRS := .
INCLUDE := $(foreach dir, $(INCDIRS), -I$(dir))
LIBPATHS := $(foreach dir, $(LIBDIRS), -L$(dir))
VPATH := $(foreach dir, $(SRCDIRS), $(dir))
CPPFLAGS += $(INCLUDE)
# ---------------------------------------------------------------------
# Build rules
# ---------------------------------------------------------------------
.PHONY:
all clean pre
all: build $(TARGET)
# make grit_main.o dependent on makefile for version number
build/grit_main.o : Makefile
$(LIBCLDIB) : $(LIBCLDIB_OBJ)
$(LIBGRIT) : $(LIBGRIT_OBJ)
$(TARGET) : $(LIBCLDIB) $(LIBGRIT) $(GRIT_OBJ)
$(CXX) $(LDFLAGS) -o $@ $(GRIT_OBJ) $(LIBPATHS) -lgrit -lcldib
$(DRIVER_TARGET) : $(LIBCLDIB) $(LIBGRIT) $(DRIVER_OBJ)
$(CXX) $(LDFLAGS) -o $@ $(DRIVER_OBJ) $(LIBPATHS) -lgrit -lcldib
build:
@[ -d $@ ] || mkdir -p $@
clean :
rm -fr $(TARGET) $(DRIVER_TARGET) build $(LIBGRIT) $(LIBCLDIB) *.bz2
install:
cp $(TARGET) $(EXTRAINSTALL) $(PREFIX)
dist-src:
@tar --exclude=*CVS* -cvjf grit-src-$(GRIT_VERSION).tar.bz2 $(SRCDIRS) *.txt Makefile
dist-bin: all
@tar -cjvf grit-$(VERSION)-$(OS).tar.bz2 $(TARGET) $(EXTRATAR)
dist: dist-src dist-bin
build/%.o : %.cpp
$(CXX) $(OSXCXXFLAGS) $(CXXFLAGS) -MMD -MF build/$(*).d -o $@ -c $<
%.a :
rm -f $@
ar rcs $@ $^
-include $(DEPENDS)