# Linux makefiles



## balanga (Feb 13, 2016)

Is there any way of using Linux makefiles on FreeBSD?


----------



## chrbr (Feb 13, 2016)

You might have to modify them slightly to match to the system. But basically the answer should be yes. May be https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/ gives some detailed answers.


----------



## kpa (Feb 13, 2016)

They are almost certainly written for devel/gmake and do not work with the system make(1).


----------



## balanga (Feb 13, 2016)

Does that mean I should be able to make them using gmake?


----------



## tobik@ (Feb 13, 2016)

Yes, that's the first thing to try. But sometimes you'd need to adjust the makefiles, because they were written with Linux in mind.


----------



## balanga (Feb 13, 2016)

Seems to work.... almost...

I was trying to build ipxe http://ipxe.org/download and got quite a way before an error occurred


```
[BUILD] bin/config.o
In file included from config/config.c:27:0:
./config/settings.h:20:35: fatal error: config/local/settings.h: No such file or directory
#include <config/local/settings.h>
  ^
compilation terminated.
Makefile.housekeeping:850: recipe for target 'bin/config.o' failed
gmake: *** [bin/config.o] Error 1
root@support:~/ipxe/src #
```

I guess I need to install some extra headers from somewhere.....


----------



## tobik@ (Feb 13, 2016)

Building iPXE succeeds on my FreeBSD 10.2 desktop with some tweaks. I installed devel/gcc5 and started the build with `gmake CC=gcc5 HOST_CC=gcc5`. There seems to be some issues with generating bin/ipxe.iso, so I don't think the ISO is usable, but the other images seem fine.

I might as well create a port at this point...

EDIT: I see that there is already net/gpxe (which does not build on FreeBSD >= 10 however).

EDIT 2: A work-in-progress port is at https://github.com/t6/wip-ports/tree/master/net/ipxe. The installed ISO is not usable however.


----------



## tobik@ (Feb 13, 2016)

Fixed the ISO issue and submitted port as PR 207166.


----------



## balanga (Feb 13, 2016)

This is brilliant news_. _I managed to build it myself, although I assume you meant lang/gcc5-devel as the above pkg doesn't exist.

I managed to test ipxe.pxe and undionly.kpxe on my PXE boot server and both worked although I'm not sure of what the difference is between them. One problem in my case was that an x86-64 CPU was required when I tried

`iPXE> chain http://boot.ipxe.org/demo/boot.php`

Is there an option to make this work for an i686 CPU.


If you are familiar with IPXE maybe you could explain how to make scripting work.

I get this when booting a PXE client:


```
Next server: 192.168.1.1
Filename: ipxe.pxe
Root path: tftpboot
Ignoring unsupported root path
tftp://192.168.1.1/ipxe.pxe... ok
```

No idea why the root path is unsupported. It works with PXELINUX.


----------



## tobik@ (Feb 13, 2016)

balanga said:


> I managed to test ipxe.pxe and undionly.kpxe on my PXE boot server and both worked although I'm not sure of what the difference is between them.


ipxe.pxe contains all network drivers iPXE supports and can be used with or without a PXE ROM. undionly.kpxe can only be used if you chain load iPXE from your card's PXE ROM which supports the Universal Network Device Interface (=> UNDI only).



balanga said:


> I managed to test ipxe.pxe and undionly.kpxe on my PXE boot server and both worked although I'm not sure of what the difference is between them. One problem in my case was that an x86-64 CPU was required when I tried
> 
> 
> iPXE> chain http://boot.ipxe.org/demo/boot.php
> ...


The demo is probably 64-bit only. That URL returns the following iPXE script:

```
#!ipxe

kernel vmlinuz-3.16.0-rc4 bootfile=http://boot.ipxe.org/demo/boot.php fastboot initrd=initrd.img
initrd initrd.img
boot
```
 and vmlinuz-3.16.0-rc4 is 64-bit only. If you supply your own iPXE script with your own kernel via your own HTTP server it should work. Making this work with your own server is really simple. Just put the above script and all referenced files in the same directory on your web server and give iPXE that URL.


----------



## balanga (Feb 13, 2016)

At the moment I'm trying to concentrate on migrating from PXELINUX to IPXE and would like to get the functionality of YUMI (http://www.pendrivelinux.com/yumi-multiboot-usb-creator/) onto my PXE boot server ie a pfSense box (https://www.pfsense.org/).

I have found an IPXE binary which almost produces what I want - https://releng.archlinux.org/pxeboot/ipxe_text.pxe. I have the means, thanks to your advice, to build IPXE binaries, now I just need to figure out how to incorporate scripts into the binary... 

There is an example here http://ipxe.org/embed but I can't get it to work.


----------



## tobik@ (Feb 13, 2016)

I think I'm going to update the port tomorrow to allow embedding of scripts. I did not know that you could do that. That would make it a lot more useful.


----------



## tobik@ (Feb 14, 2016)

I've updated the port. The example script on http://ipxe.org/embed is indeed broken. There is no timeout command anymore etc. The build instructions work however.

With the port you can embed a script by compiling the port with `make IPXE_EMBED=/path/to/ipxe/script`


----------



## balanga (Feb 14, 2016)

I'll give this a try later on...

Specifically I would like to have the functionality described here: - http://www.wonkity.com/~wblock/docs/html/pxe.html

Will you provide some sample scripts to look at?


----------



## tobik@ (Feb 14, 2016)

Here is a script that can boot Debian and FreeBSD with iPXE (over the internet, booting completely unverified images. Don't use in the real world!):

```
#!ipxe 
prompt --key 0x02 --timeout 2000 Press Ctrl-B for the iPXE command line... && shell ||

menu Please choose an image to boot
item debian Debian Jessie
item mfsbsdmini mfsBSD 10.2-RELEASE 
choose --default debian --timeout 10000 img && goto ${img}

:debian
ifconf
sanhook http://ftp.de.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/mini.iso
sanboot --keep

# Loading FreeBSD this way is very, very slow. Be patient!
# root password is mfsroot
:mfsbsdmini
ifconf
sanhook http://mfsbsd.vx.sk/files/iso/10/amd64/mfsbsd-mini-10.2-RELEASE-amd64.iso
sanboot --keep
```


----------



## balanga (Feb 15, 2016)

Wow!

Is there any chance of creating a repository for such IPXE scripts? I think that once people realise how powerful they are their usage might become quite popular.

I'll try writing a few scripts for Clonezilla and SystemRescueCD today.


----------



## tobik@ (Feb 16, 2016)

balanga said:


> Is there any chance of creating a repository for such IPXE scripts?


Sure, why not? I've created a repository here: https://github.com/applicative-tech/ipxe-scripts
If you have any new scripts send me a pull request, or I can add you to the repository if you want.


----------



## balanga (Jan 22, 2018)

I get a 404 with that URL...


----------



## tobik@ (Jan 22, 2018)

balanga said:


> I get a 404 with that URL...


I deleted the repository a while ago because there was no interest in it. But the only script that was in it was what I already posted here.


----------

