-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
153 lines (133 loc) · 5.28 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
#############################################
## ##
## Copyright (C) 2019-2022 Julian Uy ##
## https://sites.google.com/site/awertyb ##
## ##
## See details of license at "LICENSE" ##
## ##
#############################################
TARGET_ARCH ?= intel32
USE_STABS_DEBUG ?= 0
USE_POSITION_INDEPENDENT_CODE ?= 0
USE_ARCHIVE_HAS_GIT_TAG ?= 0
ifeq (x$(TARGET_ARCH),xarm32)
TOOL_TRIPLET_PREFIX ?= armv7-w64-mingw32-
endif
ifeq (x$(TARGET_ARCH),xarm64)
TOOL_TRIPLET_PREFIX ?= aarch64-w64-mingw32-
endif
ifeq (x$(TARGET_ARCH),xintel64)
TOOL_TRIPLET_PREFIX ?= x86_64-w64-mingw32-
endif
TOOL_TRIPLET_PREFIX ?= i686-w64-mingw32-
ifeq (x$(TARGET_ARCH),xarm32)
TARGET_CMAKE_SYSTEM_PROCESSOR ?= arm
endif
ifeq (x$(TARGET_ARCH),xarm64)
TARGET_CMAKE_SYSTEM_PROCESSOR ?= arm64
endif
ifeq (x$(TARGET_ARCH),xintel64)
TARGET_CMAKE_SYSTEM_PROCESSOR ?= amd64
endif
TARGET_CMAKE_SYSTEM_PROCESSOR ?= i686
CC := $(TOOL_TRIPLET_PREFIX)gcc
CXX := $(TOOL_TRIPLET_PREFIX)g++
AR := $(TOOL_TRIPLET_PREFIX)ar
WINDRES := $(TOOL_TRIPLET_PREFIX)windres
STRIP := $(TOOL_TRIPLET_PREFIX)strip
7Z := 7z
ifeq (x$(TARGET_ARCH),xintel32)
OBJECT_EXTENSION ?= .o
endif
OBJECT_EXTENSION ?= .$(TARGET_ARCH).o
DEP_EXTENSION ?= .dep.make
export GIT_TAG := $(shell git describe --abbrev=0 --tags)
INCFLAGS += -I. -I..
ALLSRCFLAGS += $(INCFLAGS) -DGIT_TAG=\"$(GIT_TAG)\"
OPTFLAGS := -O3
ifeq (x$(TARGET_ARCH),xintel32)
OPTFLAGS += -march=pentium4 -mfpmath=sse
endif
ifeq (x$(TARGET_ARCH),xintel32)
ifneq (x$(USE_STABS_DEBUG),x0)
CFLAGS += -gstabs
else
CFLAGS += -gdwarf-2
endif
else
CFLAGS += -gdwarf-2
endif
ifneq (x$(USE_POSITION_INDEPENDENT_CODE),x0)
CFLAGS += -fPIC
endif
CFLAGS += -flto
CFLAGS += $(ALLSRCFLAGS) -Wall -Wno-unused-value -Wno-format -DNDEBUG -DWIN32 -D_WIN32 -D_WINDOWS
CFLAGS += -D_USRDLL -DMINGW_HAS_SECURE_API -DUNICODE -D_UNICODE -DNO_STRICT
CFLAGS += -MMD -MF $(patsubst %$(OBJECT_EXTENSION),%$(DEP_EXTENSION),$@)
CFLAGS += -DDISABLE_PERF_MEASUREMENT
CXXFLAGS += $(CFLAGS) -fpermissive
WINDRESFLAGS += $(ALLSRCFLAGS) --codepage=65001
LDFLAGS += $(OPTFLAGS) -static -static-libgcc -Wl,--kill-at -fPIC
LDFLAGS_LIB += -shared
LDLIBS +=
DEPENDENCY_SOURCE_DIRECTORY := $(abspath build-source)
DEPENDENCY_BUILD_DIRECTORY := $(abspath build-$(TARGET_ARCH))
DEPENDENCY_OUTPUT_DIRECTORY := $(abspath build-libraries)-$(TARGET_ARCH)
INCFLAGS += -I$(DEPENDENCY_OUTPUT_DIRECTORY)/include
%$(OBJECT_EXTENSION): %.c
@printf '\t%s %s\n' CC $<
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $<
%$(OBJECT_EXTENSION): %.cpp
@printf '\t%s %s\n' CXX $<
$(CXX) -c $(CXXFLAGS) $(OPTFLAGS) -o $@ $<
%$(OBJECT_EXTENSION): %.rc
@printf '\t%s %s\n' WINDRES $<
$(WINDRES) $(WINDRESFLAGS) $< $@
PROJECT_BASENAME ?= ifjxr
ifeq (x$(TARGET_ARCH),xintel32)
BINARY ?= $(PROJECT_BASENAME)_unstripped.spi
endif
ifeq (x$(TARGET_ARCH),xintel64)
BINARY ?= $(PROJECT_BASENAME)_unstripped.sph
endif
BINARY ?= $(PROJECT_BASENAME)_$(TARGET_ARCH)_unstripped.spi
ifeq (x$(TARGET_ARCH),xintel32)
BINARY_STRIPPED ?= $(PROJECT_BASENAME).spi
endif
ifeq (x$(TARGET_ARCH),xintel64)
BINARY_STRIPPED ?= $(PROJECT_BASENAME).sph
endif
BINARY_STRIPPED ?= $(PROJECT_BASENAME)_$(TARGET_ARCH).spi
ifneq (x$(USE_ARCHIVE_HAS_GIT_TAG),x0)
ARCHIVE ?= $(PROJECT_BASENAME).$(TARGET_ARCH).$(GIT_TAG).7z
endif
ARCHIVE ?= $(PROJECT_BASENAME).$(TARGET_ARCH).7z
JXRLIB_SOURCES += external/jxrlib/image/decode/JXRTranscode.c external/jxrlib/image/decode/decode.c external/jxrlib/image/decode/postprocess.c external/jxrlib/image/decode/segdec.c external/jxrlib/image/decode/strInvTransform.c external/jxrlib/image/decode/strPredQuantDec.c external/jxrlib/image/decode/strdec.c external/jxrlib/image/encode/encode.c external/jxrlib/image/encode/segenc.c external/jxrlib/image/encode/strFwdTransform.c external/jxrlib/image/encode/strPredQuantEnc.c external/jxrlib/image/encode/strenc.c external/jxrlib/image/sys/adapthuff.c external/jxrlib/image/sys/image.c external/jxrlib/image/sys/perfTimerANSI.c external/jxrlib/image/sys/strPredQuant.c external/jxrlib/image/sys/strTransform.c external/jxrlib/image/sys/strcodec.c external/jxrlib/jxrgluelib/JXRGlue.c external/jxrlib/jxrgluelib/JXRGlueJxr.c external/jxrlib/jxrgluelib/JXRGluePFC.c external/jxrlib/jxrgluelib/JXRMeta.c
SOURCES := extractor.c $(JXRLIB_SOURCES)
OBJECTS := $(SOURCES:.c=$(OBJECT_EXTENSION))
OBJECTS := $(OBJECTS:.cpp=$(OBJECT_EXTENSION))
OBJECTS := $(OBJECTS:.rc=$(OBJECT_EXTENSION))
DEPENDENCIES := $(OBJECTS:%$(OBJECT_EXTENSION)=%$(DEP_EXTENSION))
EXTERNAL_LIBS :=
INCFLAGS += -Iexternal/jxrlib -Iexternal/jxrlib/common/include -Iexternal/jxrlib/image/sys -Iexternal/jxrlib/jxrgluelib
.PHONY:: all archive clean
all: $(BINARY_STRIPPED)
archive: $(ARCHIVE)
clean::
rm -f $(OBJECTS) $(OBJECTS_BIN) $(BINARY) $(BINARY_STRIPPED) $(ARCHIVE) $(DEPENDENCIES)
rm -rf $(DEPENDENCY_SOURCE_DIRECTORY) $(DEPENDENCY_BUILD_DIRECTORY) $(DEPENDENCY_OUTPUT_DIRECTORY)
$(DEPENDENCY_SOURCE_DIRECTORY):
mkdir -p $@
$(DEPENDENCY_OUTPUT_DIRECTORY):
mkdir -p $@
$(ARCHIVE): $(BINARY_STRIPPED) $(EXTRA_DIST)
@printf '\t%s %s\n' 7Z $@
rm -f $(ARCHIVE)
$(7Z) a $@ $^
$(BINARY_STRIPPED): $(BINARY)
@printf '\t%s %s\n' STRIP $@
$(STRIP) -o $@ $^
$(BINARY): $(OBJECTS) $(EXTERNAL_LIBS)
@printf '\t%s %s\n' LNK $@
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_LIB) -o $@ $^ $(LDLIBS)
-include $(DEPENDENCIES)