gnu-make

How do I make a Makefile to log both command and its output to a file?

不羁岁月 提交于 2021-01-28 06:34:41
问题 I want to log both the command and its output to a log file. It seems easy. Just redirect stdout to the log file. myrule: mycommand >> logfile But this only logs the output of the command. Not the command itself. Do I also echo the command and redirect that output to the log file? myrule: @echo mycommand >> logile mycommand >> logfile This duplication of 'mycommand' doesn't look good and it takes up space in the recipe. Especially if the recipe is long. Should I create a function and call it

MSVC - Creating a static library via Makefile

喜夏-厌秋 提交于 2021-01-27 21:31:45
问题 So I've been trying to create a static library under Windows under MSVC by launching mingw32-make under Microsoft's x64 Command Line Tools. I get linker error LNK1561: entry point must be defined. For completeness, here's my Makefile. all: build\lib\libds.lib build\lib\libds.lib: build\obj\priority-queue.obj link /OUT:build\bin\libds.lib build\obj\priority-queue.obj build\obj\priority-queue.obj: libs/ds/priority-queue.c include/ds/priority-queue.h cl /Iinclude /c libs/ds/priority-queue.c /Fo

What's the difference between := and = in Makefile?

白昼怎懂夜的黑 提交于 2021-01-20 14:21:06
问题 For variable assignment in Make, I see := and = operator. What's the difference between them? 回答1: This is described in the GNU Make documentation, in the section titled 6.2 The Two Flavors of Variables . In short, variables defined with := are expanded once, but variables defined with = are expanded whenever they are used. 回答2: Simple assignment := A simple assignment expression is evaluated only once, at the very first occurrence. For example, if CC :=${GCC} ${FLAGS} during the first

What's the difference between := and = in Makefile?

若如初见. 提交于 2021-01-20 14:18:29
问题 For variable assignment in Make, I see := and = operator. What's the difference between them? 回答1: This is described in the GNU Make documentation, in the section titled 6.2 The Two Flavors of Variables . In short, variables defined with := are expanded once, but variables defined with = are expanded whenever they are used. 回答2: Simple assignment := A simple assignment expression is evaluated only once, at the very first occurrence. For example, if CC :=${GCC} ${FLAGS} during the first

Difference between Cmake, gnu make and manually compiling

纵饮孤独 提交于 2020-12-27 07:52:06
问题 I'm new to programming so this is a more of a abstract question than a technical one. I've been using IDE's to learn but I heard they tend to oversimplify the act of compiling,assembling and linking when creating an executable file. I'm trying to download and compile a library without relying on an IDE (in this case librocket). I first had to use Cmake to create the binaries. After configuring and generating, I didn't see any object files or .cpp files in the output directory. I then had to

many Shell Commands architecture

心已入冬 提交于 2020-08-11 11:08:21
问题 at work, we are using docker and docker-compose, our developers need to start many containers locally and import a large database, there are many services that need to run together for development to be successful and easy. so we sort of define reusable functions as make commands to make the code easier to maintain, is there another way to define and reuse many shell commands better than make. for us due to network limitations running docker locally is the only option. we managed to solve

Dictionaries/Maps/Lookup Tables in Makefiles

☆樱花仙子☆ 提交于 2020-06-27 07:40:27
问题 I need to create a lookup table/dictionary/map in my Makefile to look up key-value information. I have been trying to use ifeq statements to do the same thing but my statements seem to fail: # this gets the account id from the current user's ARN, you must have the AWS CLI and jq installed AWS_ACCOUNT_ID:=$(shell aws iam get-user | jq -r '.User.Arn' | awk -F ':' '{print $$5;}') # define a friendly account name for output ifeq ($(AWS_ACCOUNT_ID), 123456) AWS_ACCOUNT_FRIENDLY:=staging endif ifeq