in 2003 Google's build system was moved from a single Makefile to a per-directory design with better-managed, more explicit dependencies. A typical binary shrank about 40% in file size, just from having more accurate dependencies recorded.
Rob Pike

seen from United States
seen from United States

seen from United States
seen from China
seen from United States
seen from United States
seen from United States
seen from United States
seen from Hong Kong SAR China
seen from Brazil

seen from United States

seen from United States
seen from United States

seen from New Zealand
seen from Türkiye
seen from New Zealand

seen from United States

seen from United States

seen from United States
seen from Türkiye
in 2003 Google's build system was moved from a single Makefile to a per-directory design with better-managed, more explicit dependencies. A typical binary shrank about 40% in file size, just from having more accurate dependencies recorded.
Rob Pike

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
فهم ملفات Makefiles ودورها في أتمتة المهام البرمجية
ملفات Makefiles تعد من الأدوات المهمة التي يستخدمها المطورون لتنظيم وأتمتة العمليات البرمجية مثل التجميع والبناء. إذا كنت تتعامل مع مشاريع برمجية كبيرة، فإن Makefiles توفر طريقة فعالة لتبسيط المهام المتكررة وتحسين الإنتاجية. من خلال كتابة تعليمات محددة داخل ملف Makefile، يمكنك التحكم في خطوات بناء البرنامج وضمان تنفيذها بدقة وبالترتيب المطلوب. في هذا المقال، سنستعرض مفهوم Makefiles، أهم استخداماتها، وكيفية البدء في إنشاء ملفات Makefile الخاصة بك لتحسين سير عملك البرمجي.
النقاط الرئيسية - تستخدم Make ملفات Make، التي تعمل على أتمتة عمليات البناء عبر ملفات Make لتجميع التعليمات البرمجية بكفاءة. - تتكون ملفات Make من قواعد تحتوي على أهداف وتبعيات وإجراءات. - تتطلب ملفات Make المسافة البادئة باستخدام علامات التبويب وليس المسافات، لذا انتبه إلى المسافات الفارغة عند العمل مع ملفات Make. إذا قمت بتثبيت أي برنامج من التعليمات البرمجية المصدرية، فمن المحتمل أنك استخدمت Make. ولكن ما هو هذا البرنامج وكيف يعمل؟ تعرف على كل شيء عن ملفات Make وكيف يمكنها إحداث ثورة في عملية البناء الخاصة بك.
ما هو Makefiles؟
ترتبط ملفات Make والتجميع ارتباطًا وثيقًا. على الرغم من أنها ليست مخصصة للتجميع فقط، إلا أن برنامج Make نشأ بسبب الإحباطات التي يمكن أن يسببها التجميع. يأخذ التجميع ملفات المصدر ويحولها إلى شكل آخر. المثال الكلاسيكي هو ملف .c الذي يتم تجميعه إلى ملف كائن .o. تخضع برامج C أيضًا لعملية ربط تحول ملفات .o إلى ملف قابل للتنفيذ النهائي. في الواقع، هناك أربع مراحل منفصلة تشارك في بناء مشروع C:
انتشرت عملية التجميع في أوائل سبعينيات القرن العشرين مع تطور لغة C، ولكن اللغات الأحدث مثل Typescript وRust وSass تستخدمها أيضًا. البديل هو التفسير، الذي يستخدم برنامجًا وسيطًا لتشغيل التعليمات البرمجية بدلاً من إنشاء ملف قابل للتنفيذ مستقل. تشمل اللغات المفسرة JavaScript وPython وRuby. تعمل البرامج المترجمة عادةً بشكل أسرع - وأحيانًا أسرع كثيرًا - من البرامج المفسرة. يتحقق التجميع أيضًا من التعليمات البرمجية الخاصة بك بحثًا عن أنواع معينة من الأخطاء التي لا يمكن للتفسير التحقق منها إلا في وقت التشغيل، لذلك من الأسهل التأكد من صحة البرامج المترجمة. لكن التجميع يمكن أن يكون عملية بطيئة، خاصة بالنسبة للمشاريع التي تحتوي على مئات أو آلاف ملفات المصدر.
ماذا تفعل ملفات Makefiles؟
تستخدم ملفات Makefiles بواسطة Make، وهو برنامج يساعدك على أتمتة عملية البناء الخاصة بك، بما في ذلك المهام مثل التجميع. عند تشغيل أمر make، فإنه يبحث عن ملف يسمى Makefile أو makefile افتراضيًا. يجب أن يحتوي هذا الملف على تعليمات حول كيفية تجميع كل ملف في برنامجك أو إنشائه. تم بناء ملفات Makefiles حول مفهوم "التبعية" (أو "الشرط الأساسي") الذي يتحقق منه برنامج Make باستخدام طوابع زمنية للملفات. وهذا يعني أن برنامج Make يمكنه تسريع عملية التجميع بشكل كبير: فبدلاً من إعادة تجميع كل ملف مصدر، يقوم برنامج Make بإعادة بناء الحد الأدنى فقط. وبشكل عام، إذا تغير ملف المصدر، يقوم برنامج Make بإعادة تجميعه، وإلا فإنه يتركه كما هو.
كيف تبدو ملفات Makefiles؟
أول شيء يجب أن تعرفه عن ملفات Makefiles هو أن المسافات البيضاء كبيرة. ويُعتبر هذا على نطاق واسع قرار تصميم سيئ، لكننا عالقون فيه، لذا كن حذرًا! يحتوي ملف Makefiles على سلسلة من القواعد التي تصف كيفية بناء كل مكون. ويبدو النمط العام للقاعدة على النحو التالي: target: dependencies actions فيما يلي، في الأساس، أبسط ملف makefile، والذي يقوم بتجميع ملف مصدر واحد إلى ملف قابل للتنفيذ: program: program.c gcc -o program program.c تحذير السطر الثاني من ملف Makefile هذا مسنن، ويجب أن يكون التباعد حرف تبويب واحد. سواء كنت تقوم بنسخ ولصق ملف Makefile أو كتابته يدويًا، كن حريصًا جدًا على الاحتفاظ بحرف تبويب واحد في بداية الأسطر المسننة. على سبيل المثال، إذا استخدمت أربع مسافات بدلاً من علامة تبويب، فسترى خطأ مثل "Makefile:2: *** missing separator. Stop." في هذا المثال، الهدف هو اسم الملف القابل للتنفيذ النهائي: program. ليس من الضروري أن يتطابق الهدف مع اسم الملف، ولكن هذا يحدث عادةً. هناك اعتماد واحد فقط لهذا الهدف - program.c - سيستخدمه Make لتحديد ما يجب القيام به. إذا كان ملف "program" أحدث من "program.c"، فلن يفعل Make أي شيء.
كتابة ملف Makefile الأول
لا يوجد شيء مثل الخبرة العملية، ولحسن الحظ، يعد Make سهل الاستخدام في أبسط أشكاله. تثبيت Make على توزيعة Linux التي تستخدم apt، مثل Ubuntu أو Mint أو Debian، يمكنك تثبيت Make على النحو التالي: sudo apt install make على نظام macOS، يمكنك تثبيت Make عبر Xcode عن طريق تشغيل هذا الأمر: xcode-select --install بدلاً من ذلك، إذا كان لديك برنامج Homebrew مثبتًا، قم بتشغيل: brew install make نصيحة إذا رأيت خطأ مثل "make: command not found" عند محاولة تشغيله، فهذا يعني أن برنامج make غير مثبت في PATH. يمكنك إصلاح هذه المشكلة من خلال التحقق من تثبيته بشكل صحيح. كتابة برنامج اختبار بسيط يمكنك مشاهدة برنامج Make أثناء العمل بنفسك من خلال اختبار ملف make أعلاه باستخدام برنامج c بسيط. ستحتاج فقط إلى gcc وmake installed لتجربة ذلك. قم بإنشاء ملف باسم "program.c" واملأه بما يلي: #include int main() { printf("Hello, world.n"); } في هذه المرحلة، اختبر برنامجك للتأكد من صحته (وأنك قمت بتثبيت gcc) عن طريق تشغيل الأمر التالي: gcc -o program program.c تأكد من أن gcc يقوم ببناء البرنامج بنجاح، ثم قم بإزالته: rm program اكتب ملف Makefile الأساسي الآن قم بإنشاء ملف Makefile المثال (إما باسم "Makefile" أو "makefile") بالمحتويات التالية: program: program.c gcc -o program program.c قم بتشغيل Make في محطتك الطرفية، تأكد من أن دليل العمل الخاص بك يحتوي على ملفات Makefile وprogram.c، ثم قم بتشغيل Make: make
بمجرد التأكد من أن Make قام بتجميع برنامجك وبنائه، اختبر سلوكه عن طريق تشغيله مرة أخرى: make
يخبرك برنامج Make بأن كل شيء محدث، لذا فهو لا يقوم بأي شيء الآن. هذه واحدة من أكبر فوائد برنامج Make: فهو لن يقضي وقتًا إلا في بناء المكونات التي تحتاج إلى إعادة البناء. حاول تحديث ملف المصدر وستلاحظ الفرق: touch program.c make
ملاحظة إن الأمر touch هنا يقوم فقط بتحديث وقت تعديل الملف إلى الوقت الحالي. هذه مجرد طريقة سريعة "لخداع" Make ليعتقد أن الملف قد تغير.
ما الذي يمكن أن يفعله Make أيضًا؟
إن Make محدود حقًا بطبيعته المستندة إلى الملفات. يمكن لأي ملف أن يكون جزءًا من عملية البناء الخاصة بك ويعمل كهدف أو اعتماد. هذا يعني أن Make مناسب لمجموعة واسعة من المشاريع. أي شيء بخطوات بناء يمكن التنبؤ بها وقابلة للتكرار مناسب. على سبيل المثال، خذ مولد موقع ثابت يقوم بإنشاء صفحات ويب من مصادر أخرى، غالبًا ما تتضمن ملفات نصية Markdown. سيعيد ملف Make هذا بناء صفحة ويب معينة: index.html: index.md pandoc index.md index.html لقد لمسنا هنا سطح ما يمكن لبرنامج Make القيام به. في الواقع، تحتوي ملفات make على أنماط لتحديد القواعد للعديد من الملفات المختلفة، مما يؤدي إلى إنشاء سلاسل اعتماد معقدة. في المرة القادمة التي تقوم فيها ببناء برنامج، تحقق مما إذا كان هناك ملف make وحاول استكشاف محتوياته. نأمل أن تتمكن من فهم بعض الأساسيات والتعرف على بعض ما يحدث تحت الغطاء. مع وجود دليل GNU make في متناول اليد، يمكنك البدء في استخدام Make لمشاريعك الخاصة لتجنب التوقف غير الضروري. Makefiles هي أداة قوية لتسهيل العمل على المشاريع البرمجية المعقدة وتحقيق أتمتة عالية الدقة. باستخدام Makefiles، يمكنك تقليل الأخطاء، تحسين الكفاءة، وضمان استمرارية العمل بسلاسة. مع القليل من الممارسة، ستصبح كتابة واستخدام Makefiles جزءًا أساسيًا من سير عملك البرمجي. إذا لم تبدأ باستخدامها بعد، فقد حان الوقت لاستكشاف إمكانياتها والاستفادة منها في مشروعك القادم. Read the full article
I cannot find any information on how to create a debug-build target in a makefile for a multiple-compilation-units project that won't need to recompile everything in the project in order to work. Surely there must be a solution to this problem. Surely debug builds aren't mutually exclusive with the speed optimizations from multiple compilation units. Surely there must be some way to faff about with this magical thing in order to accomplish this.
5 reasons why you should learn Make
Maybe you have feel from time to time the speed of the current technology development. Maybe you have taken decisions like “I will choose the latest technology for my new project”. And maybe in the middle of the development you realized your decisions delay you because the new technologies you have chosen are… Well, new.
I always had curiosity for old and reliable technologies so when I started…
View On WordPress
Installing new programs the hard way
Linux system administrators are tasked to install the programs that users need. But sometimes, more advanced users may want to install their own programs. A few common methods are described here.
1.
Compiling, then calling the installation procedure that the program developer designed for you. To do this, just look for a file called README or INSTALL. Most of the time, instructions are
./configure make
These two commands take care of compiling the program. This may be enough in some situations to start using the program. But often, one more command is needed to properly install the program, and it requires root access. Being root means that you're administrator of the system. If you didn't know that, it is quite likely that you do not have root access. If you had, all you'd need to do to install the program would be:
sudo make install
Anyway, this whole process sometimes ends with an error, because of missing dependencies. Let's not go down the rabbit hole of installing dependencies, unless one's really desperate.
2.
If a good soul has already pre-compiled the program for your linux distribution and has gone the extra mile to make it available, then installing is easy: through the system package manager. Let's assume here that you're running Debian or Ubuntu, so the package manager is apt.
If you do not know the exact program name to install, let's say you're looking for BLAST:
apt search blast
It will return a (possibly long) list of programs, including the one you are looking for: ncbi-blast+. Then just type:
sudo apt-get install ncbi-blast+
Easy! In fact XKCD has you covered for many package managers:
Well, although this is meant as a parody because you're unlikely to have all of those (many are specialized), this comic could actually be used in practice.
Small apparté here. “Having root privilege” essentially implies that you can use the command sudo. It allows programs to alter the system. Here, sudo apt-get means to run the program apt-get, with the permission to write stuff to any folder, including the system configuration /etc, and where system programs generally are, /usr. Writing to those folders is typically what is needed to install a program in the system.
The benefits of apt-get are that
it's the easiest way to install a program,
all users of the system can then run the program.
System-installed programs then often reside in /usr/bin/ or /usr/local/bin/ (the difference between those folders is too subtle to be covered here, but you can google it), and those folders are in the PATH environment variable of everyone.
3.
Okay, but sometimes, especially at work, you are not root on the system. So how to proceed? apt-get is out of the question. There a few ways,
./configure --prefix=$HOME make install
is a good one. Then you only need to put $HOME/bin in your PATH, and you’re set:
export PATH=$HOME/bin:$PATH
What this command does is tell your system that whenever you type a command, it has to look for inside $HOME/bin to see whether your command is maybe a program in there.
Small apparté again, regarding shells. A shell is a small program that handles some things behind the scenes related to the command line in your terminal. To find out which shell you have, type echo $SHELL. The export command above is assuming you're running the bash shell. Maybe you need type something else like "setenv PATH $HOME/bin:$PATH" in the tcsh shell.
To make this PATH permanent, just add the export line to your ~/.bashrc or ~/.bash_profile, whichever exists (or ~/.tcshrc).
Anyway, this whole install procedure with the --prefix trick is fine solution as long as your system has all the dependencies that your program needs. By the way, a dependency is typically another program or a library. A library is not exactly a program, but think of it as a piece of a program that can only be used by another program. But maybe you already knew this.
So, this was about installing programs the hard way. In another blog post, we will cover the easy way: non-root package managers, such has linuxbrew and bioconda.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
The question might not even be meaningful, since cake recipes are like Makefiles: no-one ever wrote one from scratch, every one is copied and modified from one that’s close to what you want.
Oh, and the chocolate-marmalade cake! | The Reinvigorated Programmer
Week 9: (Still) Automake
We had a long check in with Sam today and discussed how we’ve been stuck on the make / automake element of the project. I’m quite disappointed with our lack of progress, but this is an area that very few people actually have experience / expertise in. We have diagnosed the issue, however. The command automake is equivalent to typing ./configure && make && make install, but the “&&” break simply means that if the preceding function call exits with a 1 (error), then the subsequent calls will not run. The configure call is ending with an error because the autoconf utility claims that intltoolize is not creating a Makefile.in.in, however, when we independently run checks with intltoolize, then we do receive a Makefile.in.in.
We are not sure what to do at this point. I’m reaching out to the owner of the tutorial which I followed to a) ask him how to remove this error and b) point out that his version checks are extremely outdated.
Sam thinks (and Scott and I agree) that it would be a waste to spend another entire week on Automake, so if we do not get an answer, either from the owner of the tutorial or from IRC, we will revert back to the old (non-automake) way of doing things. I do think that this is a problem that we’ll have to fix before the semester is up though, but we want to get substantive work done this upcoming week.
My plan for this week is two-fold: 1) continue to work on the Automake issue and 2) work with Scott to integrate his (now compiling!) Gjs code into the plug-in. The hardest part of this will be... you guessed correctly.... merging the makefiles!
I hate C.
Week 8: Automake
This week, I spent my time focusing on getting Automake to work. While it “works” right now, it still does not run with the automake command given some of the technicalities of file systems and where the program mounts (some machines do not have permission to place files into the required directory). I also put some additional refining traits onto my console, adding some text buffer functionality and breaking the file into two parts.
An issue that I am having is that I don’t really understand which files are necessary and which are not necessary to actually have in the repository. That is another focus of my research and involves learning a lot about how GIMP language dependencies and C compilation works.
We were not actually able to meet with Sam yet for the week, but we are planning on meeting as soon as possible to have an hour long catch-up meeting in order to plan the architecture. I am a little worried about my progress for this next week. I plan to get automake to 100% work, but after that, there is nothing that I can do until Scott figures out GObject. In order to occupy my time, I might actually contribute to the template for the GIMP plug-in. It’s outdated (dependencies are not up to date) and the makefile is a little incorrect. I will be reaching out to the author this upcoming week.