# How to tweak the source of an existing port ?



## Nicola Mingotti (Jan 15, 2019)

Hi guys, 

Today i was trying to modify the port /usr/ports/editors/texmacs
It is the first time i do such thing and I guess I am missing the master way.

I need to do a slight modification to the C++ code, but since I am hunting
for a bug I need to do many trials, modfiy, compile and run many times. 

The best way i found is this:

```
while (true) {
$> sudo make patch
==> my C modifications ====
$> sudo make build
==> check if the bug is gone, since i am here it is not, so
$> sudo make clean
}
```

It goes without saying that this is BAD, for each tiny modification i must recompile
all TeXmacs which quite long and boring.

Is there a better option ? 

bye
Nicola


----------



## Nicola Mingotti (Jan 15, 2019)

I found this OLD thread where user jalla proposes a solution, i will try to see if it still works.


----------



## aragats (Jan 15, 2019)

jalla said:


> You don't have to _make clean_, just remove a couple of files from /usr/ports/whatever/portname/work
> 
> ```
> # rm work/.build_done.portname._usr_local work/.install_done.portname._usr_local
> ```


I don't think it helps now...
It won't rebuild after I change a source file.


----------



## Nicola Mingotti (Jan 15, 2019)

Very wired aragats !

To me it works, i am super happy about this easy method
and I also somehow corrected the TeXmacs port thanks to this.

I put this in the port directory

```
----- my-remake.sh -----------
#!/bin/sh

echo "--- Remove built signal ----"
rm work/.build_done.texmacs._usr_local

echo "--- Re-Make --- "
make build
------------------------------------
```
Then I modified the code at least 10 times and run for each of them
`$> sudo ./my-remake`
Tested Texmacs locally after the make, It never failed.

In what port are you trying ?

bye
n.


----------



## aragats (Jan 15, 2019)

I made some changes to sysutils/u-boot-beaglebone (to eliminate the flood of boot messages I mentioned in another thread).
So, this method didn't work, I had to make my own patch and add the corresponding path to `EXTRA_PATCHES=` in the Makefile.


----------



## Nicola Mingotti (Jan 15, 2019)

I tried to check but I can't compile it, it requires perl-5.28.0 and here i have only perl-5.28.1.
I may see on a BBB, but I don't have them here at office.

I red about the patch method in the old thread, that is ok when you already know what changes
to make and you wish to stabilized them. 

I am using FreeBSD-11.2, what are you using? Maybe they changed the bsd.port.mk (i hope not)

Are you compiling on the BBB ?

I am NOT using poudriere ! I still had no time to learn that


----------



## aragats (Jan 15, 2019)

I'm using FreeBSD 12.0-RELEASE on my amd64 desktop.
I guess, all u-boot* ports exist only for ARM anyway. My compiled  MLO and u-boot.img perfectly work with BBB.


----------



## Nicola Mingotti (Jan 16, 2019)

What happens if you go to

```
$> cd /usr/ports/sysutils/u-boot-beaglebone
#> make build
```
then

```
$> cd /usr/ports/sysutils/u-boot-beaglebone/work/u-boot-2018.09
--- change some code
$> make
```
does it run ? If not maybe is the original-project-makefile which is not detecting time of change in sources
(just an idea, I don't know if that is even possible)

Other thing,
I just build the patch, then out of curiosity I made this experiment:

Suppose I am operating on file foo.c

```
#> cd WHERE-NEEDED
#>  cp foo.c  foo.c.orig
loop:
   #> edit file foo.c
   #> cd "port base dir"
   #> make makepatch
   #> make patch
   #> make build
```
For what I can see, it is seems to me the port does not get rebuilt when I change foo.c.

To me the only two option remains

 make clean         --- slow
 "jalla" method      --- fast  (but in your case not working)
Does your EXTRA_PATCH way force the rebuild if you change the patch (and you do not make clean)?


----------



## aragats (Jan 16, 2019)

Nicola Mingotti said:


> What happens if you go to
> $> cd /usr/ports/sysutils/u-boot-beaglebone
> #> make bulid
> then
> ...


If I run `make` at the top level it doesn't build, just silently exits.
If I run `make` in the actual directory, it spits out a lot of errors. I guess, it may work for certain ports, but won't be a universal approach.


Nicola Mingotti said:


> Does your EXTRA_PATCH way force the rebuild if you change the patch (and you do not make clean)?


No, it doesn't trigger a build, `make` doesn't do anything...


----------

