-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
164 lines (126 loc) · 4.27 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
154
155
156
157
158
159
160
161
162
# Generic GNU Makefile with Native Language Support
# written by Henrik Carlqvist
#
# Possible targets are:
# make normal compile
# make all normal compile, the same as above
# make install installs compiled files
# make uninstall removes installed files
# make clean removes compiled files
# make mrproper removes compiled files and dependencies
# make debug compiles with flag -g for debuggers
# make messages creates po/messages.po as a skeleton for NLS
#
# Contributors: Henrik Carlqvist
# Alon Bar-Lev
# Name of program, compiled executable file
PACKAGE = ms-sys
# Add anything extra you might need when comipiling below
# Example: EXTRA_CFLAGS = -D MY_DEFINE=1
# The row below is a workaround for systems which lack libintl.h
EXTRA_CFLAGS = -idirafter include-fallback -D_FILE_OFFSET_BITS=64
# Add anything extra you might need when linking below
# Example: EXTRA_LDFLAGS = -lm
EXTRA_LDFLAGS =
# Paths
# Installation path
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
LOCALEDIR = $(PREFIX)/share/locale
MANDIR = $(PREFIX)/man
# Where your .c-files live
SRC = src
# Where your .h-files live
INC = inc
# Where .d-files will be created for dependencies
DEP = dep
# Where any .po-files live for native language support, eg sv_SE.po or de_DE.po
# A skeleton .po-file could be created by "make messages"
PO = po
# Where your man-pages live
MAN = man
# Where .mo-files will be created
MO = mo
# Where .o-files will be created
OBJ = obj
# Where your program will be created before installation
BIN = bin
# There is no need to change anything below this line
#***********************************************************************
# Used for Native Language Support, do not change!
MESSDIR = LC_MESSAGES
INCDIRS = $(INC)
CC ?= gcc
INCLUDES = $(INCDIRS:%=-I %)
CFLAGS ?= -O2
ifeq ($(MAKECMDGOALS),debug)
CFLAGS ?= -g
endif
CFLAGS += -ansi -pedantic -Wall -c $(INCLUDES) \
-D PACKAGE=\"$(PACKAGE)\" -D LOCALEDIR=\"$(LOCALEDIR)\" \
$(EXTRA_CFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)
SRC_FILES = $(wildcard $(SRC)/*.c)
INC_FILES = $(wildcard $(INC)/*.h)
MESSAGES = $(PO)/messages.po
MAN_SRC = $(wildcard $(MAN)/*.* $(MAN)/??/*.*)
PO_FILES = $(filter-out $(MESSAGES),$(wildcard $(PO)/*.po))
MO_FILES = $(PO_FILES:$(PO)/%.po=$(MO)/%.mo)
LANGUAGES ?= $(PO_FILES:$(PO)/%.po=%)
NLS_FILES = $(LANGUAGES:%=$(DESTDIR)$(LOCALEDIR)/%/$(MESSDIR)/$(PACKAGE).mo)
MAN_FILES = $(foreach FILE, $(MAN_SRC), \
$(DESTDIR)$(subst $(MAN),$(MANDIR),$(dir $(FILE)))man$(subst .,,$(suffix $(FILE)))/$(notdir $(FILE)))
FILES = $(SRC_FILES:$(SRC)/%.c=%)
OBJS = $(FILES:%=$(OBJ)/%.o)
DEPS = $(FILES:%=$(DEP)/%.d)
all debug: $(BIN)/$(PACKAGE) $(MO_FILES)
install: $(DESTDIR)$(BINDIR)/$(PACKAGE) $(NLS_FILES) $(MAN_FILES)
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/$(PACKAGE) $(NLS_FILES) $(MAN_FILES)
messages: $(MESSAGES)
mrproper: clean
$(RM) $(DEP)/*.d
$(RM) $(OS_CHECK)
clean:
$(RM) $(MESSAGES)
$(RM) $(MO)/*.mo
$(RM) $(OBJ)/*.o
$(RM) $(LIB)/*.a
$(RM) $(filter-out $(BIN)/CVS,$(wildcard $(BIN)/*))
$(DESTDIR)$(BINDIR)/%: $(BIN)/%
install -D -m 755 $^ $@
$(DESTDIR)$(LOCALEDIR)/%/$(MESSDIR)/$(PACKAGE).mo: $(MO)/%.mo
mkdir -p $(DESTDIR)$(LOCALEDIR)/$*/$(MESSDIR)
install -D -m 644 $^ $@
$(DESTDIR)$(MANDIR)/%: $(MAN)/$(dir $(*D))/$(*F)
install -D -m 644 $(MAN)/$(dir $(*D))$(*F) $@
gzip -f $@
#$(DESTDIR)$(MANDIR)/%: $(MAN)/$(*F)
# echo t: $<
# install -D -m 644 $(MAN)/$(*F) $@
$(BIN)/%: $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
$(MESSAGES): $(SRC_FILES) $(INC_FILES)
xgettext -k_ -o$@ $^
$(OBJS): $(OBJ)/%.o: $(SRC)/%.c $(DEP)/%.d \
$(filter-out $(wildcard $(OBJ)), $(OBJ)) \
$(filter-out $(wildcard $(BIN)), $(BIN))
$(CC) $(CFLAGS) -o $@ $<
$(MO_FILES): $(MO)/%.mo: $(PO)/%.po $(filter-out $(wildcard $(MO)), $(MO))
msgfmt -o $@ $<
$(DEPS): $(DEP)/%.d: $(SRC)/%.c $(filter-out $(wildcard $(DEP)), $(DEP))
ifeq ($(MAKECMDGOALS),quiet)
@$(CC) -MM $(CFLAGS) -MT $@ $< > $@
else
$(CC) -MM $(CFLAGS) -MT $@ $< > $@
endif
ifneq ($(MAKECMDGOALS),mrproper)
ifneq ($(wildcard $(DEPS)),)
include $(wildcard $(DEPS))
endif
endif
# Create directories which might be lost from CVS
$(DEP) $(OBJ) $(BIN) $(MO):
mkdir -p $@
# Used to force some rules to always be compiled
FORCE: ;