From: Jan Nieuwenhuizen Date: Thu, 20 Sep 2001 19:24:40 +0000 (+0200) Subject: patch::: 1.5.10.jcn3 X-Git-Tag: release/1.5.11~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=72c67220d22e607b82d2919b71b7de849af6bbeb;p=lilypond.git patch::: 1.5.10.jcn3 1.5.10.jcn3 =========== * include python midi parser. * stepmake updates. * add .cvsignore patterns for making patches the standard, manual way. --- diff --git a/CHANGES b/CHANGES index 224fb6764e..c1cc36046f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ -1.5.10.jcn2 -========== +1.5.10.jcn3 +=========== + +* include python midi parser. + +* stepmake updates. + +* add .cvsignore patterns for making patches the standard, manual way. * midi2ly: support chords, duration conversion rewrite. diff --git a/GNUmakefile.in b/GNUmakefile.in index e5db868e71..ef6ea571a0 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -10,7 +10,7 @@ depth = . # SUBDIRS = buildscripts scripts flower lily \ mf ly tex ps scm \ - midi2ly po make intl \ + modules midi2ly po make intl \ debian $(builddir)/stepmake \ Documentation input \ mutopia ports diff --git a/VERSION b/VERSION index 7a347816fa..7eb914293c 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 PATCH_LEVEL=10 -MY_PATCH_LEVEL=jcn2 +MY_PATCH_LEVEL=jcn3 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/modules/GNUmakefile b/modules/GNUmakefile new file mode 100644 index 0000000000..5a023f14cb --- /dev/null +++ b/modules/GNUmakefile @@ -0,0 +1,11 @@ +depth = .. + +# Hmm, name dir midi too, then? +NAME=midi + +STEPMAKE_TEMPLATES=c install python-module + +INSTALLATION_FILES=$(outdir)/midi.so +INSTALLATION_DIR=$(datadir)/python + +include $(depth)/make/stepmake.make diff --git a/modules/midi.c b/modules/midi.c new file mode 100644 index 0000000000..11fdd25d4f --- /dev/null +++ b/modules/midi.c @@ -0,0 +1,413 @@ +/* + midi.c -- implement Python midi parser module + + source file of the GNU LilyPond music typesetter + + (c) 2001 Han-Wen Nienhuys + Jan Nieuwenhuizen + +*/ + +/* + +python2 +import midi +s = open ("s.midi").read () +midi.parse_track (s) +midi.parse (s) + +*/ + +#include + +#if 0 +int x = 0; +int *track = &x; +#define debug_print(f, args...) fprintf (stderr, "%s:%d: track: %p :" f, __FUNCTION__, __LINE__, *track, ##args) +#else +#define debug_print(f, args...) +#endif + +static PyObject *Midi_error; +static PyObject *Midi_warning; + +static PyObject * +midi_error (char *s) +{ + PyErr_SetString (Midi_error, s); + return 0; +} + +static PyObject * +midi_warning (char *s) +{ + PyErr_SetString (Midi_warning, s); + return 0; +} + + +typedef struct message { + unsigned char msg; + char * description; +} message_t; + +message_t channelVoiceMessages[] = { + 0x80, "NOTE_OFF", + 0x90, "NOTE_ON", + 0xA0, "POLYPHONIC_KEY_PRESSURE", + 0xB0, "CONTROLLER_CHANGE", + 0xC0, "PROGRAM_CHANGE", + 0xD0, "CHANNEL_KEY_PRESSURE", + 0xE0, "PITCH_BEND", + 0,0 +}; + +message_t channelModeMessages[] = { + 0x78, "ALL_SOUND_OFF", + 0x79, "RESET_ALL_CONTROLLERS", + 0x7A, "LOCAL_CONTROL", + 0x7B, "ALL_NOTES_OFF", + 0x7C, "OMNI_MODE_OFF", + 0x7D, "OMNI_MODE_ON", + 0x7E, "MONO_MODE_ON", + 0x7F, "POLY_MODE_ON", + 0,0 +}; + +message_t metaEvents[] = { + 0x00, "SEQUENCE_NUMBER", + 0x01, "TEXT_EVENT", + 0x02, "COPYRIGHT_NOTICE", + 0x03, "SEQUENCE_TRACK_NAME", + 0x04, "INSTRUMENT_NAME", + 0x05, "LYRIC", + 0x06, "MARKER", + 0x07, "CUE_POINT", + 0x20, "MIDI_CHANNEL_PREFIX", + 0x21, "MIDI_PORT", + 0x2F, "END_OF_TRACK", + 0x51, "SET_TEMPO", + 0x54, "SMTPE_OFFSET", + 0x58, "TIME_SIGNATURE", + 0x59, "KEY_SIGNATURE", + 0x7F, "SEQUENCER_SPECIFIC_META_EVENT", + 0,0 +}; + +unsigned long int +get_number (char * str, char * end_str, int length) +{ + /* # MIDI uses big-endian for everything */ + long sum = 0; + int i = 0; + + for (; i < length; i++) + sum = (sum << 8) + (unsigned char) str[i]; + + debug_print ("%d:\n", sum); + return sum; +} + +unsigned long int +get_variable_length_number (char **str, char * end_str) +{ + long sum = 0; + int i = 0; + while (*str < end_str) + { + unsigned char x = **str; + (*str) ++; + sum = (sum << 7) + (x & 0x7F); + if (!(x & 0x80)) + break; + } + debug_print ("%d:\n", sum); + return sum; +} + +static PyObject * +read_unimplemented_event (char **track, char *end, unsigned long time, + unsigned char x, unsigned char z) +{ + debug_print ("%x:%s", z, "unimplemented MIDI event\n"); + *track += 2; + return Py_BuildValue ("(iii)", z, *((*track) -2), *((*track) -1)); +} + +PyObject * +read_one_byte (char **track, char *end, unsigned long time, + unsigned char x, unsigned char z) +{ + debug_print ("%x:%s", z, "event\n"); + *track += 1; + return Py_BuildValue ("(ii)", z, *((*track) -1)); +} + +PyObject * +read_two_bytes (char **track, char *end, unsigned long time, + unsigned char x, unsigned char z) +{ + debug_print ("%x:%s", z, "event\n"); + *track += 2; + return Py_BuildValue ("(iii)", z, *((*track) -2), *((*track) -1)); +} + +PyObject * +read_three_bytes (char **track, char *end, unsigned long time, + unsigned char x, unsigned char z) +{ + debug_print ("%x:%s", z, "event\n"); + *track += 3; + return Py_BuildValue ("(iiii)", z, *((*track) -3), *((*track) -2), *((*track) -1)); +} + +PyObject * +read_string (char **track, char *end, unsigned long time, + unsigned char x, unsigned char z) +{ + unsigned long length = get_variable_length_number (track, end); + if (length < *track - end) + debug_print ("%s", "zero length string\n"); + *track += length; + debug_print ("%x:%s", length, "string\n"); + return Py_BuildValue ("(is)", z, *((*track) -length)); +} + +typedef PyObject* (*Read_midi_event) + (char **track, char *end, unsigned long time, + unsigned char x, unsigned char z); + +Read_midi_event read_ff_byte [16] = +{ + read_three_bytes, // 0 + read_one_byte, // 10 + read_one_byte, // 20 + read_one_byte, // 30 + read_one_byte, // 40 + read_one_byte, // 50 + read_one_byte, // 60 + read_two_bytes, // 70 + read_two_bytes, // 80 + read_two_bytes, // 90 + read_two_bytes, // a0 + read_two_bytes, // b0 + read_one_byte, // c0 + read_two_bytes, // d0 + read_two_bytes, // e0 + read_two_bytes, // e0 +}; + + +static PyObject * +read_f0_byte (char **track, char *end, unsigned long time, + unsigned char x, unsigned char z) + +{ + debug_print ("%x:%s", z, "event\n"); + if (z == 0xff) + { + unsigned char zz = *(*track)++; + debug_print ("%x:%s", zz, "f0-event\n"); + if (zz == 0x01 && **track <= 0x07) + return read_string (track, end, time, x, zz); + else if (zz == 0x2f && **track == 0x00) + { + (*track)++; + debug_print ("%s", "done\n"); + return 0; + } + else + return read_unimplemented_event (track, end, time, x, zz); + exit (0); + } + else + return read_string (track, end, time, x, z); +} + +Read_midi_event read_midi_event [16] = +{ + read_one_byte, // 0 + read_one_byte, // 10 + read_one_byte, // 20 + read_one_byte, // 30 + read_one_byte, // 40 + read_one_byte, // 50 + read_one_byte, // 60 + read_two_bytes, // 70 + read_two_bytes, // 80 + read_two_bytes, // 90 + read_two_bytes, // a0 + read_two_bytes, // b0 + read_one_byte, // c0 + read_two_bytes, // d0 + read_two_bytes, // e0 + read_f0_byte, // f0 +}; + +static PyObject * +read_event (char **track, char *end, unsigned long time, + unsigned char *running_status) +{ + int rsb_skip = ((**track & 0x80)) ? 1 :0; + + unsigned char x = (rsb_skip) ? (*track)[0]: *running_status; + // unsigned char y = x & 0xf0; + unsigned char z = (*track)[1 + rsb_skip]; + + debug_print ("%x:%s", z, "event\n"); + *track += 2 + rsb_skip; + + return (*read_midi_event[z >> 4]) (track, end, time, x, z); +} + +static PyObject * +midi_parse_track (char **track, char *track_end) +{ + unsigned int time = 0; + unsigned char running_status; + unsigned long track_len, track_size; + PyObject *pytrack = 0; + + debug_print ("%s", "\n"); + + track_size = track_end - *track; + /* need this for direct midi.parse_track (s) on midi file */ + if (strcmp (*track, "MTrk")) + *track = memmem (*track, track_size - 1, "MTrk", 4); + debug_print ("%s", "\n"); + assert (!strcmp (*track, "MTrk")); + *track += 4; + + track_len = get_number (*track, *track + 4, 4); + *track += 4; + + debug_print ("track_len: %u\n", track_len); + debug_print ("track_size: %u\n", track_size); + debug_print ("track begin: %p\n", track); + debug_print ("track end: %p\n", track + track_len); + + //assert (track_len <= track_size); + + pytrack = PyList_New (0); + + track_end = *track + track_len; + + while (*track < track_end) + { + long dt = get_variable_length_number(track, track_end); + time += dt; + PyList_Append (pytrack, read_event (track, track_end, time, + &running_status)); + } + + *track = track_end; + return pytrack; +} + + +static PyObject * +pymidi_parse_track (PyObject *self, PyObject *args) +{ + char *track, *track_end; + unsigned long track_size, track_len; + + PyObject * sobj = PyTuple_GetItem (args, 0); + + debug_print ("%s", "\n"); + if (!PyArg_ParseTuple (args, "s#", &track, &track_size)) + return 0; + + if (track_size < 0) + return midi_error ("negative track size"); + + track_end = track + track_size; + + return midi_parse_track (&track, track_end); +} + +static PyObject * +midi_parse (char **midi, char *midi_end) +{ + PyObject *pymidi = 0; + unsigned long header_len; + unsigned format, tracks; + int division; + int i; + + debug_print ("%s", "\n"); + + /* Header */ + header_len = get_number (*midi, *midi + 4, 4); + *midi += 4; + + if (header_len < 6) + return midi_error ("header too short"); + + format = get_number (*midi, *midi + 2, 2); + *midi += 2; + + tracks = get_number (*midi, *midi + 2, 2); + *midi += 2; + + if (tracks > 32) + return midi_error ("too many tracks"); + + division = get_number (*midi, *midi + 2, 2) * 4; + *midi += 2; + + if (division < 0) + /* return midi_error ("can't handle non-metrical time"); */ + ; + *midi += header_len - 6; + + pymidi = PyList_New (0); + PyList_Append (pymidi, Py_BuildValue ("(iii)", format, tracks, division)); + + /* Tracks */ + for (i = 0; i < tracks; i++) + PyList_Append (pymidi, midi_parse_track (midi, midi_end)); + + return pymidi; +} + +static PyObject * +pymidi_parse (PyObject *self, PyObject *args) +{ + char *midi, *midi_end; + unsigned long midi_size, midi_len; + + PyObject *sobj = PyTuple_GetItem (args, 0); + + debug_print ("%s", "\n"); + if (!PyArg_ParseTuple (args, "s#", &midi, &midi_size)) + return 0; + + if (strcmp (midi, "MThd")) + return midi_error ("MThd expected"); + + midi += 4; + + midi_end = midi + midi_size; + + return midi_parse (&midi, midi_end); +} + + +static PyMethodDef MidiMethods[] = +{ + {"parse", pymidi_parse, 1}, + {"parse_track", pymidi_parse_track, 1}, + {0, 0} /* Sentinel */ +}; + +initmidi () +{ + PyObject *m, *d; + m = Py_InitModule ("midi", MidiMethods); + d = PyModule_GetDict (m); + + Midi_error = PyString_FromString ("midi.error"); + PyDict_SetItemString (d, "error", Midi_error); + Midi_warning = PyString_FromString ("midi.warning"); + PyDict_SetItemString (d, "warning", Midi_warning); +} diff --git a/stepmake/stepmake/c++-rules.make b/stepmake/stepmake/c++-rules.make index 1c7a0cc0db..5b80d24475 100644 --- a/stepmake/stepmake/c++-rules.make +++ b/stepmake/stepmake/c++-rules.make @@ -1,12 +1,16 @@ -.SUFFIXES: .cc .o .hh .yy .ll .dep +.SUFFIXES: .cc .dep .hh .ll .o .so .yy -# compile rules: -# $(outdir)/%.o: %.cc - $(DO_CXX_COMPILE) + $(DO_O_DEP) $(CXX) -c $(CXXFLAGS) -o $@ $< $(outdir)/%.o: $(outdir)/%.cc - $(DO_CXX_COMPILE) + $(DO_O_DEP) $(CXX) -c $(CXXFLAGS) -o $@ $< + +$(outdir)/%.lo: %.cc + $(DO_LO_DEP) $(CXX) -c $(CXXFLAGS) $(PIC_FLAGS) -o $@ $< + +$(outdir)/%.lo: $(outdir)/%.cc + $(DO_LO_DEP) $(CXX) -c $(CXXFLAGS) $(PIC_FLAGS) -o $@ $< $(outdir)/%.cc: %.yy $(BISON) $< diff --git a/stepmake/stepmake/c++-vars.make b/stepmake/stepmake/c++-vars.make index bf78e7d48a..3dfe6819b1 100644 --- a/stepmake/stepmake/c++-vars.make +++ b/stepmake/stepmake/c++-vars.make @@ -1,4 +1,6 @@ +include $(stepdir)/compile-vars.make + # added two warnings that are treated by cygwin32's gcc 2.7.2 as errors. # huh, but still, no warnings even provoced with linux's gcc 2.7.2.1? @@ -7,8 +9,6 @@ EXTRA_CXXFLAGS= -Wall -W -Wmissing-prototypes -Wconversion CXXFLAGS = $(ICFLAGS) $(DEFINES) $(addprefix -I,$(INCLUDES)) $(USER_CFLAGS) $(EXTRA_CFLAGS) $(MODULE_CFLAGS) $($(PACKAGE)_CFLAGS) $($(PACKAGE)_CXXFLAGS) $(USER_CXXFLAGS) $(EXTRA_CXXFLAGS) $(MODULE_CXXFLAGS) -CXX_OUTPUT_OPTION = $< -o $@ -DO_CXX_COMPILE=$(DODEP) $(CXX) -c $(CXXFLAGS) $(CXX_OUTPUT_OPTION) # template files: TCC_FILES := $(wildcard *.tcc) diff --git a/stepmake/stepmake/c-rules.make b/stepmake/stepmake/c-rules.make index 90013ec551..ef44800783 100644 --- a/stepmake/stepmake/c-rules.make +++ b/stepmake/stepmake/c-rules.make @@ -1,10 +1,16 @@ -.SUFFIXES: .c .o .h .y .l .dep +.SUFFIXES: .c .dep .h .l .lo .o .so .y $(outdir)/%.o: %.c - $(DO_C_COMPILE) + $(DO_O_DEP) $(CC) -c $(CFLAGS) -o $@ $< $(outdir)/%.o: $(outdir)/%.c - $(DO_C_COMPILE) + $(DO_O_DEP) $(CC) -c $(CFLAGS) -o $@ $< + +$(outdir)/%.lo: %.c + $(DO_LO_DEP) $(CC) -c $(CFLAGS) $(PIC_FLAGS) -o $@ $< + +$(outdir)/%.lo: %.c + $(DO_LO_DEP) $(CC) -c $(CFLAGS) $(PIC_FLAGS) -o $@ $< $(outdir)/%.c: %.y $(BISON) $< diff --git a/stepmake/stepmake/c-vars.make b/stepmake/stepmake/c-vars.make index 7c5a9f0ef2..2b25636bba 100644 --- a/stepmake/stepmake/c-vars.make +++ b/stepmake/stepmake/c-vars.make @@ -1,4 +1,5 @@ -# header files: +include $(stepdir)/compile-vars.make + H_FILES := $(wildcard *.h) C_FILES := $(wildcard *.c) Y_FILES := $(wildcard *.y) @@ -9,15 +10,7 @@ SOURCE_FILES+=$(Y_FILES) $(C_FILES) $(L_FILES) $(H_FILES) O_FILES+=$(addprefix $(outdir)/, $(Y_FILES:.y=.o) $(C_FILES:.c=.o) $(L_FILES:.l=.o)) TAGS_FILES += $(C_FILES) $(H_FILES) -# C/C++ -# ALL_C_SOURCES += $(H_FILES) $(C_FILES) $(Y_FILES) $(L_FILES) -# compiler: -# -DO_C_COMPILE = $(DODEP) $(CC) -c $(CFLAGS) $(C_OUTPUT_OPTION) -C_OUTPUT_OPTION = -o $@ $< - CFLAGS = $(ICFLAGS) $(DEFINES) $(addprefix -I,$(INCLUDES)) $(USER_CFLAGS) $(EXTRA_CFLAGS) $(MODULE_CFLAGS) - diff --git a/stepmake/stepmake/compile-vars.make b/stepmake/stepmake/compile-vars.make new file mode 100644 index 0000000000..04725547b8 --- /dev/null +++ b/stepmake/stepmake/compile-vars.make @@ -0,0 +1,13 @@ +ARFLAGS = ru + +LDFLAGS = $(ILDFLAGS) $(EXTRA_LDFLAGS) $($(PACKAGE)_LDFLAGS) $(MODULE_LDFLAGS) $(USER_LDFLAGS) + +PIC_FLAGS = -fpic -fPIC +SHARED_FLAGS = -shared + +o-dep-out = $(outdir)/$(subst .o,.dep,$(notdir $@))# +DO_O_DEP = rm -f $(o-dep-out); DEPENDENCIES_OUTPUT="$(o-dep-out) $(outdir)/$(notdir $@)" + +lo-dep-out = $(outdir)/$(subst .lo,.dep,$(notdir $@))# +DO_LO_DEP = rm -f $(lo-dep-out); DEPENDENCIES_OUTPUT="$(lo-dep-out) $(outdir)/$(notdir $@)" + diff --git a/stepmake/stepmake/executable-rules.make b/stepmake/stepmake/executable-rules.make index e032d7ee59..7f0b076dc8 100644 --- a/stepmake/stepmake/executable-rules.make +++ b/stepmake/stepmake/executable-rules.make @@ -1,2 +1,4 @@ -# empty +$(EXECUTABLE): $(outdir)/config.h $(O_FILES) $(outdir)/version.hh + $(foreach a, $(MODULE_LIBS), $(MAKE) -C $(a) && ) true + $(LD) -o $@ $(O_FILES) $(LOADLIBES) $(LDFLAGS) diff --git a/stepmake/stepmake/executable-targets.make b/stepmake/stepmake/executable-targets.make index 89b06d48a8..b16bf89807 100644 --- a/stepmake/stepmake/executable-targets.make +++ b/stepmake/stepmake/executable-targets.make @@ -1,13 +1,7 @@ default: $(EXECUTABLE) -$(EXECUTABLE): $(outdir)/config.h $(O_FILES) $(outdir)/version.hh - $(foreach a, $(MODULE_LIBS), $(MAKE) -C $(a) && ) true - $(LD_COMMAND) $(O_FILES) $(LOADLIBES) $(USER_LDFLAGS) - exe: $(EXECUTABLE) - - local-install: installexe local-uninstall: uninstallexe diff --git a/stepmake/stepmake/executable-vars.make b/stepmake/stepmake/executable-vars.make index c94aeff482..5ac8fcd982 100644 --- a/stepmake/stepmake/executable-vars.make +++ b/stepmake/stepmake/executable-vars.make @@ -1,6 +1,3 @@ -LDFLAGS = $(ILDFLAGS) $(EXTRA_LDFLAGS) $(MODULE_LDFLAGS) $($(PACKAGE)_LDFLAGS) - -## urg, silly name: library.a MODULE_LIBES =$(addprefix $(outdir)/../, $(addsuffix /$(outbase)/library.a, $(MODULE_LIBS))) LOADLIBES = $(MODULE_LIBES) $($(PACKAGE)_LIBES) $(EXTRA_LIBES) diff --git a/stepmake/stepmake/generic-vars.make b/stepmake/stepmake/generic-vars.make index 8ee0efd874..1679e6b90d 100644 --- a/stepmake/stepmake/generic-vars.make +++ b/stepmake/stepmake/generic-vars.make @@ -77,33 +77,9 @@ ERROR_LOG = 2> /dev/null SILENT_LOG = 2>&1 > /dev/null date := $(shell date +%x) #duplicated? -# compile and link options: -# -ARFLAGS = ru - -#INCLUDES = $(depth)/$(builddir) include $(outdir) $($(PACKAGE)_INCLUDES) $(MODULE_INCLUDES) INCLUDES = include $(outdir) $($(PACKAGE)_INCLUDES) $(MODULE_INCLUDES) -# urg: for windows ? -# LOADLIBES = $(MODULE_LIBES) $($(PACKAGE)_LIBES) $(EXTRA_LIBES) -lstdc++ -# - -# macro compiler: -# M4 = m4 -# - -# -LD_COMMAND = $(LD) $(LDFLAGS) -o $@ -# - -# dependencies: -# -depfile = $(outdir)/$(subst .o,.dep,$(notdir $@))# -DODEP=rm -f $(depfile); DEPENDENCIES_OUTPUT="$(depfile) $(outdir)/$(notdir $@)" -# - -# #replace to do stripping of certain objects STRIPDEBUG=true @@ -111,11 +87,7 @@ STRIPDEBUG=true DIST_FILES=$(EXTRA_DIST_FILES) GNUmakefile $(ALL_SOURCES) DOCDIR=$(depth)/$(outdir) - STRIP=strip --strip-debug -ifdef stablecc - STABLEOBS=$(addprefix $(outdir)/,$(stablecc:.cc=.o)) -endif # substitute $(STRIP) in Site.make if you want stripping DO_STRIP=true diff --git a/stepmake/stepmake/library-rules.make b/stepmake/stepmake/library-rules.make index 1bb8bf6d7f..64d49bc098 100644 --- a/stepmake/stepmake/library-rules.make +++ b/stepmake/stepmake/library-rules.make @@ -1 +1,8 @@ -# empty + +$(LIBRARY): $(outdir)/config.h $(O_FILES) + $(AR) $(ARFLAGS) $@ $(O_FILES) + # thanks to Nelson Beebe for this trick. + $(RANLIB) $@ || $(AR) ts $@ || true + + + diff --git a/stepmake/stepmake/library-targets.make b/stepmake/stepmake/library-targets.make index 7cb7ea5bfe..61bd8f28c0 100644 --- a/stepmake/stepmake/library-targets.make +++ b/stepmake/stepmake/library-targets.make @@ -1,14 +1,3 @@ - default: $(LIBRARY) -$(outdir)/library.a: $(outdir)/config.h $(O_FILES) $(MODULE_LIBES) - $(AR_COMMAND) $(O_FILES) - $(RANLIB_COMMAND) - -$(SHAREDLIBRARY): $(outdir)/config.h $(O_FILES) $(MODULE_LIBES) - $(LD_COMMAND) $(O_FILES) -o $@.$(VERSION) - rm -f $@ - ln -sf $(outdir)/$(LIB_PREFIX)$(NAME).so.$(VERSION) $@.$(MAJOR_VERSION) - ln -sf $(LIB_PREFIX)$(NAME).so.$(VERSION) $@ - - +lib: $(LIBRARY) diff --git a/stepmake/stepmake/library-vars.make b/stepmake/stepmake/library-vars.make index b2555a9c84..7c01002d53 100644 --- a/stepmake/stepmake/library-vars.make +++ b/stepmake/stepmake/library-vars.make @@ -1,22 +1,8 @@ - -#ugh ugh . -ifndef LIB_SUFFIX -LIB_SUFFIX = .a -endif - LIB_PREFIX = lib +LIB_SUFFIX = .a -# librarian: -# -AR = ar -AR_COMMAND = $(AR) $(ARFLAGS) $@ - -# thanks to Nelson Beebe for this trick. -RANLIB_COMMAND=$(RANLIB) $@ || $(AR) ts $@ || true - -# linker: -# urg, i don't like this name, it's not what you'd expect -LIBRARY = $(outdir)/library.a +AR=ar +# LIBRARY = $(outdir)/$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX) +LIBRARY = $(outdir)/$(LIB_PREFIX)rary$(LIB_SUFFIX) INSTALL_LIBRARY = $(LIB_PREFIX)$(NAME)$(LIB_SUFFIX) -SHARED_LIBRARY=$(outdir)/$(LIB_PREFIX)$(NAME).so diff --git a/stepmake/stepmake/python-module-rules.make b/stepmake/stepmake/python-module-rules.make new file mode 100644 index 0000000000..b37eb61110 --- /dev/null +++ b/stepmake/stepmake/python-module-rules.make @@ -0,0 +1,3 @@ + +$(PYTHON_MODULE): $(outdir)/config.h $(LO_FILES) + $(LD) $(SHARED_FLAGS) -o $@ $(LO_FILES) $(LDFLAGS) diff --git a/stepmake/stepmake/python-module-targets.make b/stepmake/stepmake/python-module-targets.make new file mode 100644 index 0000000000..6d4f607785 --- /dev/null +++ b/stepmake/stepmake/python-module-targets.make @@ -0,0 +1 @@ +default: $(PYTHON_MODULE) \ No newline at end of file diff --git a/stepmake/stepmake/python-module-vars.make b/stepmake/stepmake/python-module-vars.make new file mode 100644 index 0000000000..372264046c --- /dev/null +++ b/stepmake/stepmake/python-module-vars.make @@ -0,0 +1,7 @@ +SHARED_LIB_SUFFIX = .so + +PYTHON_MODULE = $(outdir)/$(NAME)$(SHARED_LIB_SUFFIX) +INSTALL_SHARED_LIBRARY = $(SHARED_LIB_PREFIX)$(NAME)$(SHARED_LIB_SUFFIX) + +LO_FILES += $(addprefix $(outdir)/, $(Y_FILES:.y=.lo) $(C_FILES:.c=.lo) $(L_FILES:.l=.lo)) + diff --git a/stepmake/stepmake/shared-library-rules.make b/stepmake/stepmake/shared-library-rules.make new file mode 100644 index 0000000000..d4256de5a7 --- /dev/null +++ b/stepmake/stepmake/shared-library-rules.make @@ -0,0 +1,8 @@ + +$(SHARED_LIBRARY): $(outdir)/config.h $(LO_FILES) + $(LD) $(SHARED_FLAGS) -o $@.$(VERSION) $(LO_FILES) $(LDFLAGS) + rm -f $@.$(MAJOR_VERSION) + ln -sf $(outdir)/$(LIB_PREFIX)$(NAME).so.$(VERSION) $@.$(MAJOR_VERSION) + rm -f $@ + ln -sf $(LIB_PREFIX)$(NAME).so.$(VERSION) $@ + diff --git a/stepmake/stepmake/shared-library-targets.make b/stepmake/stepmake/shared-library-targets.make new file mode 100644 index 0000000000..87602324dd --- /dev/null +++ b/stepmake/stepmake/shared-library-targets.make @@ -0,0 +1,3 @@ + +default: $(SHARED_LIBRARY) + diff --git a/stepmake/stepmake/shared-library-vars.make b/stepmake/stepmake/shared-library-vars.make new file mode 100644 index 0000000000..b4650f5418 --- /dev/null +++ b/stepmake/stepmake/shared-library-vars.make @@ -0,0 +1,11 @@ +SHARED_LIB_PREFIX = lib +SHARED_LIB_SUFFIX = .so + +SHARED_LIBRARY = $(outdir)/$(SHARED_LIB_PREFIX)$(NAME)$(SHARED_LIB_SUFFIX) +INSTALL_SHARED_LIBRARY = $(SHARED_LIB_PREFIX)$(NAME)$(SHARED_LIB_SUFFIX) + +lo-dep-out = $(outdir)/$(subst .lo,.dep,$(notdir $@))# +DO_LO_DEP = rm -f $(lo-dep-out); DEPENDENCIES_OUTPUT="$(lo-dep-out) $(outdir)/$(notdir $@)" + +LO_FILES += $(addprefix $(outdir)/, $(Y_FILES:.y=.lo) $(C_FILES:.c=.lo) $(L_FILES:.l=.lo)) +