I still don't know how to write Makefile after learning C? Is there any good source to learn about Makefile?
How to write Makefile right?
Read the GNU make manual; and, try not to use too many GNUisms (GNU make-specific stuff) in the Makefiles you write.
strawman2511 I would recommended try this with pkgsrc as practical way to create Makefile and building process
“Only the paranoid survive.”
― Harold Finch
NetBSD VPS , NetBSD , OS108
- Edited
The way pkgsrc uses make is very non-standard, no? It has an entire huge "library" in mk/
that you won't have if you're making your own build process for your own software.
The two major BSD and GNU make dialects are pretty different, and have lots of features that you may or may not want to use.
The Open Group documentation describes the simplest possible subset of both, POSIX make. It might be useful to learn at first, before you want to use any of the shinier non-standard features: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
- Edited
nia Definitely a must-have-link! But ... :-( ... I'd miss $(.MAKE.MAKEFILES)
... :…( ... If I'd stick to the standard.
(yeti@kumari:71)~$ cat Makefile
# help @1573910376
#!# Guess what ;-)
help:
@awk '\
BEGIN { FS=":" ; n=0 } \
match($$0,"^#!# .*$$") { \
d[n]=substr($$0,RSTART+4,RLENGTH-3) ;\
getline ;\
t[n++]=$$1 ;\
if(l<length($$1)) l=length($$1) \
} \
END { \
for(i=0;i<n;i++) printf"%*s - %s\n",l,t[i],d[i] \
}' $(.MAKE.MAKEFILES)
.PHONY: help
(yeti@kumari:71)~$ make
help - Guess what ;-)
Yay, I guess that people always recommend POSIX standard for me to learn Makefile
. I will give a try when I am free