-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
Makefile.win
195 lines (158 loc) · 6.59 KB
/
Makefile.win
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
CC = $(CROSS)gcc
WINDRES = $(CROSS)windres
STRIP = $(CROSS)strip
# function to get absolute path to parent directory of a path
getparentdir = $(abspath $(dir $1))
# determine location of this Makefile
src_dir := $(call getparentdir, $(lastword $(MAKEFILE_LIST)))
# lookup for out-of-tree builds
VPATH := $(src_dir)
override CFLAGS := -c -Wall -Werror -MMD -DPDC_WIDE -D_XOPEN_SOURCE $(CFLAGS)
override CFLAGS += -include ../build-aux/config.h -D_FILE_OFFSET_BITS=64 -pipe
override CFLAGS += -pthread
ifeq ($(RELEASE),1)
override CFLAGS += -O2
else
override CFLAGS += -g -O0
endif
MANGEN := groff
UNDER_VCS := $(shell [ "`which git 2> /dev/null`" -a -d ../.git ] && echo 1)
LIBS := -lregex -lnetapi32 -lws2_32 -lm -lole32 -luuid
ifeq ($(OS),Windows_NT)
LIBS += -lpdcurses
else
# new versions of MXE name pdcurses this way
LIBS += -lcurses
endif
LDFLAGS := -pthread
DIRS := ./ compat/ cfg/ engine/ int/ io/ io/private/ menus/ modes/
DIRS += modes/dialogs/ ui/ utils/
cfg := config.c info.c
cfg := $(addprefix cfg/, $(cfg))
compat := curses.c dtype.c getopt.c getopt1.c os.c pthread.c reallocarray.c
compat += wcwidth.c
compat := $(addprefix compat/, $(compat))
engine := abbrevs.c autocmds.c cmds.c functions.c completion.c keys.c mode.c \
options.c parsing.c text_buffer.c var.c variables.c
engine := $(addprefix engine/, $(engine))
int := file_magic.c fuse.c path_env.c term_title.c vim.c
int := $(addprefix int/, $(int))
io := private/ioc.c private/ioe.c private/ioeta.c private/ionotif.c
io += private/traverser.c ioe.c ioeta.c iop.c ior.c
io := $(addprefix io/, $(io))
menus := apropos_menu.c bmarks_menu.c cabbrevs_menu.c colorscheme_menu.c \
commands_menu.c dirhistory_menu.c dirstack_menu.c filetypes_menu.c \
find_menu.c grep_menu.c history_menu.c jobs_menu.c locate_menu.c \
trash_menu.c trashes_menu.c map_menu.c marks_menu.c menus.c \
registers_menu.c undolist_menu.c users_menu.c vifm_menu.c \
volumes_menu.c
menus := $(addprefix menus/, $(menus))
dialogs := attr_dialog_win.c change_dialog.c msg_dialog.c sort_dialog.c
dialogs := $(addprefix dialogs/, $(dialogs))
modes := $(dialogs) cmdline.c file_info.c menu.c modes.c more.c normal.c \
view.c visual.c
modes := $(addprefix modes/, $(modes))
ui := cancellation.c color_manager.c color_scheme.c colored_line.c column_view.c
ui += escape.c fileview.c statusbar.c statusline.c tabs.c quickview.c ui.c
ui := $(addprefix ui/, $(ui))
utilities := cancellation.c dynarray.c env.c file_streams.c \
filemon.c filter.c fs.c fsdata.c fsddata.c fswatch_win.c globs.c \
gmux_win.c hist.c int_stack.c log.c matcher.c matchers.c parson.c \
path.c regexp.c selector_win.c shmem_win.c str.c string_array.c \
trie.c utf8.c utils.c utils_win.c
utilities := $(addprefix utils/, $(utilities))
vifm_SOURCES := $(cfg) $(compat) $(engine) $(int) $(io) $(menus) $(modes) \
$(ui) $(utilities) args.c background.c bmarks.c \
bracket_notation.c builtin_functions.c cmd_completion.c \
cmd_core.c cmd_handlers.c compare.c compile_info.c dir_stack.c \
event_loop.c filelist.c filename_modifiers.c fops_common.c \
fops_cpmv.c fops_misc.c fops_put.c fops_rename.c filetype.c \
filtering.c flist_hist.c flist_pos.c flist_sel.c instance.c \
ipc.c macros.c marks.c ops.c opt_handlers.c registers.c \
running.c search.c signals.c sort.c status.c tags.c trash.c \
types.c undo.c version.c viewcolumns_parser.c vifmres.o vifm.c
vifm_OBJECTS := $(vifm_SOURCES:.c=.o)
vifm_EXECUTABLE := vifm.exe
# determine list of output directories that don't exist at the moment
out_dirs := $(sort $(dir $(vifm_OBJECTS)))
out_dirs := $(filter-out $(wildcard $(out_dirs)) ./, $(out_dirs))
out_dirs := $(addprefix $(abspath .)/,$(out_dirs))
win_helper_SOURCES := win_helper.c
win_helper_OBJECTS := $(win_helper_SOURCES:.c=.o)
win_helper_EXECUTABLE := win_helper.exe
.PHONY: all clean check update_compile_info
all: ../data/vifm-help.txt $(vifm_EXECUTABLE) $(win_helper_EXECUTABLE)
$(vifm_EXECUTABLE): $(vifm_OBJECTS) | ../build-aux/config.h
$(CC) $^ -o $@ $(LDFLAGS) $(LIBS)
ifeq ($(RELEASE),1)
$(STRIP) -S --strip-unneeded $@
endif
$(win_helper_EXECUTABLE): $(win_helper_OBJECTS) | ../build-aux/config.h
$(CC) $^ -o $@ $(LDFLAGS)
ifeq ($(RELEASE),1)
$(STRIP) -S --strip-unneeded $@
endif
vifm.res: vifm.rc ../data/graphics/vifm.ico
$(WINDRES) --use-temp-file -i $(src_dir)/vifm.rc -o vifm.res
vifmres.o: vifm.res
$(WINDRES) --use-temp-file -i ./vifm.res -o vifmres.o
../build-aux/config.h:
@echo Creating sample $@
mkdir -p ../build-aux
echo '#define VERSION "0.11-beta"' > $@; \
echo '#define ENABLE_EXTENDED_KEYS' >> $@; \
echo '#define _GNU_SOURCE 1' >> $@; \
echo '#define PACKAGE_SYSCONF_DIR ""' >> $@; \
echo '#define ENABLE_REMOTE_CMDS 1' >> $@; \
echo '#define WITH_BUILD_TIMESTAMP 1' >> $@; \
echo '#define WINVER 0x0600' >> $@; \
echo '#define _WIN32_WINNT 0x0600' >> $@; \
# echo '#define HAVE_FILE_PROG' >> $@;
ifneq ($(OS),Windows_NT)
@echo '#define __USE_MINGW_ANSI_STDIO 1' >> $@
endif
version.o: $(filter-out version.o, $(vifm_OBJECTS))
compile_info.c: update_compile_info
@$(src_dir)/update-compile-info $(UNDER_VCS)
# No action needed for this target.
update_compile_info:
%.o: %.c | ../build-aux/config.h $(out_dirs)
$(CC) $(CFLAGS) $< -o $@
../data/vifm-help.txt: $(src_dir)/../data/man/vifm.1 | $(abspath ../data/)
@if [ "x$$(which $(MANGEN))" != "x" -a "x$$(which sed)" != "x" ]; then \
$(MANGEN) -Tascii -man $< | \
sed -e 's/.\x08//g' -e 's/\x1b\[[0-9]*m//g' -e 's/\r//g' >| '$@'; \
fi
tags.c: ../data/vim/doc/app/vifm-app.txt
@if [ "x$$(which vim)" != "x" -a "x$$(which awk)" != "x" ]; then \
vim -e -s -c 'helptags $(dir $<)|q'; \
awk ' \
BEGIN { \
print "const char *tags[] = {" \
} \
{ \
print "\t\"" $$1 "\"," \
} \
END { \
print "\t0,\n};" \
} \
' $(dir $<)/tags > $@; \
dos2unix "$@"; \
fi
$(out_dirs) $(abspath ../data/):
mkdir -p $@
# only builds tests without running them
tests: | ../build-aux/config.h $(vifm_EXECUTABLE)
mkdir -p "$(abspath ../tests)"
+make -C $(src_dir)/../tests/ B='$(abspath ../tests)/' CC='$(CC)' \
TEST_RUN_PREFIX='$(TEST_RUN_PREFIX)' build
# runs the tests, building them before if needed
check: tests
+make -C $(src_dir)/../tests/ B='$(abspath ../tests)/' CC='$(CC)' \
TEST_RUN_PREFIX='$(TEST_RUN_PREFIX)'
clean:
-$(RM) compile_info.c tags.c
-$(RM) $(addsuffix *.o, $(DIRS))
-$(RM) $(addsuffix *.d, $(DIRS))
-$(RM) *.res *.exe
include $(wildcard $(addsuffix *.d, $(DIRS)))