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
|
##
## Some make rules
##
# Beware: in releases, the Notion rules.mk is used to build both libtu,
# libextl and notion - so structural changes to this file should also be
# carried out on the Notion rules.mk
ifdef MODULE
ifeq ($(PRELOAD_MODULES),1)
MODULE_TARGETS := $(MODULE).a $(MODULE).lc
else
MODULE_TARGETS := $(MODULE).so $(MODULE).lc
endif
TARGETS := $(TARGETS) $(MODULE_TARGETS)
endif
ifdef LUA_SOURCES
LUA_COMPILED := $(subst .lua,.lc, $(LUA_SOURCES))
TARGETS := $(TARGETS) $(LUA_COMPILED)
endif
# Main targets
######################################
.PHONY: subdirs
.PHONY: subdirs-clean
.PHONY: subdirs-realclean
.PHONY: subdirs-install
.PHONY: _install
.PHONY: _exports
all: subdirs _exports $(TARGETS)
clean: subdirs-clean _clean
realclean: subdirs-realclean _clean _realclean
install: subdirs-install _install
# Exports
######################################
ifdef MAKE_EXPORTS
EXPORTS_C = exports.c
EXPORTS_H = exports.h
TO_CLEAN := $(TO_CLEAN) $(EXPORTS_C) $(EXPORTS_H)
_exports: $(EXPORTS_C)
# this funny syntax (more than one pattern-based target) is meant to tell Make
# that this rule makes BOTH of these targets. Look at the last paragraph of
# http://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html
%xports.c %xports.h:
$(MKEXPORTS) -module $(MAKE_EXPORTS) -o $(EXPORTS_C) -h $(EXPORTS_H) $(SOURCES)
else # !MAKE_EXPORTS
EXPORTS_C =
EXPORTS_H =
endif # !MAKE_EXPORTS
# Compilation and linking
######################################
OBJS=$(subst .c,.o,$(SOURCES) $(EXPORTS_C))
ifdef MODULE
ifneq ($(PRELOAD_MODULES),1)
CC_PICFLAGS=-fPIC -DPIC
LD_SHAREDFLAGS=-shared -Wl,-soname -Wl,$@
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_PICFLAGS) -c $< -o $@
$(MODULE).so: $(OBJS) $(EXT_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(LD_SHAREDFLAGS) $(OBJS) $(EXT_OBJS) -o $@ $(LIBS)
module_install: module_stub_install
$(INSTALLDIR) $(MODULEDIR)
$(INSTALL) $(INSTALL_STRIP) -m $(BIN_MODE) $(MODULE).so $(MODULEDIR)
else # PRELOAD_MODULES
PICOPT=-fPIC -DPIC
LINKOPT=-shared
$(MODULE).a: $(OBJS) $(EXT_OBJS)
$(AR) $(ARFLAGS) $@ $+
module_install: module_stub_install
endif # PRELOAD_MODULES
module_stub_install:
$(INSTALLDIR) $(LCDIR)
$(INSTALL) -m $(DATA_MODE) $(MODULE).lc $(LCDIR)
ifndef MODULE_STUB
$(MODULE).lc:
echo "ioncore.load_module('$(MODULE)')" | $(LUAC) -o $@ -
else
LUA_SOURCES += $(MODULE_STUB)
endif #MODULE_STUB
endif# !MODULE
# Clean rules
######################################
_clean:
$(RM) -f $(TO_CLEAN) core *.d $(OBJS)
_realclean:
$(RM) -f $(TO_REALCLEAN) $(TARGETS)
# Lua rules
######################################
%.lc: %.lua
$(LUAC) -o $@ $<
lc_install:
$(INSTALLDIR) $(LCDIR)
for i in $(LUA_COMPILED); do \
$(INSTALL) -m $(DATA_MODE) $$i $(LCDIR); \
done
etc_install:
$(INSTALLDIR) $(ETCDIR)
for i in $(ETC); do \
$(INSTALL) -m $(DATA_MODE) $$i $(ETCDIR); \
done
# Dependencies
######################################
CFLAGS += -MMD
-include *.d
# Subdirectories
######################################
ifdef SUBDIRS
subdirs:
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
subdirs-depend:
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i depend; done
subdirs-clean:
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
subdirs-realclean:
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done
subdirs-install:
set -e; for i in $(INSTALL_SUBDIRS); do $(MAKE) -C $$i install; done
endif
# Localisation
######################################
TO_CLEAN += potfiles_c potfiles_lua
_potfiles:
echo "$(SOURCES)"|tr ' ' '\n' > potfiles_c
echo "$(LUA_SOURCES) $(ETC)"|tr ' ' '\n' > potfiles_lua
|