# General defines version := 1.5.2 # ownership (used by 'make install') user := root group := root # this WILL NOT WORK for you. only inhouse patched version of # sapphire will omit enciphering code when set to yes, so leave # as no, unless you really know what you're doing legalexport := no ##### Customizable stuff. Set it how you like it ##### # compiler CROSS_COMPILE = CC = gcc need_local_regex := no # shared library- set to yes if you would like to build buildshare := no # VCL library- set to yes if you would like to build buildvcl := no # Debugging options etc... debug := no profile := no # endian, etc. support for other hardware system := intel #system := sparc #system := macosx #system := arm ## MAC OSX Support works but possible bug exists in /usr/include/sys/dirent.h ## on the current version (B) of OSX. You will need to add this line right after the #ifdef of DIRENT #include # zLib support zlib := yes # paths instdir := /usr bindir := ${instdir}/bin libdir := ${instdir}/lib hdir := ${instdir}/include/sword docdir := ${instdir}/doc/sword confdir := ${instdir}/share/sword #------------------------------------------------------------------------------# # You shouldn't need to change anything below here. objdir := ${root}/obj ##### System specific stuff ##### WARNINGS = -Wall -Wno-format -pedantic #WARNINGS += -Werror WARNINGS += -pedantic CFLAGS = -pipe $(WARNINGS) $(DEBUG) CPPFLAGS = -I${root}/include/ $(DEFINES) ifeq ($(system),macosx) CPPFLAGS += -I/System/Library/Frameworks/System.framework/Headers/ endif CPPFLAGS += $(DEFINES) LFLAGS = $(OPTIMIZE) $(DEBUG) -L${root}/lib/ LIBS = -lsword -lstdc++ ifeq ($(zlib),no) CFLAGS += -DEXCLUDEZLIB else LIBS += -lz endif LDFLAGS = $(LFLAGS) $(LIBS) DEFINES = -D_GNU_SOURCE ifeq ($(profile),yes) CFLAGS += -pg else CFLAGS += -fomit-frame-pointer endif ifeq ($(debug),yes) CFLAGS += -ggdb -O0 else ifeq ($(profile),yes) CFLAGS += -O3 else CFLAGS += -s -O3 endif DEFINES += -DNDEBUG endif ifeq ($(system),macosx) CFLAGS += -DBIGENDIAN -DMACOSX endif ifeq ($(system),arm) CROSS_COMPILE = arm-linux- LIBS += -L/skiff/local/lib -L/skiff/local/arm-linux/lib -L/skiff/local/arm-linux/lib/X11 endif ifeq ($(system),sparc) CFLAGS += -DBIGENDIAN endif ifeq ($(legalexport),no) CFLAGS += -DUSBINARY endif ifeq ($(system),intel) CFLAGS += -m486 endif ifeq ($(buildvcl),yes) ifeq ($(root),.) subdirs += apps/X11/VCL endif endif subdir_targets := clean install dist pre targets .PHONY: $(foreach target,${subdir_targets},just-$(target) subdir-$(target) $(target)) .PHONY: all uninstall cp # Primary target default: all # Set up -D flags based on config # Compilation rules ifeq (${buildshare},yes) ifneq (${bin},) %.o: %.c $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< %.o: %.cpp $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< else %.o: %.c $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CROSS_COMPILE)$(CC) $(CPPFLAGS) -fpic -shared $(CFLAGS) -c -o `basename $@ .o`.so $< mv `basename $@ .o`.so ${objdir} %.o: %.cpp $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CROSS_COMPILE)$(CC) $(CPPFLAGS) -fpic -shared $(CFLAGS) -c -o `basename $@ .o`.so $< mv `basename $@ .o`.so ${objdir} endif else %.o: %.c $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< %.o: %.cpp $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< endif %: %.cpp $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) %: %.c $(CROSS_COMPILE)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) ifeq (${clean-targets},) clean-targets = ${targets} endif # Rules to generate dependancies define run-depend $(SHELL) -ec '$(CROSS_COMPILE)$(CC) -MM -MG $(CPPFLAGS) $< | sed '\''s/$*\.o/& $@/g'\'' > $@' endef %.d: %.c ${run-depend} %.d: %.cpp ${run-depend} # Subdirectory rules $(foreach dir,${subdirs},$(foreach target,${subdir_targets},$(dir)/$(target))): ${MAKE} -C $(@D) just-$(@F) $(foreach target,${subdir_targets},subdir-$(target)): subdir-%: $(foreach dir,${subdirs},$(dir)/%) # all target all: pre just-targets # targets target just-targets: subdir-targets ${targets} targets: ${MAKE} just-targets nodeps=no # pre target just-pre: subdir-pre ${pre-targets} pre: ${MAKE} just-pre nodeps=yes # clean target just-clean: subdir-clean rm -f *.mbr *.mbt *.a *.so *.exe *.lib *.dsm *.bak *.obj *.obr *.rws *.apx *.dof *.dcu *.tr *.trw *.ils *.ilf *.ilc *.ild *.tds *.mrt *.dsw *.csm *.o *~ *.*~ *.~* *.s *.tga *.anim *.spr errlist core ${pre-targets} ${clean-targets} rm -rf .deps rm -f `ls -d *.d|grep -v locales.d` clean: ${MAKE} just-clean nodeps=yes # install_config target install_config: @echo "" @echo "" @echo "****" @echo "****" @echo "Be sure directory, user, group, etc. preferences are correct in Makefile.cfg" @echo "****" @echo "****" @echo "" ifneq (${confdir},) @if [ ! -d ${confdir}/mods.d ]; then install -o ${user} -g ${group} -m a+rx,u+rxw -d ${confdir}/mods.d/ ; fi @if [ ! -d ${confdir}/locales.d ]; then install -o ${user} -g ${group} -m a+rx,u+rxw -d ${confdir}/locales.d/ ; fi @echo "[Install]" > /etc/sword.conf @echo "DataPath=${confdir}" >> /etc/sword.conf # install -o ${user} -g ${group} -m a+r,u+rw samples/recommended/sword.conf /etc/ install -o ${user} -g ${group} -m a+r,u+rw ${modsconf} ${confdir}/mods.d/ install -o ${user} -g ${group} -m a+r,u+rw ${localesconf} ${confdir}/locales.d/ endif # install target just-install: subdir-install ifneq (${install-dir},) @if [ ! -f ${install-dir} ]; then install -o ${user} -g ${group} -m a+rx,u+rxw -d ${install-dir}/ ; fi install -o ${user} -g ${group} -m a+r,u+rw ${install-targets} ${install-dir} endif ifneq (${bin},) @if [ ! -d ${bindir} ]; then install -o ${user} -g ${group} -m a+rx,u+rxw -d ${bindir}/ ; fi @if [ -f ${bin} ]; then install -o ${user} -g ${group} -m a+rx,u+rws -s ${bin} ${bindir}/ ; fi endif ifneq (${lib},) @if [ ! -d ${libdir} ]; then install -o ${user} -g ${group} -m a+rx,u+rxw -d ${libdir}/ ; fi install -o ${user} -g ${group} -m a+r,u+rw ${lib} ${libdir}/ ifeq (${buildshare},yes) install -o ${user} -g ${group} -m a+rx,u+rwx ${libshare} ${libdir}/ endif endif ifneq (${docs},) @if [ ! -d ${docdir}/samples/mods.d ]; then install -o ${user} -g ${group} -m a+rx,u+rxw -d ${docdir}/samples/mods.d/ ; fi install -o ${user} -g ${group} -m a+r,u+rw ${docs} ${docdir}/ install -o ${user} -g ${group} -m a+r,u+rw ${docssamples} ${docdir}/samples/ install -o ${user} -g ${group} -m a+r,u+rw ${docssmodsd} ${docdir}/samples/mods.d/ endif ifneq (${headers},) @if [ ! -d ${hdir} ]; then install -o ${user} -g ${group} -m a+rx,u+rxw -d ${hdir}/ ; fi install -o ${user} -g ${group} -m a+r,u+rw ${headers} ${hdir}/ endif ifeq (${other-install},yes) ${MAKE} other-install endif install: pre targets ${MAKE} just-install nodeps=yes # dist target ifeq (${other-dist},yes) just-dist: subdir-dist other-dist else just-dist: subdir-dist endif ifneq (${install-dir},) install -o ${user} -g ${group} -m a+rx,u+rxw -d /tmp/swordbin${libdir}/${install-dir}/ install -o ${user} -g ${group} -m a+r,u+rw ${install-targets} /tmp/swordbin${libdir}/${install-dir}/ endif ifneq (${bin},) install -o ${user} -g ${group} -m a+rx,u+rxw -d /tmp/swordbin${bindir}/ install -o ${user} -g ${group} -m a+rx,u+rwx -s ${bin} /tmp/swordbin${bindir}/ endif dist: pre targets rm -rf /tmp/sword && mkdir -p /tmp/sword ${MAKE} just-dist nodeps=yes cd /tmp/sword && tar czf /tmp/sword-${version}.bin.tgz * mv /tmp/sword-${version}.bin.tgz ./ rm -rf /tmp/sword