Red Antigua Logo
Yet another piece of web.
Ads by Goooooogle
Search this site (by Google)
Tools    (top)
Your IP
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Mail::POP3Client
Mail::Send
MIME::Tools
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
UnxUtils
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
CD and DVD creation on FreeBSD using 'k3b' on FreeBSD
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Sendmail tips
GKrellm
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Virus list    (top)
Latest 10 viruses - Sophos

Off topic    (top)
Personal home links

Makefile for shared library on FreeBSD
Makefile for shared library on FreeBSD
IndexPreviousNext
Here is an example of how to build a shared library on FreeBSD of some object files, and then build an executable of some other object files, and finally link them together.
This Makefile has been tested with BSD make.
This example comes with no source code. It is just an example how to use compiler and linker flags to create a shared library on FreeBSD.
Note specially the following lines:
DEFAULT_LIB_INSTALL_PATH=./
SHARED_LDFLAGS=-Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)
With these compiler/linker flags, there is no need to use environment variables such as LD_LIBRARY_PATH.
These flags can be ignored if a library will be installed in one of the standard paths /lib/, /usr/lib/, or /usr/local/lib/, but during development and testing of a library, it is recommended to use an alternative path to not mix them with possible existing older versions of the same library.
In this case, DEFAULT_LIB_INSTALL_PATH is set to the same path as the executable.

Makefile:
# Example BSD Makefile for building a shared library, object files, an executable, and linking them alltogether.

# Executable
PROG = arithmetic
OBJS = main.o arithmetic.o kldgrep.o
OBJS_BSD = kldgrep.o
HEADERS = arithmetic.h

# Shared library
CODEC_OBJS = codec-alaw-mulaw.o codec-8bit.o codec-16bit.o codec-24bit.o codec-32bit.o
CODEC_HEADERS = codec.h
CODEC_LIB=libcodec.so
PICFLAGS = -fpic 
DEFAULT_LIB_INSTALL_PATH=./
SHAREDFLAGS = -shared
SHARED_LDFLAGS=-Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)
CODEC_LDFLAGS =  -L$(DEFAULT_LIB_INSTALL_PATH) -lcodec

# Compiler & linker options
CC = gcc
DEBUGFLAGS = -g
WARNFLAGS_BSD = -fno-strict-aliasing -pipe  -Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes \
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wno-pointer-sign
OPTFLAGS = -O2
LDFLAGS = -lm -lpthread
CFLAGS = $(DEBUGFLAGS) $(OPTFLAGS) $(WARNFLAGS) $(WARNFLAGS_BSD)


# Emacs TAGS
ETAGS_ARGS = find . -name "*.[ch]"


all: bsdlib bsd


bsd:  $(OBJS) $(OBJS_BSD)
        $(CC) $(DEBUGFLAGS) $(OPTFLAGS) $(WARNFLAGS_BSD) $(OBJS) $(OBJS_KLD) $(LDFLAGS) $(SHARED_LDFLAGS) $(CODEC_LDFLAGS) -o $(PROG)


# Codec Library
lib: bsdlib
bsdlib: $(CODEC_OBJS)
        $(CC) $(DEBUGFLAGS) $(OPTFLAGS) $(WARNFLAGS_BSD) $(SHAREDFLAGS) -o $(CODEC_LIB) $(CODEC_OBJS)


# Everything is rebuilt if this Makefile (which is hopefully named "Makefile") or any header changes.
$(OBJS): Makefile $(HEADERS)


$(CODEC_OBJS): Makefile $(CODEC_HEADERS)


# ----------------------------------------
# Misc. PHONY rules
# ----------------------------------------

# Cleanup
clean:
        rm -f $(PROG) *.a *.so *.o *~ *.core core


# Emacs etags
etags:
        etags `$(ETAGS_ARGS)`


# Print dependencies
dep: deps
deps:
        gcc -MM *.c


# Print make's internal database
print: printdb
printdb:
        make -p -f /dev/null


# Print predefined cpp macros
cpp:   macros
macro: macros
macros:
        @echo | cpp -dM


.PHONY: all clean
IndexPreviousNext
Last modified: Thu Jul 2 16:04:09 CEST 2009