# Modifying exif port...



## eddie1985 (Mar 10, 2016)

Hi, I'm new on FreeBSD and this is my first porting...so be patient 

I would want to modify the exif port (I would add two new options).
I modified some source files (.c) of exif, using some external files .c and .h as libraries; I temporarily copy the content of these external files in an internal file of exif (utils.c) then I compile with make, but clearly this is not the correct approach.

My goal is to add these external files as libraries of exif....I make a .so file, but I don't know how to include this dependency in the makefile...so I think that a workaround could be to add the dependency in the 'overall' makefile of the port.
This is the original makefile of the port:


```
# Created by: Pav Lucistnik <pav@FreeBSD.org>
# $FreeBSD$

PORTNAME=    exif
PORTVERSION=    0.6.21
CATEGORIES=    graphics
MASTER_SITES=    SF/lib${PORTNAME}/${PORTNAME}/${PORTVERSION}

MAINTAINER=    sunpoet@FreeBSD.org
COMMENT=    Command line utility to read and manipulate EXIF data

LICENSE=    LGPL21
LICENSE_FILE=    ${WRKSRC}/COPYING

LIB_DEPENDS=    libexif.so:${PORTSDIR}/graphics/libexif \
        libpopt.so:${PORTSDIR}/devel/popt

OPTIONS_DEFINE=    NLS
OPTIONS_SUB=    yes

CONFIGURE_ENV = POPT_CFLAGS=-I${LOCALBASE}/include POPT_LIBS="-L${LOCALBASE}/lib -lpopt"
CPE_VENDOR=    curtis_galloway
GNU_CONFIGURE=    yes
USES=        cpe gmake localbase pkgconfig

NLS_CONFIGURE_ON=    --enable-nls ${ICONV_CONFIGURE_ARG}
NLS_CONFIGURE_OFF=    --disable-nls --without-libiconv-prefix
NLS_USES=        gettext iconv

.include <bsd.port.mk>
```

How I can modify this file? Suppose that my lib is: lib.so..could you help me?


----------



## SirDice (Mar 10, 2016)

Porter's Handbook: 4.4. Patching
Porter's Handbook: 5.8. Dependencies
Yes, we have handbooks for pretty much everything


----------



## eddie1985 (Mar 10, 2016)

SirDice said:


> Porter's Handbook: 4.4. Patching
> Porter's Handbook: 5.8. Dependencies
> Yes, we have handbooks for pretty much everything


I read Porter's Handbook: 5.8 Dependencies.
In the Makefile that I post above, there is this line:


```
LIB_DEPENDS=libexif.so:${PORTSDIR}/graphics/libexif
```

But I check, and libexif.so is is /usr/local/lib .... why?

Then I add this line to the Makefile, after the line above:


```
mylib.so:${PORTSDIR}7graphics/libexif
```

I don't really add this library in this directory, and I then

```
make fetch
make extract
cd /work/exif
./configure
make
```

And no errors occur....while the lib is not really present....I'm a little bit confused...

Therefore in that guide there isn't nothing related to CONFIGURE_ENV


----------



## ondra_knezour (Mar 11, 2016)

eddie1985 said:


> ```
> LIB_DEPENDS=libexif.so:${PORTSDIR}/graphics/libexif
> ```
> But I check, and libexif.so is is /usr/local/lib .... why?


${PORTSDIR} expands to /usr/ports so this line reads as this port depends on the libexif.so which is installed by the /usr/ports/graphics/libexif port.


----------



## eddie1985 (Mar 11, 2016)

No sorry I didn't understand...it isn't the path of the libexif.so?


----------



## ondra_knezour (Mar 11, 2016)

No, it is not. Shared libraries are installed in some given directories and the linker is instructed with flags (see -L) where to look for them. So to cite from the Porter handbook, dependencies chapter linked above:


> This variable specifies the shared libraries this port depends on. It is a list of _lib_:_dir_ tuples where _lib_ is the name of the shared library, _dir_ is the directory in which to find it in case it is not available. For example,
> 
> LIB_DEPENDS=   libjpeg.so:${PORTSDIR}/graphics/jpeg
> 
> will check for a shared jpeg library with any version, and descend into the graphics/jpeg subdirectory of the ports tree to build and install it if it is not found.


----------



## tobik@ (Mar 11, 2016)

libexif.so is looked up by /usr/ports/Mk/Scripts/find-lib.sh which searches /lib,/usr/lib,/usr/local/lib plus every path in /usr/local/libdata/ldconfig/*.

This is done for you and you don't need to specify the full path to the library.


----------



## eddie1985 (Mar 12, 2016)

So, if I want to add a new library because my modified port depends on it, where I should put this library? For example, in /usr/lib directory? 
And how I should modify the Makefile? Should I add a new tuple in LIB_DEPENDS? And what is the next step?


----------



## tingo (Mar 12, 2016)

The correct way would be to create a new port for that library, and make your modified port have that as a dependecy.


----------



## eddie1985 (Mar 12, 2016)

And there are not alternatives?


----------



## tobik@ (Mar 15, 2016)

eddie1985 said:


> And there are not alternatives?


You say you currently modify utils.c. You can create a patch and drop it into files/ of the exif port. It is then automatically applied whenever the port is build. See the Porter's Handbook on how to do this: https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/slow-patch.html


----------

