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
|
# 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
# 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
# Add anything extra you might need when linking below
# Example: EXTRA_LDFLAGS = -lm
EXTRA_LDFLAGS =
# Paths
# Installation path
PREFIX = $(DESTDIR)/usr
BINDIR = $(PREFIX)/bin
LOCALEDIR = $(PREFIX)/share/locale
MANDIR = $(PREFIX)/share/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 -ansi -pedantic -Wall -c $(INCLUDES) \
-D PACKAGE=\"$(PACKAGE)\" -D LOCALEDIR=\"$(LOCALEDIR)\" \
$(EXTRA_CFLAGS)
ifeq ($(MAKECMDGOALS),debug)
CFLAGS = -g -ansi -pedantic -Wall -c $(INCLUDES) \
-D PACKAGE=\"$(PACKAGE)\" -D LOCALEDIR=\"$(LOCALEDIR)\" \
$(EXTRA_CFLAGS)
endif
LDFLAGS = $(EXTRA_LDFLAGS)
SRC_FILES = $(wildcard $(SRC)/*.c)
INC_FILES = $(wildcard $(INC)/*.h)
MESSAGES = $(PO)/messages.po
MAN_SRC = $(wildcard $(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:%=$(LOCALEDIR)/%/$(MESSDIR)/$(PACKAGE).mo)
MAN_FILES = $(foreach FILE, $(MAN_SRC), \
$(MANDIR)/man$(subst .,,$(suffix $(FILE)))/$(FILE:$(MAN)/%=%))
FILES = $(SRC_FILES:$(SRC)/%.c=%)
OBJS = $(FILES:%=$(OBJ)/%.o)
DEPS = $(FILES:%=$(DEP)/%.d)
all debug: $(BIN)/$(PACKAGE) $(MO_FILES)
install: $(BINDIR)/$(PACKAGE) $(NLS_FILES) $(MAN_FILES)
uninstall:
$(RM) $(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)/*))
$(BINDIR)/%: $(BIN)/%
install -D -m 755 $^ $@
$(LOCALEDIR)/%/$(MESSDIR)/$(PACKAGE).mo: $(MO)/%.mo
mkdir -p $(LOCALEDIR)/$*/$(MESSDIR)
install -D -m 644 $^ $@
$(MANDIR)/%: $(MAN)/$(*F)
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
$(CC) $(CFLAGS) -o $@ $<
$(MO_FILES): $(MO)/%.mo: $(PO)/%.po
msgfmt -o $@ $<
$(DEPS): $(DEP)/%.d: $(SRC)/%.c
ifeq ($(MAKECMDGOALS),quiet)
@if((printf "$@ $(OBJ)/";$(CC) -MM $(CFLAGS) $< )> $@); then true; \
else rm $@; false; fi
else
if((printf "$@ $(OBJ)/";$(CC) -MM $(CFLAGS) $< )> $@); then true; \
else rm $@; false; fi
endif
ifneq ($(MAKECMDGOALS),mrproper)
ifneq ($(wildcard $(DEPS)),)
include $(wildcard $(DEPS))
endif
endif
# Used to force some rules to always be compiled
FORCE: ;
|