I'm not sure if I phrased the question in the most terse way, but here's an example:
I have a program written in C (specifics don't matter)
main() { // Made up example char *ui_definition = readfile("./ui.xml"); ui *baseUI build_ui(ui_definition); run_ui(baseUI); }
Suppose that was main.c, a simple build system to install it could be
.POSIX: DESTDIR = PREFIX = /usr/local all: prog prog: main.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ main.o main.o: main.c clean: @rm -f prog main.o install: mkdir -p $(PREFIX)$(DESTDIR)/bin cp prog $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/prog uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/prog
This seems fine, but then prog no longer has ui.xml to read. I could copy it to bin, as well, but typically only binaries go there. I could re-write the code for it to, say, search in /usr/local/share/myapp/ui.xml instead, but PREFIX is usually changed when installing via package manager / etc – e.g. make PREFIX=/usr DESTDIR=fakeroot install. One solution could be to write a configure script like
#!/bin/sh for arg do opt="${x%%=*}" var="${x#*=}" case "$opt" in --prefix) PREFIX="$var" ;; esac done : "${PREFIX:=/usr/local}" printf "PREFIX = %s\n" "$PREFIX" > config.mk printf "const char *PREFIX = \"%s\";\n" "$PREFIX" > paths.h if [ -e Makefile.in ] then mv Makefile.in Makefile fi
And have a Makefile.in include the generated config. Then, have the program include the "paths.h" However, I still want the ability to build it and test the app in the same directory without having to install it.
If anyone has any suggestions, I would like to mention I would like to
- NOT use gnu auto tools
- Use a Makefile compliant with IEEE / Open Group 1003.1-2017 (POSIX.1-2017) make (no +=, ?=, etc)
- Use C code ISO / IEC 9899:1999 (C99) compliant
- If using a configure script, use IEEE / Open Group 1003.1 (POSIX.1-2017) sh language / utilities
If anyone is curious what the specifics are, it's shaders for opengl and ui files for GTK builder.
I'm a little new to software development and thus don't really have a lot of experience on how to handle runtime dependent files whose location depends on the build / install. Any tips would be amazing ^^
submitted by /u/Kawaii_Amber
[link] [comments]
from Software Development – methodologies, techniques, and tools. Covering Agile, RUP, Waterfall + more! https://ift.tt/LUDmCWa