# modify code in ports, but `make` doesn't know



## jronald (May 16, 2013)

*W*hen I do as below:


```
cd /usr/ports/www/larbin
make fetch
make extract
make patch
cd work/larbin-2.6.3
// modify options.h
cd ../..
make
// the progress is showed
// then modify options.h and make again as above, but nothing is made,
// all the *.o and larbin in working/larbin-2.6.3/src stay the same
```

What's the proper way to rebuild?


----------



## dh (May 16, 2013)

Remove the work/.build_done.* file.


----------



## kpa (May 16, 2013)

The standard way is to do `make clean build`.


----------



## dh (May 16, 2013)

kpa said:
			
		

> The standard way is to do `make clean build`.



That would delete the modified source files, which is unwanted side effect in this case.


----------



## kpa (May 16, 2013)

Oh ok. In that case make a custom patch from the modified source and drop it in the files directory of the port.


----------



## KNOStic (May 16, 2013)

kpa said:
			
		

> Oh ok. In that case make a custom patch from the modified source and drop it in the files directory of the port.


Please forgive a really dumb question, but how does one go about doing that? My alternative now is to just copy off the modified files and drop them back in later after an update.


----------



## phoenix (May 16, 2013)

```
# cd /usr/ports/<whatever>/<whatever>
# make patch
# cd work/<srcdir>
# cp options.h options.h.orig
# ee options.h
# diff -u options.h.orig options.h > ../../files/patch-options.h
# cd ../..
# make clean
# make patch
<check that options.h got patched correctly>
# make build
<repeat the patch, edit, diff, clean, build steps as needed>
```


----------



## bkouhi (May 16, 2013)

If you want to create a patch for a file, make a copy of that file with .orig extension. Then edit the file and apply your changes. Finaly run `make makepatch` in the port directory. The patch file will be saved in the files directory.

For example, I want to create a patch for something.c:

`% make extract`
`% cd work/src      #  ${WRKSRC}` 
`% cp something.c something.c.orig`
`% ee something.c`
`% cd /path/to/port/directory`
`% make makepatch`

EDIT: Sorry, posted at same time with @phoenix.


----------



## phoenix (May 17, 2013)

Oh, there's a makepatch target? Cool. That simplifies things quite a bit.


----------



## wblock@ (May 18, 2013)

phoenix said:
			
		

> Oh, there's a makepatch target? Cool. That simplifies things quite a bit.



Yes, but last I looked it gives patches poor names.  The Porter's Handbook shows the preferred style, using the path as part of the name.


----------



## jronald (May 18, 2013)

phoenix said:
			
		

> ```
> # cd /usr/ports/<whatever>/<whatever>
> # make patch
> # cd work/<srcdir>
> ...



`# diff -u options.h options.h.orig > ../../files/patch-options.h`
should be
`# diff -u options.h.orig options.h > ../../files/patch-options.h`


----------



## jronald (May 18, 2013)

bkouhi said:
			
		

> If you want to create a patch for a file, make a copy of that file with .orig extension. Then edit the file and apply your changes. Finaly run `make makepatch` in the port directory. The patch file will be saved in the files directory.
> 
> For example, I want to create a patch for something.c:
> 
> ...



I think makepatch is a good interface, but the implementation that hard coding the file name as *.orig is not very good, I preferred the diff way.


----------



## phoenix (May 18, 2013)

jronald said:
			
		

> ```
> # diff -u options.h options.h.orig > ../../files/patch-options.h
> ```
> should be
> ...



Oh. Good catch. Thanks. Was going by memory.


----------



## phoenix (May 18, 2013)

wblock@ said:
			
		

> Yes, but last I looked it gives patches poor names.  The Porter's Handbook shows the preferred style, using the path as part of the name.



Yeah, but can't you just rename the patch file after its created?  I've never used makepatch, or even heard of it until now, so not sure exactly how I works.


----------

