a project with custom makefile

Adam Weinberger adamw at adamw.org
Sat Nov 25 03:57:13 UTC 2017


> On 24 Nov, 2017, at 20:42, blubee blubeeme <gurenchan at gmail.com> wrote:
> 
> I apologize for not being clear, I can get really long winded and try to control myself.
> The project that I want to port is nuklear which is a single header gui library: https://github.com/vurtun/nuklear
> 
> If you look at the source code then demo folder: https://github.com/vurtun/nuklear/tree/master/demo
> you'll see there are demos for practically every rendering backend from x11 to glfw.
> 
> I like this because it makes GUI very easy and I can avoid a lot of the troubles with bigger packages such as QT, Gnome, etc...
> 
> Let's look at the simplest project which is demo/x11: https://github.com/vurtun/nuklear/tree/master/demo/x11
> 
> There's the makefile and main.c and the nuklear_xlib.h header.
> 
> The makefile is very straight forward: https://github.com/vurtun/nuklear/blob/master/demo/x11/Makefile
> but it doesn't fit in with the FreeBSD build system or at least I don't really get how to make things build smoothly.
> 
> My current ports makefile looks like this:
> 
> OPTIONS_DEFINE=	x11
> 
> x11_DESC=	Nuklear X11 Demo
> 
> USE_GITHUB=	yes
> GH_ACCOUNT=	vurtun
> GH_TAGNAME=	36a396f
> 
> .include <bsd.port.pre.mk>
> do-build:
> .if ${PORT_OPTIONS:Mx11}
> 	@(${DO_MAKE_BUILD} -C ${WRKSRC}/demo/x11/)
> .endif
> .include <bsd.port.post.mk>
> 
> Initially I was using replace cmd and sed to change parts of the files but that got really tedious so I made a patch file:
> 
> --- demo/x11/Makefile.orig	2017-11-24 21:08:07 UTC
> +++ demo/x11/Makefile
> @@ -1,8 +1,8 @@
>  # Install
> -BIN = zahnrad
> +BIN = x11-zahnrad
>  
>  # Flags
> -CFLAGS = -std=c89 -pedantic -O2
> +CFLAGS = -std=c89 -pedantic -O2 `pkg-config --cflags --libs x11`
>  
>  SRC = main.c
>  OBJ = $(SRC:.c=.o)
> 
> That's obviously wrong, maybe I'll have to change the ${WRKSRC} depending on the options that's selected
> or
> write a cmake file and get that upstreamed to the developer.
> 
> I'd think cmake might be a better option since it's easier to maintain in the long run.
> 
> Hope this clarifies what I'm trying to do and I'd still like some feedback as to which path the community would recommend; writing a cmake file, make many patch files and deal with that possibly breaking in the future or some other options that I didn't think about yet?

The error that you gave earlier says that there's no Makefile in ${WRKSRC}. The default do-install essentially runs "make -C ${WRKSRC} install", so without a Makefile, it produces an error.

Writing cmake files seems pretty overkill. Your port appears to build just one file. So just make your own do-install: target and install the files yourself. There are 5,995 examples of this in the ports tree, and the Porter's Handbook has an entire section on installing files.

# Adam


-- 
Adam Weinberger
adamw at adamw.org
https://www.adamw.org



More information about the freebsd-ports mailing list