mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 02:19:22 +01:00 
			
		
		
		
	+ Final changes for documentation
This commit is contained in:
		
							parent
							
								
									0d58e53bfc
								
							
						
					
					
						commit
						c4c93e0cd0
					
				
							
								
								
									
										71
									
								
								docs/progex/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								docs/progex/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,71 @@
 | 
			
		||||
#######################################################################
 | 
			
		||||
#
 | 
			
		||||
# Makefile to compile all examples and convert them to LaTeX
 | 
			
		||||
# 
 | 
			
		||||
#######################################################################
 | 
			
		||||
 | 
			
		||||
# Compiler
 | 
			
		||||
PP=ppc386
 | 
			
		||||
 | 
			
		||||
# Unit directory
 | 
			
		||||
# UNITDIR=/usr/lib/ppc/0.99.0/linuxunits
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Any options you wish to pass.
 | 
			
		||||
PPOPTS=
 | 
			
		||||
 | 
			
		||||
# Script to convert the programs to LaTeX examples which can be included.
 | 
			
		||||
PP2TEX=../pp2tex
 | 
			
		||||
 | 
			
		||||
# Script to convert the C programs to LaTeX examples which can be included.
 | 
			
		||||
C2TEX=./c2tex
 | 
			
		||||
 | 
			
		||||
# Script to collect all examples in 1 file.
 | 
			
		||||
MAKETEX=make1tex
 | 
			
		||||
 | 
			
		||||
#######################################################################
 | 
			
		||||
# No need to edit after this line.
 | 
			
		||||
#######################################################################
 | 
			
		||||
 | 
			
		||||
ifdef UNITDIR
 | 
			
		||||
PPOPTS:=$(PPOPTS) -Up$(UNITDIR);
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
.SUFFIXES: .pp .tex
 | 
			
		||||
 | 
			
		||||
.PHONY: all tex clean
 | 
			
		||||
 | 
			
		||||
OBJECTS=plsubs psubs 
 | 
			
		||||
COBJECTS=ctest ctest2
 | 
			
		||||
LIBOBJECT=libsubs.so
 | 
			
		||||
TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
 | 
			
		||||
TEXOBJECTS:=$(TEXOBJECTS) subs.tex
 | 
			
		||||
CTEXOBJECTS=$(addsuffix .tex, $(COBJECTS))
 | 
			
		||||
 | 
			
		||||
all : $(LIBOBJECTS) $(OBJECTS) $(COBJECTS)
 | 
			
		||||
 | 
			
		||||
tex : $(TEXOBJECTS) $(CTEXOBJECTS) subs.tex
 | 
			
		||||
 | 
			
		||||
onetex : tex
 | 
			
		||||
	$(MAKETEX) $(TEXOBJECTS)
 | 
			
		||||
 | 
			
		||||
clean : 
 | 
			
		||||
	rm -f *.o *.s *.so $(OBJECTS) $(COBJECTS) $(TEXOBJECTS) $(CTEXOBJECTS)
 | 
			
		||||
 
 | 
			
		||||
$(OBJECTS): %: %.pp $(LIBOBJECT)
 | 
			
		||||
	$(PP) $(PPOPTS) $*
 | 
			
		||||
 | 
			
		||||
$(TEXOBJECTS): %.tex: %.pp head.tex foot.tex
 | 
			
		||||
	$(PP2TEX) $*
 | 
			
		||||
 | 
			
		||||
$(CTEXOBJECTS): %.tex: %.c head.tex foot.tex
 | 
			
		||||
	$(C2TEX) $*
 | 
			
		||||
 | 
			
		||||
libsubs.so: subs.pp
 | 
			
		||||
	$(PP) $(PPOPTS) $<
 | 
			
		||||
 | 
			
		||||
ctest: ctest.c libsubs.so
 | 
			
		||||
	$(CC) -o ctest ctest.c -lsubs
 | 
			
		||||
 | 
			
		||||
ctest2: ctest2.c libsubs.so
 | 
			
		||||
	$(CC) -o ctest2 ctest2.c -ldl
 | 
			
		||||
							
								
								
									
										7
									
								
								docs/progex/README
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								docs/progex/README
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
These are the example programs that appear in the FPC documentation.
 | 
			
		||||
 
 | 
			
		||||
Units guide, chapter on GPM unit :
 | 
			
		||||
 | 
			
		||||
Example programs
 | 
			
		||||
gpmex.pp  demonstrates the basic usage of the gpm unit.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								docs/progex/c2tex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								docs/progex/c2tex
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
# Simply paste a header and footer to the program.
 | 
			
		||||
#
 | 
			
		||||
cat head.tex >  $1.tex
 | 
			
		||||
cat $1.c    >> $1.tex
 | 
			
		||||
cat foot.tex >> $1.tex
 | 
			
		||||
@ -6,18 +6,15 @@ int main()
 | 
			
		||||
    void *lib;
 | 
			
		||||
    char *s;
 | 
			
		||||
    int FromPos, ToPos;
 | 
			
		||||
    char* (*SubStr)(const char*, int*, int*);
 | 
			
		||||
    printf("arh %d\n",RTLD_LAZY);
 | 
			
		||||
    lib = dlopen("./libcaseudf.so", RTLD_LAZY);
 | 
			
		||||
    printf("Result from dlopen (library handle): 0x%08x\n", lib);
 | 
			
		||||
    char* (*SubStr)(const char*, int, int);
 | 
			
		||||
 | 
			
		||||
    lib = dlopen("./libsubs.so", RTLD_LAZY);
 | 
			
		||||
    SubStr = dlsym(lib, "SUBSTR");
 | 
			
		||||
    printf("Address of SubStr = 0x%08x, last error code = %i\n",
 | 
			
		||||
      SubStr, dlerror());
 | 
			
		||||
 | 
			
		||||
    s = strdup("Test");
 | 
			
		||||
    FromPos = 2;
 | 
			
		||||
    ToPos = 3;
 | 
			
		||||
    printf("Result from SubStr: '%s'\n", (*SubStr)(s, &FromPos, &ToPos));
 | 
			
		||||
    printf("Result from SubStr: '%s'\n", (*SubStr)(s, FromPos, ToPos));
 | 
			
		||||
    dlclose(lib);
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								docs/progex/foot.tex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/progex/foot.tex
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
\end{verbatim}
 | 
			
		||||
\end{FPCList}
 | 
			
		||||
							
								
								
									
										3
									
								
								docs/progex/head.tex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								docs/progex/head.tex
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
\begin{FPCList}
 | 
			
		||||
\item[Example]
 | 
			
		||||
\begin{verbatim}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user