-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.gcc-new
130 lines (101 loc) · 4.22 KB
/
Makefile.gcc-new
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
include VARS
PACKAGE_NAME=gcc
VERSION=Git-$(VERSIONBUILD)
VERSIONPATCH=
SOURCE_DIR=$(BUILD_DIR)/$(PACKAGE_NAME)-$(VERSION)
COMPIL_DIR=$(BUILD_DIR)/$(PACKAGE_NAME)-$(VERSION)$(VERSIONPATCH)-$(VERSIONBINCPU)
GIT_SRC=https://github.com/th-otto/m68k-atari-mint-gcc.git --branch mint/gcc-12 --single-branch
ARCHIVE_SRC_FILE=
ARCHIVE_PATCH_FILE=
PACKAGE_FILE=$(PACKAGE_NAME)-$(VERSION)$(VERSIONPATCH)-$(VERSIONBINCPU)-$(VERSIONBUILD).tgz
BINARY_DIR=$(COMPIL_DIR)/binary-package
LOCAL_PREFIX_DIR=$(BINARY_DIR)$(PREFIX)
CFLAGS=
##########################################
.PHONY: all clean extract patch configure compile packaging install
all: extract patch configure compile packaging install
clean:
ifeq "$(BUILD_DIR)" ""
@echo "BUILD_DIR is not set" && exit 1
endif
rm -rf "$(COMPIL_DIR)"
rm -rf "$(SOURCE_DIR)"
rm -rf "$(PACKAGES_DIR)/$(PACKAGE_FILE)"
##########################################
extract: $(SOURCE_DIR)
patch: $(SOURCE_DIR)/_patch_$(PACKAGE_NAME)
configure: $(COMPIL_DIR)/Makefile
compile: temp_gcc mintlib fdlibm fix_limits
make -j $(NUM_CPUS) --directory="$(COMPIL_DIR)"
packaging: $(PACKAGES_DIR)/$(PACKAGE_FILE)
install: packaging
tar xvzf "$(PACKAGES_DIR)/$(PACKAGE_FILE)" --directory $(dir $(PREFIX))
##########################################
# extract sources
$(SOURCE_DIR):
ifneq "$(ARCHIVE_SRC_FILE)" ""
$(MAKE) FILE="$(ARCHIVE_SRC_FILE)" fetch
tar xvjf "$(ARCHIVES_DIR)/$(ARCHIVE_SRC_FILE)" --directory "$(BUILD_DIR)"
endif
ifneq "$(GIT_SRC)" ""
mkdir -p "$(dir $(SOURCE_DIR))"
git clone --depth 1 $(GIT_SRC) $(SOURCE_DIR)/
endif
# apply patch to sources
$(SOURCE_DIR)/_patch_$(PACKAGE_NAME):
ifneq "$(VERSIONPATCH)" ""
$(MAKE) FILE="$(ARCHIVE_PATCH_FILE)" fetch
bzcat "$(ARCHIVES_DIR)/$(ARCHIVE_PATCH_FILE)" | patch -p1 --directory $(SOURCE_DIR) && touch "$(SOURCE_DIR)/_patch_$(PACKAGE_NAME)"
endif
# configure package
$(COMPIL_DIR)/Makefile: $(SOURCE_DIR)/_patch_$(PACKAGE_NAME)
-mkdir $(dir $@)
cd "$(dir $@)" && \
../$(PACKAGE_NAME)-$(VERSION)/configure --target=m68k-atari-mint --prefix="$(PREFIX)" \
--enable-languages="c,c++" \
--disable-nls --disable-libstdcxx-pch \
--disable-libvtv \
--disable-libmpx \
--disable-libcc1 \
--disable-libgomp \
--disable-threads \
--disable-decimal-float \
--disable-nls \
--disable-shared \
--with-gmp=$(BUILD_DIR)/gcclibs --with-mpfr=$(BUILD_DIR)/gcclibs \
CFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer" CXXFLAGS_FOR_TARGET="-O2 -fomit-frame-pointer"
temp_gcc:
make -j $(NUM_CPUS) --directory="$(COMPIL_DIR)" all-gcc
ifeq "$(shell uname -s)" "Darwin"
rm "$(COMPIL_DIR)/gcc/as"
ln -s $(PREFIX)/bin/m68k-atari-mint-as "$(COMPIL_DIR)/gcc/as"
endif
make -j $(NUM_CPUS) --directory="$(COMPIL_DIR)" all-target-libgcc
# build distribution package
$(PACKAGES_DIR)/$(PACKAGE_FILE):
make --directory="$(COMPIL_DIR)" install DESTDIR="$(BINARY_DIR)"
-rm -r "$(LOCAL_PREFIX_DIR)"/include
-rm "$(LOCAL_PREFIX_DIR)"/lib/*.a
find "$(LOCAL_PREFIX_DIR)" -type f -name "*.la" -delete
-rm -r "$(LOCAL_PREFIX_DIR)"/share/gcc-$(VERSION)
-rm -r "$(LOCAL_PREFIX_DIR)"/share/info
-rm -r "$(LOCAL_PREFIX_DIR)"/share/man/man7
gzip -9 "$(LOCAL_PREFIX_DIR)"/share/man/man1/*.1
strip "$(LOCAL_PREFIX_DIR)"/bin/*
-strip "$(LOCAL_PREFIX_DIR)"/libexec/gcc/m68k-atari-mint/$(VERSION)/*
-strip "$(LOCAL_PREFIX_DIR)"/libexec/gcc/m68k-atari-mint/$(VERSION)/install-tools/*
find "$(LOCAL_PREFIX_DIR)"/m68k-atari-mint/lib -name '*.a' -print -exec m68k-atari-mint-strip -S -x '{}' ';'
find "$(LOCAL_PREFIX_DIR)"/m68k-atari-mint/lib -name '*.a' -print -exec m68k-atari-mint-ranlib '{}' ';'
find "$(LOCAL_PREFIX_DIR)"/lib/gcc/m68k-atari-mint/* -name '*.a' -print -exec m68k-atari-mint-strip -S -x '{}' ';'
find "$(LOCAL_PREFIX_DIR)"/lib/gcc/m68k-atari-mint/* -name '*.a' -print -exec m68k-atari-mint-ranlib '{}' ';'
tar cvzf "$@" --directory "$(dir $(LOCAL_PREFIX_DIR))" $(notdir $(LOCAL_PREFIX_DIR))
mintlib:
$(MAKE) mintlib GCC="$(COMPIL_DIR)/gcc/xgcc"
pml:
$(MAKE) pml GCC="$(COMPIL_DIR)/gcc/xgcc"
fdlibm:
$(MAKE) fdlibm GCC="$(COMPIL_DIR)/gcc/xgcc"
# Dirty hack to fix the PATH_MAX issue.
# The good solution would be to configure gcc using --with-headers
fix_limits:
cat $(SOURCE_DIR)/gcc/limitx.h $(SOURCE_DIR)/gcc/glimits.h $(SOURCE_DIR)/gcc/limity.h > $(COMPIL_DIR)/gcc/include-fixed/limits.h