Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Nov 2017 11:42:07 +0800
From:      blubee blubeeme <gurenchan@gmail.com>
To:        Adam Weinberger <adamw@adamw.org>
Cc:        FreeBSD Ports <freebsd-ports@freebsd.org>
Subject:   Re: a project with custom makefile
Message-ID:  <CALM2mE=Ma=sGE=0N_Bzri8vwECW%2Bq%2BcvxiLvfGPBPoimo%2Bm5Tw@mail.gmail.com>
In-Reply-To: <90470926-1E50-4CD9-A797-9D013B9B68D5@adamw.org>
References:  <CALM2mEmzY8uNpbjfP5DUTd1YEMxbtjyA0zaz%2Bhkd9UM6jZHuzQ@mail.gmail.com> <90470926-1E50-4CD9-A797-9D013B9B68D5@adamw.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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?


On Sat, Nov 25, 2017 at 6:15 AM, Adam Weinberger <adamw@adamw.org> wrote:

> > On 24 Nov, 2017, at 14:23, blubee blubeeme <gurenchan@gmail.com> wrote:
> >
> > I have a port that has different directories each with it's own makefile
> > that creates some binaries in subdir/bin
> >
> > A typical makefile from this project looks like this:
> > -------------------------------------------------------
> > # Install
> > BIN = x11
> >
> > # Flags
> > CFLAGS = -std=c89 -pedantic -O2 `pkg-config --cflags --libs x11`
> >
> > SRC = main.c
> > OBJ = $(SRC:.c=.o)
> >
> > $(BIN):
> > @mkdir -p bin
> > rm -f bin/$(BIN) $(OBJS)
> > $(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) -lX11 -lm
> > -------------------------------------------------------
> >
> > There's a few things that I need to do to this makefile to make it work
> > first I have to remove -lX11 and -lm from the $(CC) line
> >
> > second I have to add `pkg-config --cflags --libs x11` to the CFLAGS line.
>
> So put patches in files/, or use REINPLACE_CMD. Read the Porter's Handbook
> for instructions on how to do this.
>
> > if I go into the folder and run make, it builds and put the executable in
> > the bin directory inside that sub folder.
> >
> > when I make the edits as listed above and then try to use FreeBSD
> Makefile.
> >
> > OPTIONS_DEFINE= X11
> >
> > x11_DESC=                     X11 sample
> >
> >
> > .include <bsd.port.pre.mk>
> > do-build:
> > .if ${PORT_OPTIONS:Mx11}
> > @(${DO_MAKE_BUILD} -C ${WRKSRC}/demo/x11/)
> > .endif
> > .include <bsd.port.post.mk>
> >
> > This DO_MAKE_BUILD command builds the executable and puts it in the
> > subdir/bin folder but I get an error cannot open Makefile.
> >
> > /usr/local/include/X11/Xfuncproto.h:174:24: warning: named variadic
> macros
> > are a GNU extension [-Wvariadic-macros]
> > #define _X_NONNULL(args...)  __attribute__((nonnull(args)))
> >                       ^
> > 1 warning generated.
> > ===>  Staging for nuklear-1.0
> > ===>   Generating temporary packing list
> > make[2]: cannot open Makefile.
> >
> > Is there a straight forward way to fix this issue or do I need to write a
> > makefile or cmake file and try to get that upstream?
>
> Most likely, there's no Makefile in WRKSRC. Either override do-install,
> add in a working Makefile, or change WRKSRC to somewhere with a Makefile.
>
> "blubee", you have a habit of asking lots of questions and not giving us
> the Makefile. It's very hard to give you answers without all the context.
> Please, give us the Makefile when you are asking for help with a Makefile.
>
> # Adam
>
>
> --
> Adam Weinberger
> adamw@adamw.org
> https://www.adamw.org
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALM2mE=Ma=sGE=0N_Bzri8vwECW%2Bq%2BcvxiLvfGPBPoimo%2Bm5Tw>