Skip to content

Commit 3321648

Browse files
author
newnix
committed
Simplified Build Process
* Makefile - Simplified the build process by using suffix rules as defined in the POSIX Makefile specification - Still leaning on the BSD make conditionals for changing compilation options, but will move to using include directives * README.md - Updated to note what dependencies are needed (libc and sqlite3, as well as build tools)
1 parent b2a65b4 commit 3321648

12 files changed

+35
-35
lines changed

Makefile

+14-35
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.POSIX:
22

33
## This really shouldn't be overridden
4-
PROJECT ?= nombre
4+
PROJECT = nombre
55
## Invoke with -DDVCS=git to use the git functions instead
66
DVCS ?= fossil
77
## Set the suffixes to catch all .c and .o files
@@ -23,18 +23,20 @@ DBG =
2323

2424
## Flags used to build under GCC
2525
## Generic flags
26-
LIBS = -L/usr/local/lib -L/usr/lib -lsqlite3 #-lpthread -lc
26+
LIBS = -L/usr/local/lib -L/usr/lib -lsqlite3 -lc
2727
INCS = -I/usr/local/include -I/usr/include
2828
## List of *.c files to build
2929
SRCS = nombre.c initdb.c dbverify.c parsecmd.c subnom.c
30-
SRCDIR = src/
30+
HEADERS = $(SRCS:.c=.h)
31+
OBJ = $(SRC:.c=.o)
32+
3133

3234
## TODO: Figure this out
3335
.if ${CC:Mclang-devel} || ${CC:Mclang}
3436
## Flags used to build under Clang/LLVM
3537
## Not all flags exist or mean the same for all compilers
3638
WARN = -Wextra -Wall -Wparentheses -Weverything -pedantic
37-
LDFLAGS= --icf=safe -z relro -z now -z combreloc
39+
LDFLAGS= -z relro -z now -z combreloc #--icf=safe
3840
CFLAGS = -std=${STD} -c -Oz -fpic -fpie -fPIC -fPIE \
3941
-fvectorize -fstack-protector -fstrict-enums -fstrict-return -fstack-protector-strong \
4042
-fmerge-all-constants -fstack-protector-all -Qn -fstrict-aliasing \
@@ -102,12 +104,12 @@ help:
102104
check: ${SRCS}
103105
@clang-tidy-devel -checks=* $?
104106

105-
debug: mkdest bin/nombre
107+
debug: mkdest nombre
106108
@echo "[${.TARGET}]: Working in ${.CURDIR}"
107-
(cd "${.CURDIR}/bin" && install -vm ${BINMODE} ${TARGET} ${PREFIX}${DESTDIR})
109+
install -vm ${BINMODE} ${TARGET} ${PREFIX}${DESTDIR}
108110
${PREFIX}${DESTDIR}/${TARGET} ${HELP}
109111

110-
install: mkdest bin/nombre
112+
install: mkdest nombre
111113
@echo "[${.TARGET}]: Working in ${.CURDIR}"
112114
@strip -s bin/${TARGET}
113115
@install -vm ${BINMODE} bin/${TARGET} ${PREFIX}${DESTDIR}
@@ -125,39 +127,16 @@ mkdest: dirs
125127
## including the test directory
126128
dirs:
127129
@echo "[${.TARGET}]: Working in ${.CURDIR}"
128-
@mkdir -pm 1750 ${.CURDIR}/bin
129-
@mkdir -pm 1750 ${.CURDIR}/obj
130-
@mkdir -pm 1750 ${.CURDIR}/src
131130
@mkdir -pm 1750 ${.CURDIR}/test
132131

133132
## Build the object files
134-
objects: ${.OBJDIR}/nombre.o ${.OBJDIR}/initdb.o ${.OBJDIR}/dbverify.o ${.OBJDIR}/parsecmd.o ${.OBJDIR}/subnom.o
135-
@echo "[${.TARGET}]: Built object files"
136-
137-
${.OBJDIR}/nombre.o: ${SRCDIR}nombre.c
138-
@echo "[${.TARGET}]: Compiling ${.OODATE}"
139-
@$(CC) ${INCS} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
140-
141-
${.OBJDIR}/initdb.o: ${SRCDIR}initdb.c
142-
@echo "[${.TARGET}]: Compiling ${.OODATE}"
143-
@$(CC) ${INCS} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
144-
145-
${.OBJDIR}/dbverify.o: ${SRCDIR}dbverify.c
146-
@echo "[${.TARGET}]: Compiling ${.OODATE}"
147-
@$(CC) ${INCS} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
148-
149-
${.OBJDIR}/parsecmd.o: ${SRCDIR}parsecmd.c
150-
@echo "[${.TARGET}]: Compiling ${.OODATE}"
151-
@$(CC) ${INCS} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
133+
.c.o:
134+
$(CC) ${CFLAGS} -c $<
152135

153-
${.OBJDIR}/subnom.o: ${SRCDIR}subnom.c
154-
@echo "[${.TARGET}]: Compiling ${.OODATE}"
155-
@$(CC) ${INCS} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
136+
$(OBJ): ${HEADERS}
156137

157-
## Link the object files
158-
bin/nombre: objects obj/nombre.o obj/initdb.o obj/dbverify.o obj/parsecmd.o obj/subnom.o
159-
@echo "[${.TARGET}]: In ${.CURDIR}, Linking ${.ALLSRC:M*.o}"
160-
(cd ${.CURDIR} && ${LD} ${LIBS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC:M*.o})
138+
$(PROJECT):
139+
$(CC) -o $@ $(OBJ) ${LDFLAGS}
161140

162141
push:
163142
@gitsync -r ${PROJECT} -n master

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
A simple SQLite3 database manager for recording and retrtieving terms, like having your own dictionary in
44
a single database file with a small binary utility to manage it.
55

6+
## Dependencies
7+
All my primary systems are some form of BSD, so the GNU build tools are not regularly tested. To that end,
8+
the Makefile used here is designed with some conditionals that change the compilation behaviour based on the given
9+
value of `CC` when processing the file. It is possible to replicate this functionality in other formats, but I can't
10+
guarantee a timetable for support.
11+
12+
Build Dependencies:
13+
14+
* A C99 compliant compiler and linker (CC and Clang/LLVM are fine)
15+
* BSD Make (often called `bmake` in Linux distro repos
16+
* Standard C header files (Consider installing the libc-devel packages on Linux distros)
17+
* SQLite3 header files (Possibly a separate -devel package)
18+
* The SQLite3 library (Probably already installed)
19+
20+
Runtime Dependencies:
21+
22+
* A POSIX-ish OS
23+
* A C99 compliant C library (optional)
24+
* The SQLite3 library (optional)
25+
26+
627
## Interface
728
The `nombre(1)` interface is a semi-natural language command line primarily driven by the use of subcommands,
829
which will then construct and run SQL queries to interface with the database on your behalf. This allows
File renamed without changes.
File renamed without changes.

src/initdb.c renamed to initdb.c

File renamed without changes.

src/initdb.h renamed to initdb.h

File renamed without changes.

src/nombre.c renamed to nombre.c

File renamed without changes.

src/nombre.h renamed to nombre.h

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/subnom.c renamed to subnom.c

File renamed without changes.

src/subnom.h renamed to subnom.h

File renamed without changes.

0 commit comments

Comments
 (0)