sources/Makefile | 46 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 36 insertions(+), 10 deletions(-) diff --git a/sources/Makefile b/sources/Makefile index 63c774f..8364ba3 100644 --- a/sources/Makefile +++ b/sources/Makefile @@ -28,43 +28,69 @@ AR=$(CROSS)ar OBJ4TH = errs_4th.o save_4th.o load_4th.o free_4th.o comp_4th.o \ name_4th.o dump_4th.o exec_4th.o open_4th.o cgen_4th.o -all: lib4th.a 4th 4tsh # 4thc 4thd 4thx 4thg +all: 4th 4tsh # 4thc 4thd 4thx 4thg + +ifdef SHARED +MAJOR=0 +MINOR=60 +MICRO=3 +SHARED_LIB=lib4th.so.$(MAJOR).$(MINOR).$(MICRO) +endif + +ifdef STATIC +STATIC_LIB=lib4th.a +else +ifndef SHARED +STATIC_LIB=lib4th.a +endif +endif + +lib4th: $(SHARED_LIB) $(STATIC_LIB) + +$(SHARED_LIB): $(OBJ4TH) + $(CC) -shared -o $@ $(OBJ4TH) -Wl,-soname,lib4th.so.$(MAJOR) + ln -sf $@ lib4th.so.$(MAJOR) + ln -sf $@ lib4th.so lib4th.a: $(OBJ4TH) $(AR) r $@ $(OBJ4TH) -4th: lib4th.a 4th.o +4th: lib4th 4th.o $(CC) $(CFLAGS) -I. -o $@ $@.o -L. -l4th -4tsh: lib4th.a 4tsh.o +4tsh: lib4th 4tsh.o $(CC) $(CFLAGS) -I. -o $@ $@.o -L. -l4th -4thc: lib4th.a 4thc.o +4thc: lib4th 4thc.o $(CC) $(CFLAGS) -I. -o $@ $@.o -L. -l4th -4thd: lib4th.a 4thd.o +4thd: lib4th 4thd.o $(CC) $(CFLAGS) -I. -o $@ $@.o -L. -l4th -4thx: lib4th.a 4thx.o +4thx: lib4th 4thx.o $(CC) $(CFLAGS) -I. -o $@ $@.o -L. -l4th -4thg: lib4th.a 4thg.o +4thg: lib4th 4thg.o $(CC) $(CFLAGS) -I. -o $@ $@.o -L. -l4th mostlyclean: -rm *.o 4th 4tsh # 4th? clean: mostlyclean - -rm lib4th.a + -rm -f lib4th.{a,so*} # Superuser privileges will probably be required for the rest install: all - cp lib4th.a $(LIBRARIES) + cp $(SHARED_LIB) $(STATIC_LIB) $(LIBRARIES) +ifdef SHARED + ln -sf $(SHARED_LIB) $(LIBRARIES)/lib4th.so.$(MAJOR) + ln -sf $(SHARED_LIB) $(LIBRARIES)/lib4th.so +endif cp 4th 4tsh $(BINARIES) uninstall: - -rm $(LIBRARIES)/lib4th.a + -rm -f $(LIBRARIES)/lib4th.{a,so*} -rm $(BINARIES)/4th $(BINARIES)/4tsh # $(BINARIES)/4thc $(BINARIES)/4thd $(BINARIES)/4thx $(BINARIES)/4thg .SUFFIXES: