-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathMakefile
More file actions
143 lines (112 loc) · 3.93 KB
/
Copy pathMakefile
File metadata and controls
143 lines (112 loc) · 3.93 KB
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
ifeq ($(MAKECMDGOALS),release)
.PHONY: release
release:
$(MAKE) PLATFORM=musl zip
$(MAKE) PLATFORM=musl appimage-zip
$(MAKE) PLATFORM=musl appimage-release
$(MAKE) PLATFORM=win32 zip
$(MAKE) PLATFORM=win64 zip
mkdir -p release
cp -t release _musl/*.zip _win32/*.zip _win64/*.zip _musl/*.AppImage
else ifeq ($(MAKECMDGOALS),clean-all)
.PHONY: clean-all
clean-all:
rm -rf release
$(MAKE) clean
$(MAKE) PLATFORM=musl clean
$(MAKE) PLATFORM=win32 clean
$(MAKE) PLATFORM=win64 clean
else ifeq (,$(filter _%,$(notdir $(CURDIR))))
include target.mk
else
VPATH = $(SRCDIR)
VERSION = 0.3.1
ifeq ($(PLATFORM),win32)
TARGET = doom-ascii.exe
CC = i686-w64-mingw32-gcc-win32
else ifeq ($(PLATFORM),win64)
TARGET = doom-ascii.exe
CC = x86_64-w64-mingw32-gcc-win32
else ifeq ($(PLATFORM),musl)
TARGET = doom-ascii
CC = musl-gcc
CFLAGS += -DNORMALUNIX -DLINUX -static
else
TARGET = doom-ascii
CFLAGS += -DNORMALUNIX -DLINUX
endif
TARGET_TRIPLE = $(subst -, ,$(shell $(CC) -dumpmachine))
ARCH = $(firstword $(TARGET_TRIPLE))
OS = $(word 2,$(TARGET_TRIPLE))
TARGETAPP = doom-ascii.AppImage
TARGETAPPREL = doom-ascii-$(VERSION)-$(ARCH).AppImage
TARGETZIP = doom-ascii-$(VERSION)-$(ARCH)-$(OS).zip
TARGETAPPZIP = $(TARGETAPPREL).zip
OBJDIR = obj
APPDIR = $(OBJDIR)/io.github.wojciech_graj.doom_ascii.AppDir
OUTDIR = game
APPOUTDIR = appimage
CFLAGS += -O3 -flto -Wall -D_DEFAULT_SOURCE -DVERSION=$(VERSION) -std=c99 #-DSNDSERV -DUSEASM
LDFLAGS += -flto
LIBS += -lm
ifndef NSIGN
APPFLAGS += --sign
endif
SRC = i_main.c dummy.c am_map.c doomdef.c doomstat.c dstrings.c d_event.c d_items.c d_iwad.c \
d_loop.c d_main.c d_mode.c d_net.c f_finale.c f_wipe.c g_game.c hu_lib.c hu_stuff.c info.c \
i_cdmus.c i_endoom.c i_joystick.c i_scale.c i_sound.c i_system.c i_timer.c memio.c m_argv.c \
m_bbox.c m_cheat.c m_config.c m_controls.c m_fixed.c m_menu.c m_misc.c m_random.c \
p_ceilng.c p_doors.c p_enemy.c p_floor.c p_inter.c p_lights.c p_map.c p_maputl.c p_mobj.c \
p_plats.c p_pspr.c p_saveg.c p_setup.c p_sight.c p_spec.c p_switch.c p_telept.c p_tick.c \
p_user.c r_bsp.c r_data.c r_draw.c r_main.c r_plane.c r_segs.c r_sky.c r_things.c sha1.c \
sounds.c statdump.c st_lib.c st_stuff.c s_sound.c tables.c v_video.c wi_stuff.c \
w_checksum.c w_file.c w_main.c w_wad.c z_zone.c w_file_stdc.c i_input.c i_video.c \
doomgeneric.c doomgeneric_ascii.c
OBJS = $(SRC:%.c=$(OBJDIR)/%.o)
OBJSAPP = $(APPDIR)/usr/bin/$(TARGET) $(APPDIR)/AppRun $(APPDIR)/io.github.wojciech_graj.doom_ascii.desktop $(APPDIR)/io.github.wojciech_graj.doom_ascii.png $(APPDIR)/usr/share/metainfo/io.github.wojciech_graj.doom_ascii.appdata.xml
.PHONY: all
all: $(OUTDIR)/$(TARGET) $(OUTDIR)/.default.cfg
.PHONY: appimage
appimage: $(APPOUTDIR)/$(TARGETAPP) $(APPOUTDIR)/.default.cfg
.PHONY: appimage-release
appimage-release: $(TARGETAPPREL)
.PHONY: zip
zip: $(TARGETZIP)
.PHONY: appimage-zip
appimage-zip: $(TARGETAPPZIP)
$(OBJDIR)/$(TARGETAPP): $(OBJSAPP)
@mkdir -p $(@D)
appimagetool $(APPDIR) $@ $(APPFLAGS)
$(APPDIR)/AppRun:
@mkdir -p $(@D)
ln -s usr/bin/doom-ascii $@
$(OBJDIR)/$(TARGET): $(OBJS)
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(TARGETAPPREL): $(OBJDIR)/$(TARGETAPP)
cp $< $@
define copy_rule
$1/%: $2/%
@mkdir -p $$(@D)
cp $$< $$@
endef
$(eval $(call copy_rule,$(OUTDIR),$(OBJDIR)))
$(eval $(call copy_rule,$(OUTDIR),$(SRCDIR)))
$(eval $(call copy_rule,$(APPDIR),$(SRCDIR)/AppDir))
$(eval $(call copy_rule,$(APPDIR)/usr/share/metainfo,$(SRCDIR)/AppDir))
$(eval $(call copy_rule,$(APPDIR)/usr/bin,$(OBJDIR)))
$(eval $(call copy_rule,$(APPOUTDIR),$(SRCDIR)))
$(eval $(call copy_rule,$(APPOUTDIR),$(OBJDIR)))
define zip_rule
$1: $(OBJDIR)/$2 ../README.md ../LICENSE $(SRCDIR)/.default.cfg
$$(eval $$@_TMP := $$(shell mktemp -d))
cp -t $$($$@_TMP) $$^
zip -r -j $$@ $$($$@_TMP)
rm -rf $$($$@_TMP)
endef
$(eval $(call zip_rule,$(TARGETZIP),$(TARGET)))
$(eval $(call zip_rule,$(TARGETAPPZIP),$(TARGETAPP)))
endif