Re: [Seed7-users] Library search path
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
From: Milo M. <mm...@ym...> - 2011-03-20 14:28:04
|
Thank you very much for that additional information. As per said information, I have created a patch for the Linux makefile which does two things: 1. It changes how the paths for the library files in the "depend" target are found: it uses a set of variables which, by default, allow for an installation to /usr/share/seed7/ and /usr/bin/hi. (This can be easily reset to the default behavior by specifying "BASE_DIR=`pwd`/.." on the command line for the "depend" target.) 2. It allows for a system-wide installation, into /usr/bin/hi and /usr/share/seed7, through the standard "install" target, which is accompanied by an "uninstall" target. Here is the patch, in unified format: --- a/seed7/src/mk_linux.mak 2011-03-06 05:51:35.000000000 -0500 +++ b/seed7/src/mk_linux.mak 2011-03-20 10:12:23.000000000 -0400 @@ -2,8 +2,12 @@ # To compile use a command shell and call: # make -f mk_linux.mak depend # make -f mk_linux.mak +# To install use a command shell and call: +# make -f mk_linux.mak install # If you are under windows you should use MinGW with mk_mingw.mak, mk_nmake.mak or mk_msys.mak instead. +DESTDIR = +prefix = /usr # CFLAGS = # CFLAGS = -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith # CFLAGS = -O2 -fomit-frame-pointer -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith @@ -25,6 +29,12 @@ LIBS = -lX11 -lncurses -lm # LIBS = -lX11 -lncurses -lm -lgmp # LIBS = -lX11 -lncurses -lm_p -lc_p +BIN_DIR = $(prefix)/bin +BASE_DIR = $(prefix)/share/seed7 +LIB_DIR = $(BASE_DIR)/lib +RLIB_DIR = $(BASE_DIR)/bin +DOC_DIR = $(BASE_DIR)/doc +PRG_DIR = $(BASE_DIR)/prg SEED7_LIB = seed7_05.a COMP_DATA_LIB = s7_data.a COMPILER_LIB = s7_comp.a @@ -116,6 +126,19 @@ clean: rm -f *.o ../bin/*.a depend a_depend b_depend c_depend version.h +install: ../bin/hi + mkdir -p $(DESTDIR)$(BIN_DIR) $(DESTDIR)$(RLIB_DIR) $(DESTDIR)$(LIB_DIR) $(DESTDIR)$(DOC_DIR) $(DESTDIR)$(PRG_DIR) + cp ../bin/hi $(DESTDIR)$(BIN_DIR)/hi + cp -t $(DESTDIR)$(RLIB_DIR) ../bin/*.a + cp -t $(DESTDIR)$(DOC_DIR) ../doc/* + cp -t $(DESTDIR)$(LIB_DIR) ../lib/*.s7i + cp -t $(DESTDIR)$(PRG_DIR) ../prg/* + rm $(DESTDIR)$(PRG_DIR)/hi + +uninstall: + rm -r $(BASEDIR) + rm $(prefix)/bin/hi + dep: depend strip: @@ -165,10 +188,10 @@ echo "#define LINKER_OPT_OUTPUT_FILE \"-o \"" >> version.h echo "#define LINKER_FLAGS \"$(LDFLAGS)\"" >> version.h echo "#define SYSTEM_LIBS \"$(LIBS)\"" >> version.h - cd ../bin; echo "#define SEED7_LIB \"`pwd`/$(SEED7_LIB)\"" >> ../src/version.h; cd ../src - cd ../bin; echo "#define COMP_DATA_LIB \"`pwd`/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd ../src - cd ../bin; echo "#define COMPILER_LIB \"`pwd`/$(COMPILER_LIB)\"" >> ../src/version.h; cd ../src - cd ../lib; echo "#define SEED7_LIBRARY \"`pwd`\"" >> ../src/version.h; cd ../src + cd ../bin; echo "#define SEED7_LIB \"$(RLIB_DIR)/$(SEED7_LIB)\"" >> ../src/version.h; cd ../src + cd ../bin; echo "#define COMP_DATA_LIB \"$(RLIB_DIR)/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd ../src + cd ../bin; echo "#define COMPILER_LIB \"$(RLIB_DIR)/$(COMPILER_LIB)\"" >> ../src/version.h; cd ../src + cd ../lib; echo "#define SEED7_LIBRARY \"$(LIB_DIR)\"" >> ../src/version.h; cd ../src depend: a_depend b_depend c_depend version.h $(CC) $(CFLAGS) -M $(SRC) > depend I have included this patch in the Seed7 AUR package at http://aur.archlinux.org/packages.php?ID=47584 and it is automatically applied before compilation. I have installed it on my own computer and it appears to work perfectly. Also, this patch could in theory be used to make packages for other Linux distros which use APT or RPM, but neither I nor my employer use them. Note, however, that the AUR isn't called a "User Repository" for nothing: it technically doesn't store the binary packages themselves, but bash scripts called "PKGBUILDS" which are sourced by the "makepkg" program to compile and make an actual package which the user can then install to their own system. The AUR includes a voting system, and packages with sufficient votes and popularity may be inducted into the "community" repository, which consists of binary packages which are maintained by a staff which is somewhat more loosely-knit than the regular package maintainers. You can read more about Arch Linux's packaging system at their excellent wiki (https://wiki.archlinux.org/index.php/AUR). This patch probably could be modified to work for the cygwin makefile as well, because cygwin also uses a UNIX-like file hierarchy standard. Once again, thank you very much for all your help. --- On Sun, 3/20/11, Thomas Mertes <tho...@gm...> wrote: > From: Thomas Mertes <tho...@gm...> > Subject: Re: [Seed7-users] Library search path > To: see...@li... > Cc: mm...@ym... > Date: Sunday, March 20, 2011, 10:03 AM > At Sat, 19 Mar 2011 15:52:01 +0000 > "Milo Mirate" <mm...@ym...> > wrote: > > This sounds great. I needed those details because I > would like to make an > > Arch Linux User Repository (http://aur.archlinux.org) package of Seed7 and > > I needed to know where to put the library files. Now > that I know how to > > specify where the interpreter should look for the > standard library, I can > > start making the package. Thank you again for your > help. > > Great, a package for Seed7. Thanks in advance. > Considering this case I try give you more precise > information. > > There are two things to consider: Seed7 include files (they > use > the extension .s7i and are sometimes called libraries in > the Seed7 > documentation) and Seed7 runtime libraries (static *.a > libraries of > the operating system). I suggest using different > directories for > *.s7i and *.a files. The position of all this files is > determined > in the makefile (and must be considered in a package). > > To determine the position of the *.a runtime libraries > (seed7_05.a, > s7_data.a and s7_comp.a) the preprocessor macros > SEED7_LIB, > COMP_DATA_LIB and COMPILER_LIB are written to the file > "version.h". > The commands in the makefile to do this are: > > cd ../bin; echo "#define SEED7_LIB > \"`pwd`/$(SEED7_LIB)\"" >> ../src/version.h; cd > ../src > cd ../bin; echo "#define COMP_DATA_LIB > \"`pwd`/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd > ../src > cd ../bin; echo "#define COMPILER_LIB > \"`pwd`/$(COMPILER_LIB)\"" >> ../src/version.h; cd > ../src > > The position of the Seed7 *.s7i include files is > determinated with > the preprocessor macro SEED7_LIBRARY (also written to > "version.h"). > The command to write SEED7_LIBRARY in the makefile is: > > cd ../lib; echo "#define SEED7_LIBRARY \"`pwd`\"" > >> ../src/version.h; cd ../src > > The file "version.h" is created with the 'make depend' > command. > My "version.h" file contains the following lines > (regarding > library and include files): > > #define SEED7_LIB "/home/tm/seed7_5/bin/seed7_05.a" > #define COMP_DATA_LIB "/home/tm/seed7_5/bin/s7_data.a" > #define COMPILER_LIB "/home/tm/seed7_5/bin/s7_comp.a" > #define SEED7_LIBRARY "/home/tm/seed7_5/lib" > > The mechanism to carry this and other information to the > Seed7 > compiler (comp.s7i) is as follows. The function > cmdConfigValue() > (see: "cmd_rtl.c") allows access to several values from > the > "version.h" file. BTW: The contents of the file > "version.h" > are described in "seed7/src/read_me.txt". > > Please do NOT change "version.h" manually. It contains many > things > that are determined automatically by the make process. If > you > want to change preprocessor macros in "version.h" you > should > definitely change the makefile. > > The Seed7 compiler needs detailed information about the C > compiler > and its runtime library. This information is created with > 'make depend' and written to "version.h". When the Seed7 > compiler > runs this information is obtained via cmdConfigValue(). > > There are two C compilers and runtime libraries to > consider: > > 1. The one which compiles the Seed7 interpreter and > the Seed7 > libraries (C compiler and runtime > used to crate the package). > 2. The one which is used by the Seed7 compiler (C > compiler > and runtime installed at a users > computer). > > As long as essentially the same C compiler and runtime > library is > used for both cases no unpleasant surprise will happen. > > For its own libraries Seed7 uses static (*.a) libraries. I > did not > try to uses dynamic (*.so) libraries for them. So I cannot > tell if > it would work for dynamic libraries. > > If you need more help or want some upstream changes, please > tell me. > > > Greetings Thomas Mertes > > -- > Seed7 Homepage: http://seed7.sourceforge.net > Seed7 - The extensible programming language: User defined > statements > and operators, abstract data types, templates without > special > syntax, OO with interfaces and multiple dispatch, > statically typed, > interpreted or compiled, portable, runs under > linux/unix/windows. > > -- > GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit > gratis Handy-Flat! http://portal.gmx.net/de/go/dsl > |