Skip to content

Conversation

@astralchan
Copy link

@astralchan astralchan commented Jan 14, 2022

If the goal is to make this portable via POSIX compatibility, this makefile is more portable. I assume the goal is to make it POSIX based off of the source and docs, correct me if I'm wrong. Conditional assignment (VAR ?= VALUE) is not POSIX (see make(1p), it's behaviour is unspecified. The .PHONY rule, while handy for recipes, is not POSIX. In this case, there will never be files that evaluate to the clean, debug, install, or uninstall target names, so it's unneeded anyways. Some choose to keep .PHONY in POSIX makefiles just for good practice even though it's not specified. The special .POSIX target ensures that CC is c99 (no need for -std=c99) and that the .c single suffix rules for source files evaluates to: $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<. I tried to make a clean-looking debug rule, but meh. Typically, debug is not a rule in makefiles. Users and packagers typically override variables with the make command; e.g. make PREFIX=/usr install, etc. Same with CC variable. makefile is matched before Makefile (see make(1p)). I seperated the build and install rule. Typically, you don't want to build as root. The flow of the makefile build system is to build as a user, then install as root to properly set permissions. That is:

$ make <- run as a user; that user can then always clean up the generated files with make clean / do other things before installing
# make install <- install to the system, user can no longer change the system files without being root

Tested with GNU Make, CI check seems to be hardcoded to match for Makefile.

If 79 is merged (I highly recommend, with the overhead that pthread needs, threading actually slows down the program in this case.) just remove the LDFLAGS = -lpthread line.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant