Closed CongMNguyen closed 1 year ago
Thank you professor
just saving for myself:
Makefile
itself can be made to essentially supply just the variables' definition to make
, --debug=why
is added in GNU make v4.4 (2022-10). Unfortunately cs50.dev is still using GNU make v4.3 (2020-01)MAKEFLAGS += --debug=why
# MAKEFLAGS += --no-silent
# MAKEFLAGS += --warn-undefined-variables
CC := clang
CFLAGS := -std=c11
# Below are common C[XX]FLAGS
CCFLAGS += -ferror-limit=1 -gdwarf-4 -ggdb3 -O0
CCFLAGS += -Wall -Werror -Wextra
CCFLAGS += -Wno-gnu-folding-constant -Wno-sign-compare
CCFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable
CCFLAGS += -Wshadow
CFLAGS += $(CCFLAGS)
# LDLIBS := -lcrypt -lcs50 -lm
LDLIBS := -lm
# Following is for use with IDEs like Geany, Kate, Eclipse, IntelliJ, PyCharm, etc
.PHONY: all
all: # <pset_file_basename_i.e._without_extension>
# EXE = foo
# SRCS = foo.c bar.c
# OBJS = $(SRCS:.c=.o)
# $(EXE): $(OBJS)
# $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS)
# https://cs50.readthedocs.io/libraries/cs50/c/#makefile
# https://github.com/cs50/libcs50/issues/287
for using on windows, as these vars are essentially common to all the cs50x psets based on c-lang so, just cmd /c mklink /h Makefile <pset>\Makefile
(ref: howtogeek/win-symlink)
References:
--debug=why
shows following output:
$ make --debug=why inheritance
<builtin>: update target 'inheritance' due to: inheritance.c
MAKEFLAGS
variable:
declare mk="$(curl "https://www.gnu.org/software/make/manual/make.txt")"
then do:
tac - <<< "$mk" | grep flags -m7 -A4 | tac
# ^~~~ A(fter) since `tac`ed
Or equivalently:
echo "$mk" | bat # then do: `?flags` and hope for it to wrap back and show search results from last
I've been struggling with it all day and just found a way to create a makefile. But folders that do not contain makefile files will not automatically link to the cs50 library.