# General defines version := 1.5.0pre # this WILL NOT WORK for you. only inhouse patched version of # sapphire will omit enciphering code when set legalexport := yes ##### Customizable stuff. Set it how you like it ##### # compiler CC = gcc need_local_regex := no # shared library- set to yes if you would like to build buildshare := yes # VCL library- set to yes if you would like to build buildvcl := yes # Debugging options etc... debug := yes profile := no # endian, etc. support for other hardware system := intel #system := sparc # ownership (used by 'make install') user := root group := root # paths instdir := /usr bindir := ${instdir}/bin libdir := ${instdir}/lib hdir := ${instdir}/include/sword docdir := ${instdir}/doc/sword #------------------------------------------------------------------------------# # You shouldn't need to change anything below here. objdir := ${root}/obj ##### System specific stuff ##### WARNINGS = -Wall -Wno-format #WARNINGS += -Werror CFLAGS = -pipe $(WARNINGS) $(DEBUG) CPPFLAGS = -I${root}/include/ $(DEFINES) LFLAGS = $(OPTIMIZE) $(DEBUG) -L${root}/lib/ LIBS = -lsword -lstdc++ -lz LDFLAGS = $(LFLAGS) $(LIBS) DEFINES = -D_GNU_SOURCE ifeq ($(profile),yes) CC += -pg else CFLAGS += -fomit-frame-pointer endif ifeq ($(debug),yes) CFLAGS += -ggdb -O0 else CFLAGS += -s -O3 DEFINES += -DNDEBUG 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 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< %.o: %.cpp $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< else %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CC) $(CPPFLAGS) -fpic -shared $(CFLAGS) -c -o `basename $@ .o`.so $< mv `basename $@ .o`.so ${objdir} %.o: %.cpp $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CC) $(CPPFLAGS) -fpic -shared $(CFLAGS) -c -o `basename $@ .o`.so $< mv `basename $@ .o`.so ${objdir} endif else %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< %.o: %.cpp $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< endif %: %.cpp $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) ifeq (${clean-targets},) clean-targets = ${targets} endif # Rules to generate dependancies define run-depend $(SHELL) -ec '$(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 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