-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
133 lines (104 loc) · 3.3 KB
/
Makefile.in
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
#
# Copyright (C) 2009-2013 Przemyslaw Pawelczyk <[email protected]>
#
# This software is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2.
# See <http://www.gnu.org/licenses/gpl-2.0.txt>.
#
# This software is distributed in the hope that it will be useful, but
# WITHBIN ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
NAME := vidma
DOCS := AUTHORS NEWS README.md
OBJS := main.o vdi.o ui-cli.o
MAN1 := $(NAME).1
BIN := $(NAME)
LDLIBS :=
HOST :=
TARGET_ARCH :=
ifneq (,$(HOST))
CROSS_COMPILE ?= $(HOST)-
endif
ifeq ($(CC),)
CC := gcc
endif
CC := $(CROSS_COMPILE)$(CC)
CCLD := $(CC)
STRIP := $(CROSS_COMPILE)strip
CC_V := $(shell $(CC) -v 2>&1)
CC_PARAMS = $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH)
SYSDEFINES_CMD := $(CC) $(CC_PARAMS) -E -dM -x c /dev/null
ifeq ($(shell $(SYSDEFINES_CMD) | sed '/^.define \<_WIN32\> /!d;s///'),1)
OBJS += common_win.o
LDLIBS += -lntdll
BIN := $(addsuffix .exe,$(BIN))
else
OBJS += common_posix.o
endif
SRCDIR := $(dir $(lastword $(MAKEFILE_LIST)))
NOT_IN_SRCDIR := $(shell test ! . -ef $(SRCDIR) && echo 1)
GIT_WORK_TREE := $(SRCDIR)
VIDMA_VERSION := $(shell \
GIT_WORK_TREE="$(GIT_WORK_TREE)" git describe --tags --dirty 2>/dev/null || \
awk "/\* What's new in version /"'{print "v" $$6 ((NR!=1)?"+":"");exit}' $(SRCDIR)/NEWS 2>/dev/null || \
echo unknown )
OPTIONAL_FLAGS := -O2
MANDATORY_FLAGS := -ggdb -Wall -std=c99 -Wno-variadic-macros \
-D_FILE_OFFSET_BITS=64 -D_XOPEN_SOURCE=600 \
-DVIDMA_VERSION="\"$(VIDMA_VERSION)\""
comma := ,
CFLAGS += $(OPTIONAL_FLAGS)
override CFLAGS += $(MANDATORY_FLAGS)
CPPFLAGS +=
override LDFLAGS := $(subst -Wl$(comma),,$(LDFLAGS))
override LDFLAGS := $(subst $(comma), ,$(LDFLAGS))
LDFLAGS +=
CCLDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
PREFIX := /usr/local
EPREFIX := $(PREFIX)
BINDIR := $(EPREFIX)/bin
DATADIR := $(PREFIX)/share
DOCDIR := $(DATADIR)/doc/$(NAME)
MANDIR := $(DATADIR)/man
INSTALL := install
INSTALL_DATA := $(INSTALL) -m 0644
INSTALL_EXEC := $(INSTALL) -m 0755
vpath %.c $(SRCDIR)
vpath %.h $(SRCDIR)
vpath %.ronn $(SRCDIR)
all: $(BIN)
main.o: FORCE main.c vdi.h ui.h common.h
vdi.o: vdi.c vdi.h vd.h ui.h common.h
ui-cli.o: ui-cli.c ui.h common.h
%.o: %.c
$(CC) $(CC_PARAMS) -c -o $@ $<
$(BIN): $(OBJS)
$(CCLD) $(CCLDFLAGS) $(TARGET_ARCH) -o $@ $(OBJS) $(LDLIBS)
%.1: %.1.ronn
$(if $(shell test -n "$(NOT_IN_SRCDIR)" -a -f $(basename $<) -a ! $(basename $<) -ot $< && echo yes) , \
cp $(basename $<) $@ , \
ronn --pipe -r $< >$@ \
)
%.1.html: %.1.ronn
ronn -5 --pipe --style=toc $< >$@
clean:
$(RM) $(BIN) $(OBJS) $(if $(NOT_IN_SRCDIR),$(MAN1))
distclean: clean
$(RM) Makefile $(MAN1).html
install: $(BIN) $(MAN1)
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL_EXEC) $(BIN) $(DESTDIR)$(BINDIR)/$(BIN)
$(INSTALL) -d $(DESTDIR)$(MANDIR)/man1
$(INSTALL_DATA) $(SRCDIR)/$(MAN1) $(DESTDIR)$(MANDIR)/man1/$(MAN1)
$(INSTALL) -d $(DESTDIR)$(DOCDIR)
$(INSTALL_DATA) $(addprefix $(SRCDIR)/,$(DOCS)) $(DESTDIR)$(DOCDIR)
strip: $(BIN)
$(STRIP) $^
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/$(BIN)
$(RM) -r $(DESTDIR)$(DOCDIR)
$(RM) $(DESTDIR)$(MANDIR)/man1/$(MAN1)
FORCE:
.PHONY: all clean distclean install strip uninstall