Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefiles / pkgs-config #21

Open
dustinlacewell opened this issue Dec 21, 2021 · 3 comments
Open

Makefiles / pkgs-config #21

dustinlacewell opened this issue Dec 21, 2021 · 3 comments
Assignees

Comments

@dustinlacewell
Copy link

I'm new to C, tried to integrate this for a weekend hackathon project, couldn't get it integrated dependency of the project.

Any chance you'd consider writing a Makefile/pkg-config for Gena?

@dustinlacewell
Copy link
Author

I was able to package up Gena as a static library in a minimal way for NixOS/Nix with the following derivation:

{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation rec {
    pname = "gena";
    version = "dev";

    src = ./.;

    dontPatch = true;
    dontInstall = true;

    buildPhase = ''
      # create output paths
      mkdir -p $out/lib/
      mkdir -p $out/lib/pkgconfig/
      mkdir -p $out/include/gena/

      # compile library
      gcc -c genvector/genvector.c -o genvector.o
      gcc -c gentreemap/gentreemap.c -o gentreemap.o
      gcc -c gentreeset/gentreeset.c -o gentreeset.o
      ar cr $out/lib/libgena.a genvector.o gentreemap.o gentreeset.o

      # copy headers
      cp -r genvector gentreemap gentreeset routines $out/include/gena/

      # copy pkg-config file
      cp gena.pc $out/lib/pkgconfig/
      substituteInPlace $out/lib/pkgconfig/gena.pc \
        --replace @pkgname@ $pname \
        --replace @version@ $version \
        --replace @libdir@ $out/lib/gena/ \
        --replace @includedir@ $out/include/gena/ \
    '';
  }

With the following pkg-config .pc file:

libdir=@libdir@
includedir=@includedir@

Name: @pkgname@
Version: @version@
Description: Pure C vector library
URL: https://github.com/cher-nov/Gena
Libs: -L${libdir} -lgena
Cflags: -I${includedir}/genvector -I${includedir}/gentreemap -I${includedir}/gentreeset

No idea if that helps you out.

@cher-nov
Copy link
Owner

cher-nov commented Dec 22, 2021

Nice to see you here! And first of all - thank you for your effort!
From the first glance it seems for me that you've got almost everything right, the library was really supposed to have a customizable configuration. But gentreemap and gentreeset also depend on routines/internal/avl_tree, which you forgot to include, so I doubt that it would link. :)

Any chance you'd consider writing a Makefile/pkg-config for Gena?

I really want to do that, but for this I would like to find a proper build system that suits these requirements:

  1. Either at least fully declarative or (what is more preferable) imperative with ability to load project structure from a separate declarative configuration file (e.g. JSON).
  2. Without conventions for the specific structure of project directories.
  3. Minimalistic (without requiring e.g. Java runtime to work).
  4. Actively developed.

As for declarativeness, it allows a third-party developer to perform an automated project build without using the original assembly script. This is obviously useful for environments where that build system may be not available for some reason.

I would not like to use pkg-config / libtool as this library is not supposed to be used as a shared one (i.e. to be a package). Rather, in terms of build workflow, I would prefer something like CMake, just not that retarded.

@dustinlacewell
Copy link
Author

I literally started with C/C++ again this week after 15 years or so I have no valuable insight to provide. But I can say, C sorely needed a contemporary basic data structures library. If you're curious where your library is being used, I'm looking into adding a JS scripting API to the Mupen64 emulator. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants