Skip to content

Commit

Permalink
Add support for building MorphOS libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Midar committed Jul 8, 2017
1 parent 060bcd3 commit 365fe57
Showing 1 changed file with 100 additions and 15 deletions.
115 changes: 100 additions & 15 deletions buildsys.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,21 @@ OBJS11 = ${OBJS10:.S=.o}
OBJS += ${OBJS11:.xpm=.o}

LIB_OBJS = ${OBJS:.o=.lib.o}
MORPHOS_LIB_OBJS = ${OBJS:.o=.moslib.o}
PLUGIN_OBJS = ${OBJS:.o=.plugin.o}

MO_FILES = ${LOCALES:.po=.mo}

.SILENT:
.SUFFIXES:
.SUFFIXES: .beam .c .c.dep .cc .cc.dep .class .cxx .cxx.dep .d .erl .lib.o .java .mo .m .m.dep .mm .mm.dep .o .plugin.o .po .py .pyc .rc .S .S.dep .xpm
.SUFFIXES: .beam .c .c.dep .cc .cc.dep .class .cxx .cxx.dep .d .erl .lib.o .java .mo .m .m.dep .mm .mm.dep .moslib.o .o .plugin.o .po .py .pyc .rc .S .S.dep .xpm
.PHONY: all subdirs subdirs-after pre-depend depend install install-extra uninstall uninstall-extra clean distclean locales ${SUBDIRS} ${SUBDIRS_AFTER}

all:
${MAKE} pre-all
${MAKE} subdirs
${MAKE} depend
${MAKE} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${PROG} ${PROG_NOINST} ${JARFILE} locales
${MAKE} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${MORPHOS_LIB} ${MORPHOS_LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${PROG} ${PROG_NOINST} ${JARFILE} locales
${MAKE} subdirs-after
${MAKE} post-all

Expand Down Expand Up @@ -187,27 +188,27 @@ depend: pre-depend ${SRCS}

.c.c.dep:
${CPP} ${CPPFLAGS} ${CFLAGS} -M $< | \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.plugin.o:/' >$@ || \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.moslib.o \1.plugin.o:/' >$@ || \
{ rm -f $@; false; }

.cc.cc.dep .cxx.cxx.dep:
${CPP} ${CPPFLAGS} ${CXXFLAGS} -M $< | \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.plugin.o:/' >$@ || \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.moslib.o \1.plugin.o:/' >$@ || \
{ rm -f $@; false; }

.m.m.dep:
${CPP} ${CPPFLAGS} ${OBJCFLAGS} -M $< | \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.plugin.o:/' >$@ || \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.moslib.o \1.plugin.o:/' >$@ || \
{ rm -f $@; false; }

.mm.mm.dep:
${CPP} ${CPPFLAGS} ${OBJCXXFLAGS} -M $< | \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.plugin.o:/' >$@ || \
${CPP} ${CPPFLAGS} ${OBJCPPFLAGS} -M $< | \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.moslib.o \1.plugin.o:/' >$@ || \
{ rm -f $@; false; }

.S.S.dep:
${CPP} ${CPPFLAGS} ${ASFLAGS} -M $< | \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.plugin.o:/' >$@ || \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.moslib.o \1.plugin.o:/' >$@ || \
{ rm -f $@; false; }

pre-depend:
Expand Down Expand Up @@ -273,6 +274,42 @@ ${SHARED_LIB} ${SHARED_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA}
rm -fr $$dir; \
done

${MORPHOS_LIB} ${MORPHOS_LIB_NOINST}: ${EXT_DEPS} ${MORPHOS_LIB_OBJS} ${MORPHOS_LIB_OBJS_EXTRA}
${LINK_STATUS}
out="$@"; \
objs=""; \
ars=""; \
for i in ${MORPHOS_LIB_OBJS} ${MORPHOS_LIB_OBJS_EXTRA}; do \
case $$i in \
*.a) \
ars="$$ars $$i" \
;; \
*.o) \
objs="$$objs $$i" \
;; \
esac \
done; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
mkdir -p $$dir; \
cd $$dir; \
${AR} x ../$$i; \
for j in *.o; do \
objs="$$objs $$dir/$$j"; \
done; \
cd ..; \
done; \
if ${LD} -o $@ $$objs -nostartfiles ${LDFLAGS} ${LIBS}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
done

${PLUGIN} ${PLUGIN_NOINST}: ${EXT_DEPS} ${PLUGIN_OBJS}
${LINK_STATUS}
out="$@"; \
Expand Down Expand Up @@ -405,6 +442,15 @@ locales: ${MO_FILES}
else \
${COMPILE_LIB_FAILED}; \
fi
.c.moslib.o:
${COMPILE_MOSLIB_STATUS}
in="$<"; \
out="$@"; \
if ${CC} -mbaserel32 ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$@} -c -o $@ $<; then \
${COMPILE_MOSLIB_OK}; \
else \
${COMPILE_MOSLIB_FAILED}; \
fi
.c.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
Expand Down Expand Up @@ -433,6 +479,15 @@ locales: ${MO_FILES}
else \
${COMPILE_LIB_FAILED}; \
fi
.cc.moslib.o .cxx.moslib.o:
${COMPILE_MOSLIB_STATUS}
in="$<"; \
out="$@"; \
if ${CXX} -mbaserel32 ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$@} -c -o $@ $<; then \
${COMPILE_MOSLIB_OK}; \
else \
${COMPILE_MOSLIB_FAILED}; \
fi
.cc.plugin.o .cxx.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
Expand Down Expand Up @@ -499,6 +554,15 @@ locales: ${MO_FILES}
else \
${COMPILE_LIB_FAILED}; \
fi
.m.moslib.o:
${COMPILE_MOSLIB_STATUS}
in="$<"; \
out="$@"; \
if ${OBJC} -mbaserel32 ${OBJCFLAGS} ${CPPFLAGS} ${OBJCFLAGS_$@} -c -o $@ $<; then \
${COMPILE_MOSLIB_OK}; \
else \
${COMPILE_MOSLIB_FAILED}; \
fi
.m.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
Expand All @@ -513,7 +577,7 @@ locales: ${MO_FILES}
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} ${OBJCXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$@} -c -o $@ $<; then \
if ${OBJCXX} ${OBJCXXFLAGS} ${OBJCFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$@} -c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
Expand All @@ -522,16 +586,25 @@ locales: ${MO_FILES}
${COMPILE_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} ${LIB_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$@} -c -o $@ $<; then \
if ${OBJCXX} ${LIB_CFLAGS} ${OBJCXXFLAGS} ${OBJCFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$@} -c -o $@ $<; then \
${COMPILE_LIB_OK}; \
else \
${COMPILE_LIB_FAILED}; \
fi
.mm.moslib.o:
${COMPILE_MOSLIB_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} -mbaserel32 ${OBJCXXFLAGS} ${OBJCFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$@} -c -o $@ $<; then \
${COMPILE_MOSLIB_OK}; \
else \
${COMPILE_MOSLIB_FAILED}; \
fi
.mm.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} ${PLUGIN_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$@} -c -o $@ $<; then \
if ${OBJCXX} ${PLUGIN_CFLAGS} ${OBJCXXFLAGS} ${OBJCFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$@} -c -o $@ $<; then \
${COMPILE_PLUGIN_OK}; \
else \
${COMPILE_PLUGIN_FAILED}; \
Expand Down Expand Up @@ -567,14 +640,14 @@ locales: ${MO_FILES}
${COMPILE_FAILED}; \
fi

.S.o:
${COMPILE_STATUS}
.S.o .S.moslib.o:
${COMPILE_MOSLIB_STATUS}
in="$<"; \
out="$@"; \
if ${AS} ${ASFLAGS} ${CPPFLAGS} ${ASFLAGS_$@} -c -o $@ $<; then \
${COMPILE_OK}; \
${COMPILE_MOSLIB_OK}; \
else \
${COMPILE_FAILED}; \
${COMPILE_MOSLIB_FAILED}; \
fi
.S.lib.o:
${COMPILE_LIB_STATUS}
Expand Down Expand Up @@ -613,6 +686,15 @@ locales: ${MO_FILES}
else \
${COMPILE_LIB_FAILED}; \
fi
.xpm.moslib.o:
${COMPILE_MOSLIB_STATUS}
in="$<"; \
out="$@"; \
if ${CC} -mbasel32 ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$@} -x c -c -o $@ $<; then \
${COMPILE_MOSLIB_OK}; \
else \
${COMPILE_MOSLIB_FAILED}; \
fi
.xpm.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
Expand Down Expand Up @@ -876,6 +958,9 @@ COMPILE_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_
COMPILE_LIB_STATUS = printf "@TERM_EL@@TERM_SETAF3@Compiling @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@ (lib)...@TERM_SGR0@\r" "$<"
COMPILE_LIB_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully compiled @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@ (lib).@TERM_SGR0@\n" "$<"
COMPILE_LIB_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@ (lib)!@TERM_SGR0@\n" "$<"; exit $$err
COMPILE_MOSLIB_STATUS = printf "@TERM_EL@@TERM_SETAF3@Compiling @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@ (moslib)...@TERM_SGR0@\r" "$<"
COMPILE_MOSLIB_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully compiled @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@ (moslib).@TERM_SGR0@\n" "$<"
COMPILE_MOSLIB_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@ (moslib)!@TERM_SGR0@\n" "$<"; exit $$err
COMPILE_PLUGIN_STATUS = printf "@TERM_EL@@TERM_SETAF3@Compiling @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@ (plugin)...@TERM_SGR0@\r" "$<"
COMPILE_PLUGIN_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully compiled @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@ (plugin).@TERM_SGR0@\n" "$<"
COMPILE_PLUGIN_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@ (plugin)!@TERM_SGR0@\n" "$<"; exit $$err
Expand Down

0 comments on commit 365fe57

Please sign in to comment.